diff options
-rw-r--r-- | ring.c | 7 | ||||
-rw-r--r-- | ring.h | 2 | ||||
-rw-r--r-- | ring_rx.c | 2 | ||||
-rw-r--r-- | ring_tx.c | 2 | ||||
-rw-r--r-- | sock.c | 10 | ||||
-rw-r--r-- | sock.h | 1 | ||||
-rw-r--r-- | trafgen.c | 2 |
7 files changed, 20 insertions, 6 deletions
@@ -41,7 +41,7 @@ void alloc_ring_frames_generic(struct ring *ring, int num, size_t size) } } -void bind_ring_generic(int sock, struct ring *ring, int ifindex) +void bind_ring_generic(int sock, struct ring *ring, int ifindex, bool tx_only) { int ret; /* The {TX,RX}_RING registers itself to the networking stack with @@ -51,7 +51,10 @@ void bind_ring_generic(int sock, struct ring *ring, int ifindex) fmemset(&ring->s_ll, 0, sizeof(ring->s_ll)); ring->s_ll.sll_family = AF_PACKET; - ring->s_ll.sll_protocol = htons(ETH_P_ALL); + if (tx_only) + ring->s_ll.sll_protocol = 0; + else + ring->s_ll.sll_protocol = htons(ETH_P_ALL); ring->s_ll.sll_ifindex = ifindex; ring->s_ll.sll_hatype = 0; ring->s_ll.sll_halen = 0; @@ -159,6 +159,6 @@ static inline int get_sockopt_tpacket(int sock) extern void mmap_ring_generic(int sock, struct ring *ring); extern void alloc_ring_frames_generic(struct ring *ring, int num, size_t size); -extern void bind_ring_generic(int sock, struct ring *ring, int ifindex); +extern void bind_ring_generic(int sock, struct ring *ring, int ifindex, bool tx_only); #endif /* RING_H */ @@ -134,7 +134,7 @@ void alloc_rx_ring_frames(int sock, struct ring *ring) void bind_rx_ring(int sock, struct ring *ring, int ifindex) { - bind_ring_generic(sock, ring, ifindex); + bind_ring_generic(sock, ring, ifindex, false); } void sock_rx_net_stats(int sock, unsigned long seen) @@ -108,5 +108,5 @@ void alloc_tx_ring_frames(int sock __maybe_unused, struct ring *ring) void bind_tx_ring(int sock, struct ring *ring, int ifindex) { - bind_ring_generic(sock, ring, ifindex); + bind_ring_generic(sock, ring, ifindex, true); } @@ -33,6 +33,16 @@ int pf_socket(void) return sock; } +int pf_tx_socket(void) +{ + int sock = socket(PF_PACKET, SOCK_RAW, 0); + if (unlikely(sock < 0)) + panic("Creation of PF TX socket failed!\n"); + + return sock; +} + + void set_sock_prio(int fd, int prio) { int ret, val = prio; @@ -3,6 +3,7 @@ extern int af_socket(int af); extern int pf_socket(void); +extern int pf_tx_socket(void); extern void set_nonblocking(int fd); extern int set_nonblocking_sloppy(int fd); extern int set_reuseaddr(int fd); @@ -854,7 +854,7 @@ static void main_loop(struct ctx *ctx, char *confname, bool slow, fflush(stdout); } - sock = pf_socket(); + sock = pf_tx_socket(); if (slow) xmit_slowpath_or_die(ctx, cpu, orig_num); |