pf_packet updates
Subsystems (4)
cover pf_packet updates
Daniel Borkmann (3):
net: packet: add random fanout scheduler
net: packet: use reciprocal_divide in fanout_demux_hash
net: packet: document available fanout policies
Documentation/networking/packet_mmap.txt | 8 ++++++++ include/uapi/linux/if_packet.h | 1 + net/packet/af_packet.c | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/3 net: packet: add randomized fanout scheduler
We currently allow for different fanout scheduling policies in pf_packet such as scheduling by skb's rxhash, round-robin, by cpu, and rollover. Also allow for a random, equidistributed selection of the socket from the fanout process group.
--- include/uapi/linux/if_packet.h | 1 + net/packet/af_packet.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
include/uapi/linux/if_packet.h +1 -0
@@ -56,6 +56,7 @@ struct sockaddr_ll {#define PACKET_FANOUT_LB 1#define PACKET_FANOUT_CPU 2#define PACKET_FANOUT_ROLLOVER 3 +#define PACKET_FANOUT_RND 4#define PACKET_FANOUT_FLAG_ROLLOVER 0x1000#define PACKET_FANOUT_FLAG_DEFRAG 0x8000
net/packet/af_packet.c +12 -1
@@ -88,7 +88,7 @@#include <linux/virtio_net.h> #include <linux/errqueue.h> #include <linux/net_tstamp.h> - +#include <linux/reciprocal_div.h> #ifdef CONFIG_INET #include <net/inet_common.h> #endif
@@ -1158,6 +1158,13 @@ static unsigned int fanout_demux_cpu(struct packet_fanout *f,return smp_processor_id () % num; } +static unsigned int fanout_demux_rnd (struct packet_fanout *f, +struct sk_buff *skb, +unsigned int num) +{ +return reciprocal_divide (prandom_u32 (), num); +} + static unsigned int fanout_demux_rollover(struct packet_fanout *f, struct sk_buff *skb, unsigned int idx, unsigned int skip,
@@ -1215,6 +1222,9 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,case PACKET_FANOUT_CPU : idx =fanout_demux_cpu (f, skb, num);break ; +case PACKET_FANOUT_RND : + idx =fanout_demux_rnd (f, skb, num); +break ;case PACKET_FANOUT_ROLLOVER : idx =fanout_demux_rollover (f, skb,0 , (unsigned int )-1 , num);break ;
@@ -1284,6 +1294,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)case PACKET_FANOUT_HASH :case PACKET_FANOUT_LB :case PACKET_FANOUT_CPU : +case PACKET_FANOUT_RND :break ;default :return -EINVAL ;
Signature · 1 line
1.7.11.7
PATCH 2/3 net: packet: use reciprocal_divide in fanout_demux_hash
In reply to Daniel BorkmannInstead of hard-coding reciprocal_divide function, use the inline function from reciprocal_div.h.
--- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/packet/af_packet.c +1 -1
@@ -1135,7 +1135,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f, struct sk_buff *skb, unsigned int num) { -return (((u64 )skb->rxhash) * num) >>32 ; +return reciprocal_divide (skb->rxhash, num); } static unsigned int fanout_demux_lb(struct packet_fanout *f,
Signature · 1 line
1.7.11.7
PATCH 3/3 net: packet: document available fanout policies
In reply to Daniel BorkmannUpdate documentation to add fanout policies that are available.
--- Documentation/networking/packet_mmap.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/networking/packet_mmap.txt +8 -0
@@ -543,6 +543,14 @@ TPACKET_V2 --> TPACKET_V3: In the AF_PACKET fanout mode, packet reception can be load balanced among processes. This also works in combination with mmap(2) on packet sockets. +Currently implemented fanout policies are: + + - PACKET_FANOUT_HASH: schedule to socket by skb's rxhash + - PACKET_FANOUT_LB: schedule to socket by round-robin + - PACKET_FANOUT_CPU: schedule to socket by CPU packet arrives on + - PACKET_FANOUT_RND: schedule to socket by random selection + - PACKET_FANOUT_ROLLOVER: if one socket is full, rollover to another + Minimal example code by David S. Miller (try things like "./test eth0 hash", "./test eth0 lb", etc.):
Signature · 1 line
1.7.11.7
Re: [PATCH net-next 2/3] net: packet: use reciprocal_divide in fanout_demux_hash
In reply to Daniel BorkmannQuoted 3 lines · Daniel Borkmann
Instead of hard-coding
reciprocal_dividefunction, use the inline function fromreciprocal_div.h.
Then you should #include <linux/reciprocal_div.h> directly?
David Miller
maintainerFrom: Daniel Borkmann <[email protected]>
Date: Wed, 28 Aug 2013 22:13:08 +0200
Quoted 4 lines
Daniel Borkmann (3):
net: packet: add random fanout scheduler
net: packet: usereciprocal_divideinfanout_demux_hash
net: packet: document available fanout policies
Please add the missing reciprocal_divide.h include to the second patch, as per Eric Dumazet's feedback, and resubmit this series.
Thanks.
Quoted 10 lines · David Miller
From: Daniel Borkmann <[email protected]>
Date: Wed, 28 Aug 2013 22:13:08 +0200Quoted 4 lines
Daniel Borkmann (3):
net: packet: add random fanout scheduler
net: packet: usereciprocal_divideinfanout_demux_hash
net: packet: document available fanout policiesPlease add the missing
reciprocal_divide.hinclude to the second patch, as per Eric Dumazet's feedback, and resubmit this series.
That is already the case in the first patch of the series. It adds:
...
+#include <linux/reciprocal_div.h>
...
Quoted 10 lines · David Miller
From: Daniel Borkmann <[email protected]>
Date: Wed, 28 Aug 2013 22:13:08 +0200Quoted 4 lines
Daniel Borkmann (3):
net: packet: add random fanout scheduler
net: packet: usereciprocal_divideinfanout_demux_hash
net: packet: document available fanout policiesPlease add the missing
reciprocal_divide.hinclude to the second patch, as per Eric Dumazet's feedback, and resubmit this series.
(It was Cong Wang feedback ;) )
Thanks
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Thu, 29 Aug 2013 03:25:45 -0700
Quoted 9 lines · David Miller
Quoted 8 lines
From: Daniel Borkmann <[email protected]>
Date: Wed, 28 Aug 2013 22:13:08 +0200Quoted 4 lines
Daniel Borkmann (3):
net: packet: add random fanout scheduler
net: packet: usereciprocal_divideinfanout_demux_hash
net: packet: document available fanout policies
Quoted 4 lines
Quoted 2 lines
Please add the missing
reciprocal_divide.hinclude to the second patch, as per Eric Dumazet's feedback, and resubmit this series.(It was Cong Wang feedback ;) )
Sorry Eric, I am just too anxious to give you credit everywhere that I can. :-)
Anyways, thanks for explaining Daniel, I've put these patches back into the to-apply queue.
Thanks!
From: Daniel Borkmann <[email protected]>
Date: Thu, 29 Aug 2013 08:20:14 +0200
Quoted 9 lines · David Miller
Quoted 8 lines
From: Daniel Borkmann <[email protected]>
Date: Wed, 28 Aug 2013 22:13:08 +0200Quoted 4 lines
Daniel Borkmann (3):
net: packet: add random fanout scheduler
net: packet: usereciprocal_divideinfanout_demux_hash
net: packet: document available fanout policies
Quoted 7 lines
Quoted 2 lines
Please add the missing
reciprocal_divide.hinclude to the second patch, as per Eric Dumazet's feedback, and resubmit this series.That is already the case in the first patch of the series. It adds:
...
+#include <linux/reciprocal_div.h>
Series applied, thanks Daniel.