提交 ad377cab 编写于 作者: W Willem de Bruijn 提交者: David S. Miller

packet: rollover prepare: move code out of callsites

packet_rcv_fanout calls fanout_demux_rollover twice. Move all rollover
logic into the callee to simplify these callsites, especially with
upcoming changes.

The main differences between the two callsites is that the FLAG
variant tests whether the socket previously selected by another
mode (RR, RND, HASH, ..) has room before migrating flows, whereas the
rollover mode has no original socket to test.
Signed-off-by: NWillem de Bruijn <willemb@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7d771aaa
...@@ -1318,18 +1318,22 @@ static unsigned int fanout_demux_rnd(struct packet_fanout *f, ...@@ -1318,18 +1318,22 @@ static unsigned int fanout_demux_rnd(struct packet_fanout *f,
static unsigned int fanout_demux_rollover(struct packet_fanout *f, static unsigned int fanout_demux_rollover(struct packet_fanout *f,
struct sk_buff *skb, struct sk_buff *skb,
unsigned int idx, unsigned int skip, unsigned int idx, bool try_self,
unsigned int num) unsigned int num)
{ {
unsigned int i, j; unsigned int i, j;
if (try_self && packet_rcv_has_room(pkt_sk(f->arr[idx]), skb))
return idx;
i = j = min_t(int, f->next[idx], num - 1); i = j = min_t(int, f->next[idx], num - 1);
do { do {
if (i != skip && packet_rcv_has_room(pkt_sk(f->arr[i]), skb)) { if (i != idx && packet_rcv_has_room(pkt_sk(f->arr[i]), skb)) {
if (i != j) if (i != j)
f->next[idx] = i; f->next[idx] = i;
return i; return i;
} }
if (++i == num) if (++i == num)
i = 0; i = 0;
} while (i != j); } while (i != j);
...@@ -1386,17 +1390,14 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev, ...@@ -1386,17 +1390,14 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
idx = fanout_demux_qm(f, skb, num); idx = fanout_demux_qm(f, skb, num);
break; break;
case PACKET_FANOUT_ROLLOVER: case PACKET_FANOUT_ROLLOVER:
idx = fanout_demux_rollover(f, skb, 0, (unsigned int) -1, num); idx = fanout_demux_rollover(f, skb, 0, false, num);
break; break;
} }
po = pkt_sk(f->arr[idx]); if (fanout_has_flag(f, PACKET_FANOUT_FLAG_ROLLOVER))
if (fanout_has_flag(f, PACKET_FANOUT_FLAG_ROLLOVER) && idx = fanout_demux_rollover(f, skb, idx, true, num);
unlikely(!packet_rcv_has_room(po, skb))) {
idx = fanout_demux_rollover(f, skb, idx, idx, num);
po = pkt_sk(f->arr[idx]);
}
po = pkt_sk(f->arr[idx]);
return po->prot_hook.func(skb, dev, &po->prot_hook, orig_dev); return po->prot_hook.func(skb, dev, &po->prot_hook, orig_dev);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册