|
88 | 88 | #include <linux/virtio_net.h>
|
89 | 89 | #include <linux/errqueue.h>
|
90 | 90 | #include <linux/net_tstamp.h>
|
91 |
| - |
| 91 | +#include <linux/reciprocal_div.h> |
92 | 92 | #ifdef CONFIG_INET
|
93 | 93 | #include <net/inet_common.h>
|
94 | 94 | #endif
|
@@ -1158,6 +1158,13 @@ static unsigned int fanout_demux_cpu(struct packet_fanout *f,
|
1158 | 1158 | return smp_processor_id() % num;
|
1159 | 1159 | }
|
1160 | 1160 |
|
| 1161 | +static unsigned int fanout_demux_rnd(struct packet_fanout *f, |
| 1162 | + struct sk_buff *skb, |
| 1163 | + unsigned int num) |
| 1164 | +{ |
| 1165 | + return reciprocal_divide(prandom_u32(), num); |
| 1166 | +} |
| 1167 | + |
1161 | 1168 | static unsigned int fanout_demux_rollover(struct packet_fanout *f,
|
1162 | 1169 | struct sk_buff *skb,
|
1163 | 1170 | unsigned int idx, unsigned int skip,
|
@@ -1215,6 +1222,9 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
|
1215 | 1222 | case PACKET_FANOUT_CPU:
|
1216 | 1223 | idx = fanout_demux_cpu(f, skb, num);
|
1217 | 1224 | break;
|
| 1225 | + case PACKET_FANOUT_RND: |
| 1226 | + idx = fanout_demux_rnd(f, skb, num); |
| 1227 | + break; |
1218 | 1228 | case PACKET_FANOUT_ROLLOVER:
|
1219 | 1229 | idx = fanout_demux_rollover(f, skb, 0, (unsigned int) -1, num);
|
1220 | 1230 | break;
|
@@ -1284,6 +1294,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
|
1284 | 1294 | case PACKET_FANOUT_HASH:
|
1285 | 1295 | case PACKET_FANOUT_LB:
|
1286 | 1296 | case PACKET_FANOUT_CPU:
|
| 1297 | + case PACKET_FANOUT_RND: |
1287 | 1298 | break;
|
1288 | 1299 | default:
|
1289 | 1300 | return -EINVAL;
|
|
0 commit comments