bonding: set correct vlan id for alb xmit path
Subsystems (3)
PATCH 1/1 bonding: set correct vlan id for alb xmit path
The commit d3ab3ffd1d728d7ee77340e7e7e2c7cfe6a4013e (bonding: use rlb_client_info->vlan_id instead of ->tag) remove the rlb_client_info->tag, but occur some issues, The vlan_get_tag() will return 0 for success and -EINVAL for error, so the client_info->vlan_id always be set to 0 if the vlan_get_tag return 0 for success, so the client_info would never get a correct vlan id, and could not send a skb for vlan id 0.
Fix this by convert the client_info->vlan_id from u16 to s16, and set to -1 for default value, the s16 is enough for the range of the vlan id.
--- drivers/net/bonding/bond_alb.c | 8 ++++---- drivers/net/bonding/bond_alb.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/bonding/bond_alb.c +4 -4
@@ -539,7 +539,7 @@ static void rlb_update_client(struct rlb_client_info *client_info) skb->dev = client_info->slave->dev; -if (client_info->vlan_id) { +if (client_info->vlan_id >=0 ) { skb =vlan_put_tag (skb,htons (ETH_P_8021Q ), client_info->vlan_id);if (!skb) { pr_err("%s: Error: failed to insert VLAN tag\n",
@@ -722,8 +722,8 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon client_info->ntt =0 ; } -if (!vlan_get_tag (skb, &client_info->vlan_id)) - client_info->vlan_id =0 ; +if (vlan_get_tag (skb, &client_info->vlan_id)) + client_info->vlan_id =-1 ;if (!client_info->assigned) {u32 prev_tbl_head = bond_info->rx_hashtbl_used_head;
@@ -827,7 +827,7 @@ static void rlb_init_table_entry_dst(struct rlb_client_info *entry) entry->used_prev =RLB_NULL_INDEX ; entry->assigned =0 ; entry->slave =NULL ; - entry->vlan_id =0 ; + entry->vlan_id =-1 ; }static void rlb_init_table_entry_src (struct rlb_client_info *entry) {
drivers/net/bonding/bond_alb.h +1 -1
@@ -125,7 +125,7 @@ struct rlb_client_info {u8 assigned;/* checking whether this entry is assigned */ u8 ntt;/* flag - need to transmit client info */ struct slave *slave;/* the slave assigned to this client */ -unsigned short vlan_id;/* VLAN tag associated with IP address */ +short vlan_id;/* VLAN tag associated with IP address */ };struct tlb_slave_info {
Signature · 1 line
1.8.0
Quoted 12 lines · Ding Tianhong
The commit
d3ab3ffd1d728d7ee77340e7e7e2c7cfe6a4013e(bonding: userlb_client_info->vlan_idinstead of ->tag) remove therlb_client_info->tag, but occur some issues, Thevlan_get_tag()will return 0 for success and-EINVALfor error, so theclient_info->vlan_idalways be set to 0 if thevlan_get_tagreturn 0 for success, so theclient_infowould never get a correct vlan id, and could not send a skb for vlan id 0.Fix this by convert the
client_info->vlan_idfrom u16 to s16, and set to -1 for default value, the s16 is enough for the range of the vlan id.
Quoted 6 lines
Fixes d3ab3ffd1d7 (bonding: use rlb_client_info->vlan_id instead of ->tag)CC Ding Tianhong <[email protected]>CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Ding Tianhong <[email protected]>
Wrong CC list, sorry for that, resend.
Quoted 52 lines
--- drivers/net/bonding/bond_alb.c | 8 ++++---- drivers/net/bonding/bond_alb.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)drivers/net/bonding/bond_alb.c +4
-4@@ -539,7 +539,7 @@ static void rlb_update_client(struct rlb_client_info *client_info) skb->dev = client_info->slave->dev; -if (client_info->vlan_id) { +if (client_info->vlan_id >=0 ) { skb =vlan_put_tag (skb,htons (ETH_P_8021Q ), client_info->vlan_id);if (!skb) { pr_err("%s: Error: failed to insert VLAN tag\n",@@ -722,8 +722,8 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon client_info->ntt =0 ; } -if (!vlan_get_tag (skb, &client_info->vlan_id)) - client_info->vlan_id =0 ; +if (vlan_get_tag (skb, &client_info->vlan_id)) + client_info->vlan_id =-1 ;if (!client_info->assigned) {u32 prev_tbl_head = bond_info->rx_hashtbl_used_head;@@ -827,7 +827,7 @@ static void rlb_init_table_entry_dst(struct rlb_client_info *entry) entry->used_prev =RLB_NULL_INDEX ; entry->assigned =0 ; entry->slave =NULL ; - entry->vlan_id =0 ; + entry->vlan_id =-1 ; }static void rlb_init_table_entry_src (struct rlb_client_info *entry) {drivers/net/bonding/bond_alb.h +1
-1@@ -125,7 +125,7 @@ struct rlb_client_info {u8 assigned;/* checking whether this entry is assigned */ u8 ntt;/* flag - need to transmit client info */ struct slave *slave;/* the slave assigned to this client */ -unsigned short vlan_id;/* VLAN tag associated with IP address */ +short vlan_id;/* VLAN tag associated with IP address */ };struct tlb_slave_info {
PATCH 1/1 bonding: set correct vlan id for alb xmit path
In reply to Ding TianhongThe commit d3ab3ffd1d728d7ee77340e7e7e2c7cfe6a4013e (bonding: use rlb_client_info->vlan_id instead of ->tag) remove the rlb_client_info->tag, but occur some issues, The vlan_get_tag() will return 0 for success and -EINVAL for error, so the client_info->vlan_id always be set to 0 if the vlan_get_tag return 0 for success, so the client_info would never get a correct vlan id.
We should only set the vlan id to 0 when the vlan_get_tag return error.
--- drivers/net/bonding/bond_alb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_alb.c +1 -1
@@ -730,7 +730,7 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon client_info->ntt =0 ; } -if (!vlan_get_tag (skb, &client_info->vlan_id)) +if (vlan_get_tag (skb, &client_info->vlan_id)) client_info->vlan_id =0 ;if (!client_info->assigned) {
Signature · 1 line
1.8.0
Quoted 8 lines · Ding Tianhong
The commit
d3ab3ffd1d728d7ee77340e7e7e2c7cfe6a4013e(bonding: userlb_client_info->vlan_idinstead of ->tag) remove therlb_client_info->tag, but occur some issues, Thevlan_get_tag()will return 0 for success and-EINVALfor error, so theclient_info->vlan_idalways be set to 0 if thevlan_get_tagreturn 0 for success, so theclient_infowould never get a correct vlan id.
Quoted 8 lines
We should only set the vlan id to 0 when the
vlan_get_tagreturn error.Fixes d3ab3ffd1d7 (bonding: use rlb_client_info->vlan_id instead of ->tag)CC Ding Tianhong <[email protected]>CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Ding Tianhong <[email protected]>
Quoted 22 lines
---
drivers/net/bonding/bond_alb.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/bonding/bond_alb.c +1
-1@@ -730,7 +730,7 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon client_info->ntt =0 ; } -if (!vlan_get_tag (skb, &client_info->vlan_id)) +if (vlan_get_tag (skb, &client_info->vlan_id)) client_info->vlan_id =0 ;if (!client_info->assigned) {Signature · 1 line
1.8.0
From: Ding Tianhong <[email protected]>
Date: Wed, 12 Mar 2014 17:31:59 +0800
Quoted 8 lines
The commit
d3ab3ffd1d728d7ee77340e7e7e2c7cfe6a4013e(bonding: userlb_client_info->vlan_idinstead of ->tag) remove therlb_client_info->tag, but occur some issues, Thevlan_get_tag()will return 0 for success and-EINVALfor error, so theclient_info->vlan_idalways be set to 0 if thevlan_get_tagreturn 0 for success, so theclient_infowould never get a correct vlan id.
Quoted 8 lines
We should only set the vlan id to 0 when the
vlan_get_tagreturn error.Fixes d3ab3ffd1d7 (bonding: use rlb_client_info->vlan_id instead of ->tag)CC Ding Tianhong <[email protected]>CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Ding Tianhong <[email protected]>
Applied, thanks.