diff options
-rw-r--r-- | icmp.c | 4 | ||||
-rw-r--r-- | icmp.h | 4 | ||||
-rw-r--r-- | tap.c | 26 | ||||
-rw-r--r-- | tcp.c | 6 | ||||
-rw-r--r-- | tcp.h | 3 | ||||
-rw-r--r-- | udp.c | 5 | ||||
-rw-r--r-- | udp.h | 3 |
7 files changed, 34 insertions, 17 deletions
@@ -148,6 +148,7 @@ void icmpv6_sock_handler(const struct ctx *c, union epoll_ref ref) /** * icmp_tap_handler() - Handle packets from tap * @c: Execution context + * @pif: pif on which the packet is arriving * @af: Address family, AF_INET or AF_INET6 * @saddr: Source address * @daddr: Destination address @@ -156,13 +157,14 @@ void icmpv6_sock_handler(const struct ctx *c, union epoll_ref ref) * * Return: count of consumed packets (always 1, even if malformed) */ -int icmp_tap_handler(const struct ctx *c, int af, +int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af, const void *saddr, const void *daddr, const struct pool *p, const struct timespec *now) { size_t plen; (void)saddr; + (void)pif; if (af == AF_INET) { struct sockaddr_in sa = { @@ -12,8 +12,8 @@ struct ctx; void icmp_sock_handler(const struct ctx *c, union epoll_ref ref); void icmpv6_sock_handler(const struct ctx *c, union epoll_ref ref); -int icmp_tap_handler(const struct ctx *c, - int af, const void *saddr, const void *daddr, +int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af, + const void *saddr, const void *daddr, const struct pool *p, const struct timespec *now); void icmp_timer(const struct ctx *c, const struct timespec *ts); void icmp_init(void); @@ -645,7 +645,8 @@ resume: tap_packet_debug(iph, NULL, NULL, 0, NULL, 1); packet_add(pkt, l4_len, l4h); - icmp_tap_handler(c, AF_INET, &iph->saddr, &iph->daddr, + icmp_tap_handler(c, PIF_TAP, AF_INET, + &iph->saddr, &iph->daddr, pkt, now); continue; } @@ -719,14 +720,16 @@ append: if (c->no_tcp) continue; for (k = 0; k < p->count; ) - k += tcp_tap_handler(c, AF_INET, &seq->saddr, - &seq->daddr, p, k, now); + k += tcp_tap_handler(c, PIF_TAP, AF_INET, + &seq->saddr, &seq->daddr, + p, k, now); } else if (seq->protocol == IPPROTO_UDP) { if (c->no_udp) continue; for (k = 0; k < p->count; ) - k += udp_tap_handler(c, AF_INET, &seq->saddr, - &seq->daddr, p, k, now); + k += udp_tap_handler(c, PIF_TAP, AF_INET, + &seq->saddr, &seq->daddr, + p, k, now); } } @@ -807,7 +810,8 @@ resume: tap_packet_debug(NULL, ip6h, NULL, proto, NULL, 1); packet_add(pkt, l4_len, l4h); - icmp_tap_handler(c, AF_INET6, saddr, daddr, pkt, now); + icmp_tap_handler(c, PIF_TAP, AF_INET6, + saddr, daddr, pkt, now); continue; } @@ -883,14 +887,16 @@ append: if (c->no_tcp) continue; for (k = 0; k < p->count; ) - k += tcp_tap_handler(c, AF_INET6, &seq->saddr, - &seq->daddr, p, k, now); + k += tcp_tap_handler(c, PIF_TAP, AF_INET6, + &seq->saddr, &seq->daddr, + p, k, now); } else if (seq->protocol == IPPROTO_UDP) { if (c->no_udp) continue; for (k = 0; k < p->count; ) - k += udp_tap_handler(c, AF_INET6, &seq->saddr, - &seq->daddr, p, k, now); + k += udp_tap_handler(c, PIF_TAP, AF_INET6, + &seq->saddr, &seq->daddr, + p, k, now); } } @@ -2562,6 +2562,7 @@ static void tcp_conn_from_sock_finish(struct ctx *c, struct tcp_tap_conn *conn, /** * tcp_tap_handler() - Handle packets from tap and state transitions * @c: Execution context + * @pif: pif on which the packet is arriving * @af: Address family, AF_INET or AF_INET6 * @saddr: Source address * @daddr: Destination address @@ -2571,7 +2572,8 @@ static void tcp_conn_from_sock_finish(struct ctx *c, struct tcp_tap_conn *conn, * * Return: count of consumed packets */ -int tcp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, +int tcp_tap_handler(struct ctx *c, uint8_t pif, int af, + const void *saddr, const void *daddr, const struct pool *p, int idx, const struct timespec *now) { struct tcp_tap_conn *conn; @@ -2581,6 +2583,8 @@ int tcp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, char *opts; int count; + (void)pif; + th = packet_get(p, idx, 0, sizeof(*th), &len); if (!th) return 1; @@ -17,7 +17,8 @@ void tcp_timer_handler(struct ctx *c, union epoll_ref ref); void tcp_listen_handler(struct ctx *c, union epoll_ref ref, const struct timespec *now); void tcp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events); -int tcp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, +int tcp_tap_handler(struct ctx *c, uint8_t pif, int af, + const void *saddr, const void *daddr, const struct pool *p, int idx, const struct timespec *now); int tcp_sock_init(const struct ctx *c, sa_family_t af, const void *addr, const char *ifname, in_port_t port); @@ -787,6 +787,7 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, /** * udp_tap_handler() - Handle packets from tap * @c: Execution context + * @pif: pif on which the packet is arriving * @af: Address family, AF_INET or AF_INET6 * @saddr: Source address * @daddr: Destination address @@ -798,7 +799,8 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, * * #syscalls sendmmsg */ -int udp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, +int udp_tap_handler(struct ctx *c, uint8_t pif, + int af, const void *saddr, const void *daddr, const struct pool *p, int idx, const struct timespec *now) { struct mmsghdr mm[UIO_MAXIOV]; @@ -813,6 +815,7 @@ int udp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, (void)c; (void)saddr; + (void)pif; uh = packet_get(p, idx, 0, sizeof(*uh), NULL); if (!uh) @@ -10,7 +10,8 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, const struct timespec *now); -int udp_tap_handler(struct ctx *c, int af, const void *saddr, const void *daddr, +int udp_tap_handler(struct ctx *c, uint8_t pif, int af, + const void *saddr, const void *daddr, const struct pool *p, int idx, const struct timespec *now); int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, const void *addr, const char *ifname, in_port_t port); |