Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'bonding-next'

Ding Tianhong says:

====================
bonding: support QinQ for bond arp interval

v1->v2: remvoe the comment "TODO: QinQ?".
convert pr_xxx() to pr_xxx_ratelimited() for arp interval.

v2->v3: remove the unnecessary log for arp interval and add net ratelimit to
avoid spam log.

v3->v4: Add ratelimit for debugging is not a good idea, it will miss some message
if the user turns the debugging on, so don't add ratelimited on debugging.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+69 -22
+51 -22
drivers/net/bonding/bond_main.c
··· 2124 2124 * switches in VLAN mode (especially if ports are configured as 2125 2125 * "native" to a VLAN) might not pass non-tagged frames. 2126 2126 */ 2127 - static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_ip, __be32 src_ip, unsigned short vlan_id) 2127 + static void bond_arp_send(struct net_device *slave_dev, int arp_op, 2128 + __be32 dest_ip, __be32 src_ip, 2129 + struct bond_vlan_tag *inner, 2130 + struct bond_vlan_tag *outer) 2128 2131 { 2129 2132 struct sk_buff *skb; 2130 2133 2131 - pr_debug("arp %d on slave %s: dst %pI4 src %pI4 vid %d\n", 2132 - arp_op, slave_dev->name, &dest_ip, &src_ip, vlan_id); 2134 + pr_debug("arp %d on slave %s: dst %pI4 src %pI4\n", 2135 + arp_op, slave_dev->name, &dest_ip, &src_ip); 2133 2136 2134 2137 skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip, 2135 2138 NULL, slave_dev->dev_addr, NULL); 2136 2139 2137 2140 if (!skb) { 2138 - pr_err("ARP packet allocation failed\n"); 2141 + net_err_ratelimited("ARP packet allocation failed\n"); 2139 2142 return; 2140 2143 } 2141 - if (vlan_id) { 2142 - skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_id); 2144 + if (outer->vlan_id) { 2145 + if (inner->vlan_id) { 2146 + pr_debug("inner tag: proto %X vid %X\n", 2147 + ntohs(inner->vlan_proto), inner->vlan_id); 2148 + skb = __vlan_put_tag(skb, inner->vlan_proto, 2149 + inner->vlan_id); 2150 + if (!skb) { 2151 + net_err_ratelimited("failed to insert inner VLAN tag\n"); 2152 + return; 2153 + } 2154 + } 2155 + 2156 + pr_debug("outer reg: proto %X vid %X\n", 2157 + ntohs(outer->vlan_proto), outer->vlan_id); 2158 + skb = vlan_put_tag(skb, outer->vlan_proto, outer->vlan_id); 2143 2159 if (!skb) { 2144 - pr_err("failed to insert VLAN tag\n"); 2160 + net_err_ratelimited("failed to insert outer VLAN tag\n"); 2145 2161 return; 2146 2162 } 2147 2163 } ··· 2170 2154 struct net_device *upper, *vlan_upper; 2171 2155 struct list_head *iter, *vlan_iter; 2172 2156 struct rtable *rt; 2157 + struct bond_vlan_tag inner, outer; 2173 2158 __be32 *targets = bond->params.arp_targets, addr; 2174 - int i, vlan_id; 2159 + int i; 2175 2160 2176 2161 for (i = 0; i < BOND_MAX_ARP_TARGETS && targets[i]; i++) { 2177 2162 pr_debug("basa: target %pI4\n", &targets[i]); 2163 + inner.vlan_proto = 0; 2164 + inner.vlan_id = 0; 2165 + outer.vlan_proto = 0; 2166 + outer.vlan_id = 0; 2178 2167 2179 2168 /* Find out through which dev should the packet go */ 2180 2169 rt = ip_route_output(dev_net(bond->dev), targets[i], 0, ··· 2188 2167 /* there's no route to target - try to send arp 2189 2168 * probe to generate any traffic (arp_validate=0) 2190 2169 */ 2191 - if (bond->params.arp_validate && net_ratelimit()) 2192 - pr_warn("%s: no route to arp_ip_target %pI4 and arp_validate is set\n", 2193 - bond->dev->name, &targets[i]); 2194 - bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 0, 0); 2170 + if (bond->params.arp_validate) 2171 + net_warn_ratelimited("%s: no route to arp_ip_target %pI4 and arp_validate is set\n", 2172 + bond->dev->name, 2173 + &targets[i]); 2174 + bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 0, &inner, &outer); 2195 2175 continue; 2196 2176 } 2197 - 2198 - vlan_id = 0; 2199 2177 2200 2178 /* bond device itself */ 2201 2179 if (rt->dst.dev == bond->dev) ··· 2205 2185 * found we verify its upper dev list, searching for the 2206 2186 * rt->dst.dev. If found we save the tag of the vlan and 2207 2187 * proceed to send the packet. 2208 - * 2209 - * TODO: QinQ? 2210 2188 */ 2211 2189 netdev_for_each_all_upper_dev_rcu(bond->dev, vlan_upper, 2212 2190 vlan_iter) { 2213 2191 if (!is_vlan_dev(vlan_upper)) 2214 2192 continue; 2193 + 2194 + if (vlan_upper == rt->dst.dev) { 2195 + outer.vlan_proto = vlan_dev_vlan_proto(vlan_upper); 2196 + outer.vlan_id = vlan_dev_vlan_id(vlan_upper); 2197 + rcu_read_unlock(); 2198 + goto found; 2199 + } 2215 2200 netdev_for_each_all_upper_dev_rcu(vlan_upper, upper, 2216 2201 iter) { 2217 2202 if (upper == rt->dst.dev) { 2218 - vlan_id = vlan_dev_vlan_id(vlan_upper); 2203 + /* If the upper dev is a vlan dev too, 2204 + * set the vlan tag to inner tag. 2205 + */ 2206 + if (is_vlan_dev(upper)) { 2207 + inner.vlan_proto = vlan_dev_vlan_proto(upper); 2208 + inner.vlan_id = vlan_dev_vlan_id(upper); 2209 + } 2210 + outer.vlan_proto = vlan_dev_vlan_proto(vlan_upper); 2211 + outer.vlan_id = vlan_dev_vlan_id(vlan_upper); 2219 2212 rcu_read_unlock(); 2220 2213 goto found; 2221 2214 } ··· 2241 2208 */ 2242 2209 netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) { 2243 2210 if (upper == rt->dst.dev) { 2244 - /* if it's a vlan - get its VID */ 2245 - if (is_vlan_dev(upper)) 2246 - vlan_id = vlan_dev_vlan_id(upper); 2247 - 2248 2211 rcu_read_unlock(); 2249 2212 goto found; 2250 2213 } ··· 2259 2230 addr = bond_confirm_addr(rt->dst.dev, targets[i], 0); 2260 2231 ip_rt_put(rt); 2261 2232 bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 2262 - addr, vlan_id); 2233 + addr, &inner, &outer); 2263 2234 } 2264 2235 } 2265 2236
+5
drivers/net/bonding/bonding.h
··· 266 266 #define bond_slave_get_rtnl(dev) \ 267 267 ((struct slave *) rtnl_dereference(dev->rx_handler_data)) 268 268 269 + struct bond_vlan_tag { 270 + __be16 vlan_proto; 271 + unsigned short vlan_id; 272 + }; 273 + 269 274 /** 270 275 * Returns NULL if the net_device does not belong to any of the bond's slaves 271 276 *
+7
include/linux/if_vlan.h
··· 110 110 __be16 vlan_proto, u16 vlan_id); 111 111 extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); 112 112 extern u16 vlan_dev_vlan_id(const struct net_device *dev); 113 + extern __be16 vlan_dev_vlan_proto(const struct net_device *dev); 113 114 114 115 /** 115 116 * struct vlan_priority_tci_mapping - vlan egress priority mappings ··· 212 211 } 213 212 214 213 static inline u16 vlan_dev_vlan_id(const struct net_device *dev) 214 + { 215 + BUG(); 216 + return 0; 217 + } 218 + 219 + static inline __be16 vlan_dev_vlan_proto(const struct net_device *dev) 215 220 { 216 221 BUG(); 217 222 return 0;
+6
net/8021q/vlan_core.c
··· 106 106 } 107 107 EXPORT_SYMBOL(vlan_dev_vlan_id); 108 108 109 + __be16 vlan_dev_vlan_proto(const struct net_device *dev) 110 + { 111 + return vlan_dev_priv(dev)->vlan_proto; 112 + } 113 + EXPORT_SYMBOL(vlan_dev_vlan_proto); 114 + 109 115 static struct sk_buff *vlan_reorder_header(struct sk_buff *skb) 110 116 { 111 117 if (skb_cow(skb, skb_headroom(skb)) < 0)