summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ring.c7
-rw-r--r--ring.h2
-rw-r--r--ring_rx.c2
-rw-r--r--ring_tx.c2
-rw-r--r--sock.c10
-rw-r--r--sock.h1
-rw-r--r--trafgen.c2
7 files changed, 20 insertions, 6 deletions
diff --git a/ring.c b/ring.c
index a227957..e42828e 100644
--- a/ring.c
+++ b/ring.c
@@ -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;
diff --git a/ring.h b/ring.h
index 1ab81b0..cb09d99 100644
--- a/ring.h
+++ b/ring.h
@@ -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 */
diff --git a/ring_rx.c b/ring_rx.c
index 54505da..355d10c 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -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)
diff --git a/ring_tx.c b/ring_tx.c
index 100b3f0..9fef7f0 100644
--- a/ring_tx.c
+++ b/ring_tx.c
@@ -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);
}
diff --git a/sock.c b/sock.c
index 1cefb83..a8b4f82 100644
--- a/sock.c
+++ b/sock.c
@@ -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;
diff --git a/sock.h b/sock.h
index 007bf2a..75be501 100644
--- a/sock.h
+++ b/sock.h
@@ -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);
diff --git a/trafgen.c b/trafgen.c
index b27cb70..e69fcb5 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -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);