/*----------------------------------------------------------------------------*/ int ProcessPacket(mtcp_manager_t mtcp, const int ifidx, uint32_t cur_ts, unsigned char *pkt_data, int len) { struct ethhdr *ethh = (struct ethhdr *)pkt_data; u_short ip_proto = ntohs(ethh->h_proto); int ret; #ifdef PKTDUMP DumpPacket(mtcp, (char *)pkt_data, len, "IN", ifidx); #endif #ifdef NETSTAT mtcp->nstat.rx_packets[ifidx]++; mtcp->nstat.rx_bytes[ifidx] += len + 24; #endif /* NETSTAT */ #if 0 /* ignore mac address which is not for current interface */ int i; for (i = 0; i < 6; i ++) { if (ethh->h_dest[i] != CONFIG.eths[ifidx].haddr[i]) { return FALSE; } } #endif if (ip_proto == ETH_P_IP) { /* process ipv4 packet */ ret = ProcessIPv4Packet(mtcp, cur_ts, ifidx, pkt_data, len); } else if (ip_proto == ETH_P_ARP) { ProcessARPPacket(mtcp, cur_ts, ifidx, pkt_data, len); return TRUE; } else { //DumpPacket(mtcp, (char *)pkt_data, len, "??", ifidx); struct ps_packet packet; packet.ifindex = ifidx; packet.len = len; packet.buf = (char *)pkt_data; ps_slowpath_packet(mtcp->ctx->handle, &packet); return TRUE; } #ifdef NETSTAT if (ret < 0) { mtcp->nstat.rx_errors[ifidx]++; } #endif return ret; }
/*----------------------------------------------------------------------------*/ void psio_release_pkt(struct mtcp_thread_context *ctxt, int ifidx, unsigned char *pkt_data, int len) { struct psio_private_context *ppc; struct ps_packet packet; ppc = (struct psio_private_context *)ctxt->io_private_context; /* pass the packet to the kernel */ packet.ifindex = ifidx; packet.len = len; packet.buf = (char *)pkt_data; ps_slowpath_packet(&ppc->handle, &packet); }