All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol
@ 2014-03-11  3:43 Ding Tianhong
  2014-03-11  3:43 ` [PATCH net-next 1/3] vlan: make a new function vlan_dev_vlan_proto() and export Ding Tianhong
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ding Tianhong @ 2014-03-11  3:43 UTC (permalink / raw)
  To: fubar, vfalico, andy, kaber; +Cc: davem, netdev

The bonding could only use vlan proto 802.1q regardless the vlan dev is
802.1ad or 802.1q, so add new interface to get vlan proto by vlan dev and
use it to send packages by correct vlan protocol.

Ding Tianhong (3):
  vlan: make a new function  vlan_dev_vlan_proto() and export
  bonding: support different vlan proto for bond_arp_send()
  bonding: choose the correct vlan proto for alb_send_learning_packets

 drivers/net/bonding/bond_alb.c  |  7 ++++---
 drivers/net/bonding/bond_main.c | 23 +++++++++++++++--------
 include/linux/if_vlan.h         |  7 +++++++
 net/8021q/vlan_core.c           |  6 ++++++
 4 files changed, 32 insertions(+), 11 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] vlan: make a new function  vlan_dev_vlan_proto() and export
  2014-03-11  3:43 [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Ding Tianhong
@ 2014-03-11  3:43 ` Ding Tianhong
  2014-03-11  3:43 ` [PATCH net-next 2/3] bonding: support different vlan proto for bond_arp_send() Ding Tianhong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ding Tianhong @ 2014-03-11  3:43 UTC (permalink / raw)
  To: fubar, vfalico, andy, kaber; +Cc: davem, netdev

The vlan support 2 proto: 802.1q and 802.1ad, so make a new function
called vlan_dev_vlan_proto() which could return the vlan proto for
input dev.

Cc: Patrick McHardy <kaber@trash.net>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 include/linux/if_vlan.h | 7 +++++++
 net/8021q/vlan_core.c   | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index bbedfb5..967a428 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -110,6 +110,7 @@ extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
 					       __be16 vlan_proto, u16 vlan_id);
 extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
 extern u16 vlan_dev_vlan_id(const struct net_device *dev);
+extern __be16 vlan_dev_vlan_proto(const struct net_device *dev);
 
 /**
  *	struct vlan_priority_tci_mapping - vlan egress priority mappings
@@ -216,6 +217,12 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
 	return 0;
 }
 
+static inline __be16 vlan_dev_vlan_proto(const struct net_device *dev)
+{
+	BUG();
+	return 0;
+}
+
 static inline u16 vlan_dev_get_egress_qos_mask(struct net_device *dev,
 					       u32 skprio)
 {
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 35b3c19..3c32bd2 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -106,6 +106,12 @@ u16 vlan_dev_vlan_id(const struct net_device *dev)
 }
 EXPORT_SYMBOL(vlan_dev_vlan_id);
 
+__be16 vlan_dev_vlan_proto(const struct net_device *dev)
+{
+	return vlan_dev_priv(dev)->vlan_proto;
+}
+EXPORT_SYMBOL(vlan_dev_vlan_proto);
+
 static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
 {
 	if (skb_cow(skb, skb_headroom(skb)) < 0)
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] bonding: support different vlan proto for bond_arp_send()
  2014-03-11  3:43 [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Ding Tianhong
  2014-03-11  3:43 ` [PATCH net-next 1/3] vlan: make a new function vlan_dev_vlan_proto() and export Ding Tianhong
@ 2014-03-11  3:43 ` Ding Tianhong
  2014-03-11  3:43 ` [PATCH net-next 3/3] bonding: choose the correct vlan proto for alb_send_learning_packets Ding Tianhong
  2014-03-12  6:13 ` [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Veaceslav Falico
  3 siblings, 0 replies; 6+ messages in thread
From: Ding Tianhong @ 2014-03-11  3:43 UTC (permalink / raw)
  To: fubar, vfalico, andy, kaber; +Cc: davem, netdev

The vlan support 2 proto: 802.1q and 802.1ad, but the bonding dev always
send ARP frames by proto 802.1q regardless the vlan dev is 802.1q or 802.1ad,
so make the bond dev support to send ARP according its real vlan proto.

Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_main.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 324389b..1494d8e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2124,12 +2124,15 @@ static bool bond_has_this_ip(struct bonding *bond, __be32 ip)
  * switches in VLAN mode (especially if ports are configured as
  * "native" to a VLAN) might not pass non-tagged frames.
  */
-static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_ip, __be32 src_ip, unsigned short vlan_id)
+static void bond_arp_send(struct net_device *slave_dev, int arp_op,
+			  __be32 dest_ip, __be32 src_ip,
+			  __be16 vlan_proto, unsigned short vlan_id)
 {
 	struct sk_buff *skb;
 
-	pr_debug("arp %d on slave %s: dst %pI4 src %pI4 vid %d\n",
-		 arp_op, slave_dev->name, &dest_ip, &src_ip, vlan_id);
+	pr_debug("arp %d on slave %s: dst %pI4 src %pI4 proto %x vid %d\n",
+		 arp_op, slave_dev->name, &dest_ip, &src_ip, vlan_proto,
+		 vlan_id);
 
 	skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip,
 			 NULL, slave_dev->dev_addr, NULL);
@@ -2139,7 +2142,7 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_
 		return;
 	}
 	if (vlan_id) {
-		skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_id);
+		skb = vlan_put_tag(skb, vlan_proto, vlan_id);
 		if (!skb) {
 			pr_err("failed to insert VLAN tag\n");
 			return;
@@ -2156,6 +2159,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 	struct rtable *rt;
 	__be32 *targets = bond->params.arp_targets, addr;
 	int i, vlan_id;
+	__be16 vlan_proto = 0;
 
 	for (i = 0; i < BOND_MAX_ARP_TARGETS && targets[i]; i++) {
 		pr_debug("basa: target %pI4\n", &targets[i]);
@@ -2170,7 +2174,8 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 			if (bond->params.arp_validate && net_ratelimit())
 				pr_warn("%s: no route to arp_ip_target %pI4 and arp_validate is set\n",
 					bond->dev->name, &targets[i]);
-			bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 0, 0);
+			bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
+				      0, 0, 0);
 			continue;
 		}
 
@@ -2196,6 +2201,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 							  iter) {
 				if (upper == rt->dst.dev) {
 					vlan_id = vlan_dev_vlan_id(vlan_upper);
+					vlan_proto = vlan_dev_vlan_id(vlan_upper);
 					rcu_read_unlock();
 					goto found;
 				}
@@ -2209,9 +2215,10 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 		netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) {
 			if (upper == rt->dst.dev) {
 				/* if it's a vlan - get its VID */
-				if (is_vlan_dev(upper))
+				if (is_vlan_dev(upper)) {
 					vlan_id = vlan_dev_vlan_id(upper);
-
+					vlan_proto = vlan_dev_vlan_proto(upper);
+				}
 				rcu_read_unlock();
 				goto found;
 			}
@@ -2230,7 +2237,7 @@ found:
 		addr = bond_confirm_addr(rt->dst.dev, targets[i], 0);
 		ip_rt_put(rt);
 		bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
-			      addr, vlan_id);
+			      addr, vlan_proto, vlan_id);
 	}
 }
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] bonding: choose the correct vlan proto for alb_send_learning_packets
  2014-03-11  3:43 [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Ding Tianhong
  2014-03-11  3:43 ` [PATCH net-next 1/3] vlan: make a new function vlan_dev_vlan_proto() and export Ding Tianhong
  2014-03-11  3:43 ` [PATCH net-next 2/3] bonding: support different vlan proto for bond_arp_send() Ding Tianhong
@ 2014-03-11  3:43 ` Ding Tianhong
  2014-03-12  6:13 ` [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Veaceslav Falico
  3 siblings, 0 replies; 6+ messages in thread
From: Ding Tianhong @ 2014-03-11  3:43 UTC (permalink / raw)
  To: fubar, vfalico, andy, kaber; +Cc: davem, netdev

The vlan support 2 proto: 802.1q and 802.1ad, but the
alb_send_learning_packets could only use proto 802.1q,
add support for 802.1ad

Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_alb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index aaeeacf..ef98bc8 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -995,7 +995,7 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
 /*********************** tlb/rlb shared functions *********************/
 
 static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
-			    u16 vid)
+			    __be16 proto, u16 vid)
 {
 	struct learning_pkt pkt;
 	struct sk_buff *skb;
@@ -1021,7 +1021,7 @@ static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
 	skb->dev = slave->dev;
 
 	if (vid) {
-		skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vid);
+		skb = vlan_put_tag(skb, proto, vid);
 		if (!skb) {
 			pr_err("%s: Error: failed to insert VLAN tag\n",
 			       slave->bond->dev->name);
@@ -1040,13 +1040,14 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
 	struct list_head *iter;
 
 	/* send untagged */
-	alb_send_lp_vid(slave, mac_addr, 0);
+	alb_send_lp_vid(slave, mac_addr, 0, 0);
 
 	/* loop through vlans and send one packet for each */
 	rcu_read_lock();
 	netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) {
 		if (upper->priv_flags & IFF_802_1Q_VLAN)
 			alb_send_lp_vid(slave, mac_addr,
+					vlan_dev_vlan_proto(upper),
 					vlan_dev_vlan_id(upper));
 	}
 	rcu_read_unlock();
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol
  2014-03-11  3:43 [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Ding Tianhong
                   ` (2 preceding siblings ...)
  2014-03-11  3:43 ` [PATCH net-next 3/3] bonding: choose the correct vlan proto for alb_send_learning_packets Ding Tianhong
@ 2014-03-12  6:13 ` Veaceslav Falico
  2014-03-12  8:57   ` Ding Tianhong
  3 siblings, 1 reply; 6+ messages in thread
From: Veaceslav Falico @ 2014-03-12  6:13 UTC (permalink / raw)
  To: Ding Tianhong; +Cc: fubar, andy, kaber, davem, netdev

On Tue, Mar 11, 2014 at 11:43:39AM +0800, Ding Tianhong wrote:
>The bonding could only use vlan proto 802.1q regardless the vlan dev is
>802.1ad or 802.1q, so add new interface to get vlan proto by vlan dev and
>use it to send packages by correct vlan protocol.

It's not that easy. 802.1ad packets should be double-tagged, however you're
just changing the protocol (from 1q to 1ad) and tagging just once.

Have you actually tested this patchset, does it produce correct QinQ
packets?

>
>Ding Tianhong (3):
>  vlan: make a new function  vlan_dev_vlan_proto() and export
>  bonding: support different vlan proto for bond_arp_send()
>  bonding: choose the correct vlan proto for alb_send_learning_packets
>
> drivers/net/bonding/bond_alb.c  |  7 ++++---
> drivers/net/bonding/bond_main.c | 23 +++++++++++++++--------
> include/linux/if_vlan.h         |  7 +++++++
> net/8021q/vlan_core.c           |  6 ++++++
> 4 files changed, 32 insertions(+), 11 deletions(-)
>
>-- 
>1.8.0
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol
  2014-03-12  6:13 ` [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Veaceslav Falico
@ 2014-03-12  8:57   ` Ding Tianhong
  0 siblings, 0 replies; 6+ messages in thread
From: Ding Tianhong @ 2014-03-12  8:57 UTC (permalink / raw)
  To: Veaceslav Falico; +Cc: fubar, andy, kaber, davem, netdev

On 2014/3/12 14:13, Veaceslav Falico wrote:
> On Tue, Mar 11, 2014 at 11:43:39AM +0800, Ding Tianhong wrote:
>> The bonding could only use vlan proto 802.1q regardless the vlan dev is
>> 802.1ad or 802.1q, so add new interface to get vlan proto by vlan dev and
>> use it to send packages by correct vlan protocol.
> 
> It's not that easy. 802.1ad packets should be double-tagged, however you're
> just changing the protocol (from 1q to 1ad) and tagging just once.
> 
> Have you actually tested this patchset, does it produce correct QinQ
> packets?
> 

I will add test log and resend, thanks

Ding

>>
>> Ding Tianhong (3):
>>  vlan: make a new function  vlan_dev_vlan_proto() and export
>>  bonding: support different vlan proto for bond_arp_send()
>>  bonding: choose the correct vlan proto for alb_send_learning_packets
>>
>> drivers/net/bonding/bond_alb.c  |  7 ++++---
>> drivers/net/bonding/bond_main.c | 23 +++++++++++++++--------
>> include/linux/if_vlan.h         |  7 +++++++
>> net/8021q/vlan_core.c           |  6 ++++++
>> 4 files changed, 32 insertions(+), 11 deletions(-)
>>
>> -- 
>> 1.8.0
>>
>>
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-12  8:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11  3:43 [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Ding Tianhong
2014-03-11  3:43 ` [PATCH net-next 1/3] vlan: make a new function vlan_dev_vlan_proto() and export Ding Tianhong
2014-03-11  3:43 ` [PATCH net-next 2/3] bonding: support different vlan proto for bond_arp_send() Ding Tianhong
2014-03-11  3:43 ` [PATCH net-next 3/3] bonding: choose the correct vlan proto for alb_send_learning_packets Ding Tianhong
2014-03-12  6:13 ` [PATCH net-next 0/3] bonding: support 802.1ad vlan protocol Veaceslav Falico
2014-03-12  8:57   ` Ding Tianhong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.