Skip to content

Commit 13a8e0c

Browse files
jiribohacdavem330
authored andcommitted
bonding: don't increase rx_dropped after processing LACPDUs
Since commit 3aba891, bonding processes LACP frames (802.3ad mode) with bond_handle_frame(). Currently a copy of the skb is made and the original is left to be processed by other rx_handlers and the rest of the network stack by returning RX_HANDLER_ANOTHER. As there is no protocol handler for PKT_TYPE_LACPDU, the frame is dropped and dev->rx_dropped increased. Fix this by making bond_handle_frame() return RX_HANDLER_CONSUMED if bonding has processed the LACP frame. Signed-off-by: Jiri Bohac <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 38bf195 commit 13a8e0c

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

drivers/net/bonding/bond_3ad.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,9 +2173,10 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
21732173
* received frames (loopback). Since only the payload is given to this
21742174
* function, it check for loopback.
21752175
*/
2176-
static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u16 length)
2176+
static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u16 length)
21772177
{
21782178
struct port *port;
2179+
int ret = RX_HANDLER_ANOTHER;
21792180

21802181
if (length >= sizeof(struct lacpdu)) {
21812182

@@ -2184,11 +2185,12 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
21842185
if (!port->slave) {
21852186
pr_warning("%s: Warning: port of slave %s is uninitialized\n",
21862187
slave->dev->name, slave->dev->master->name);
2187-
return;
2188+
return ret;
21882189
}
21892190

21902191
switch (lacpdu->subtype) {
21912192
case AD_TYPE_LACPDU:
2193+
ret = RX_HANDLER_CONSUMED;
21922194
pr_debug("Received LACPDU on port %d\n",
21932195
port->actor_port_number);
21942196
/* Protect against concurrent state machines */
@@ -2198,6 +2200,7 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
21982200
break;
21992201

22002202
case AD_TYPE_MARKER:
2203+
ret = RX_HANDLER_CONSUMED;
22012204
// No need to convert fields to Little Endian since we don't use the marker's fields.
22022205

22032206
switch (((struct bond_marker *)lacpdu)->tlv_type) {
@@ -2219,6 +2222,7 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
22192222
}
22202223
}
22212224
}
2225+
return ret;
22222226
}
22232227

22242228
/**
@@ -2456,18 +2460,20 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
24562460
return NETDEV_TX_OK;
24572461
}
24582462

2459-
void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond,
2463+
int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond,
24602464
struct slave *slave)
24612465
{
2466+
int ret = RX_HANDLER_ANOTHER;
24622467
if (skb->protocol != PKT_TYPE_LACPDU)
2463-
return;
2468+
return ret;
24642469

24652470
if (!pskb_may_pull(skb, sizeof(struct lacpdu)))
2466-
return;
2471+
return ret;
24672472

24682473
read_lock(&bond->lock);
2469-
bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len);
2474+
ret = bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len);
24702475
read_unlock(&bond->lock);
2476+
return ret;
24712477
}
24722478

24732479
/*

drivers/net/bonding/bond_3ad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave);
274274
void bond_3ad_handle_link_change(struct slave *slave, char link);
275275
int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
276276
int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
277-
void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond,
277+
int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond,
278278
struct slave *slave);
279279
int bond_3ad_set_carrier(struct bonding *bond);
280280
void bond_3ad_update_lacp_rate(struct bonding *bond);

drivers/net/bonding/bond_main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,9 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
14441444
struct sk_buff *skb = *pskb;
14451445
struct slave *slave;
14461446
struct bonding *bond;
1447-
void (*recv_probe)(struct sk_buff *, struct bonding *,
1447+
int (*recv_probe)(struct sk_buff *, struct bonding *,
14481448
struct slave *);
1449+
int ret = RX_HANDLER_ANOTHER;
14491450

14501451
skb = skb_share_check(skb, GFP_ATOMIC);
14511452
if (unlikely(!skb))
@@ -1464,8 +1465,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
14641465
struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
14651466

14661467
if (likely(nskb)) {
1467-
recv_probe(nskb, bond, slave);
1468+
ret = recv_probe(nskb, bond, slave);
14681469
dev_kfree_skb(nskb);
1470+
if (ret == RX_HANDLER_CONSUMED) {
1471+
consume_skb(skb);
1472+
return ret;
1473+
}
14691474
}
14701475
}
14711476

@@ -1487,7 +1492,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
14871492
memcpy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, ETH_ALEN);
14881493
}
14891494

1490-
return RX_HANDLER_ANOTHER;
1495+
return ret;
14911496
}
14921497

14931498
/* enslave device <slave> to bond device <master> */
@@ -2723,15 +2728,15 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
27232728
}
27242729
}
27252730

2726-
static void bond_arp_rcv(struct sk_buff *skb, struct bonding *bond,
2731+
static int bond_arp_rcv(struct sk_buff *skb, struct bonding *bond,
27272732
struct slave *slave)
27282733
{
27292734
struct arphdr *arp;
27302735
unsigned char *arp_ptr;
27312736
__be32 sip, tip;
27322737

27332738
if (skb->protocol != __cpu_to_be16(ETH_P_ARP))
2734-
return;
2739+
return RX_HANDLER_ANOTHER;
27352740

27362741
read_lock(&bond->lock);
27372742

@@ -2776,6 +2781,7 @@ static void bond_arp_rcv(struct sk_buff *skb, struct bonding *bond,
27762781

27772782
out_unlock:
27782783
read_unlock(&bond->lock);
2784+
return RX_HANDLER_ANOTHER;
27792785
}
27802786

27812787
/*

0 commit comments

Comments
 (0)