* [PATCHv2 0/8] vxlan: bug fixes
@ 2012-10-10 6:35 Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 1/8] vxlan: minor output refactoring Stephen Hemminger
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
Revision to earlier patch set for vxlan, includes a couple
more issues.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 1/8] vxlan: minor output refactoring
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 2/8] vxlan: fix byte order in hash function Stephen Hemminger
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-dst.patch --]
[-- Type: text/plain, Size: 1781 bytes --]
Move code to find destination to a small function.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
v2 - breakup compound if()
--- a/drivers/net/vxlan.c 2012-10-09 18:08:28.594496129 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:31.722465071 -0700
@@ -621,6 +621,22 @@ static inline u8 vxlan_ecn_encap(u8 tos,
return INET_ECN_encapsulate(tos, inner);
}
+static __be32 vxlan_find_dst(struct vxlan_dev *vxlan, struct sk_buff *skb)
+{
+ const struct ethhdr *eth = (struct ethhdr *) skb->data;
+ const struct vxlan_fdb *f;
+
+ if (is_multicast_ether_addr(eth->h_dest))
+ return vxlan->gaddr;
+
+ f = vxlan_find_mac(vxlan, eth->h_dest);
+ if (f)
+ return f->remote_ip;
+ else
+ return vxlan->gaddr;
+
+}
+
/* Transmit local packets over Vxlan
*
* Outer IP header inherits ECN and DF from inner header.
@@ -632,13 +648,11 @@ static netdev_tx_t vxlan_xmit(struct sk_
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct rtable *rt;
- const struct ethhdr *eth;
const struct iphdr *old_iph;
struct iphdr *iph;
struct vxlanhdr *vxh;
struct udphdr *uh;
struct flowi4 fl4;
- struct vxlan_fdb *f;
unsigned int pkt_len = skb->len;
u32 hash;
__be32 dst;
@@ -646,21 +660,16 @@ static netdev_tx_t vxlan_xmit(struct sk_
__u8 tos, ttl;
int err;
+ dst = vxlan_find_dst(vxlan, skb);
+ if (!dst)
+ goto drop;
+
/* Need space for new headers (invalidates iph ptr) */
if (skb_cow_head(skb, VXLAN_HEADROOM))
goto drop;
- eth = (void *)skb->data;
old_iph = ip_hdr(skb);
- if (!is_multicast_ether_addr(eth->h_dest) &&
- (f = vxlan_find_mac(vxlan, eth->h_dest)))
- dst = f->remote_ip;
- else if (vxlan->gaddr) {
- dst = vxlan->gaddr;
- } else
- goto drop;
-
ttl = vxlan->ttl;
if (!ttl && IN_MULTICAST(ntohl(dst)))
ttl = 1;
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 2/8] vxlan: fix byte order in hash function
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 1/8] vxlan: minor output refactoring Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 3/8] vxlan: use ip_route_output Stephen Hemminger
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-byte-order.patch --]
[-- Type: text/plain, Size: 518 bytes --]
Shift was wrong direction causing packets to hash based on
other parts of the ethernet header, not the address.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/vxlan.c 2012-10-09 18:08:31.722465071 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:32.630456072 -0700
@@ -228,9 +228,9 @@ static u32 eth_hash(const unsigned char
/* only want 6 bytes */
#ifdef __BIG_ENDIAN
- value <<= 16;
-#else
value >>= 16;
+#else
+ value <<= 16;
#endif
return hash_64(value, FDB_HASH_BITS);
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 3/8] vxlan: use ip_route_output
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 1/8] vxlan: minor output refactoring Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 2/8] vxlan: fix byte order in hash function Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 4/8] vxlan: associate with tunnel socket on transmit Stephen Hemminger
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-route-output.patch --]
[-- Type: text/plain, Size: 1120 bytes --]
Select source address for VXLAN packet based on route destination
and don't lie to route code. VXLAN is not GRE.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
v2 - zero flow structure
--- a/drivers/net/vxlan.c 2012-10-09 18:08:32.630456072 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:33.466447793 -0700
@@ -680,9 +680,13 @@ static netdev_tx_t vxlan_xmit(struct sk_
hash = skb_get_rxhash(skb);
- rt = ip_route_output_gre(dev_net(dev), &fl4, dst,
- vxlan->saddr, vxlan->vni,
- RT_TOS(tos), vxlan->link);
+ memset(&fl4, 0, sizeof(fl4));
+ fl4.flowi4_oif = vxlan->link;
+ fl4.flowi4_tos = RT_TOS(tos);
+ fl4.daddr = dst;
+ fl4.saddr = vxlan->saddr;
+
+ rt = ip_route_output_key(dev_net(dev), &fl4);
if (IS_ERR(rt)) {
netdev_dbg(dev, "no route to %pI4\n", &dst);
dev->stats.tx_carrier_errors++;
@@ -724,7 +728,7 @@ static netdev_tx_t vxlan_xmit(struct sk_
iph->frag_off = df;
iph->protocol = IPPROTO_UDP;
iph->tos = vxlan_ecn_encap(tos, old_iph, skb);
- iph->daddr = fl4.daddr;
+ iph->daddr = dst;
iph->saddr = fl4.saddr;
iph->ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 4/8] vxlan: associate with tunnel socket on transmit
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
` (2 preceding siblings ...)
2012-10-10 6:35 ` [PATCHv2 3/8] vxlan: use ip_route_output Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 5/8] vxlan: allow configuring port range Stephen Hemminger
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-owner.patch --]
[-- Type: text/plain, Size: 1192 bytes --]
When tunnelling a skb, associate it with the tunnel socket.
This allows parameters set on tunnel socket (like multicast loop
flag), to be picked up by ip_output.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/vxlan.c 2012-10-09 18:08:33.466447793 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:34.066441861 -0700
@@ -637,6 +637,23 @@ static __be32 vxlan_find_dst(struct vxla
}
+static void vxlan_sock_free(struct sk_buff *skb)
+{
+ sock_put(skb->sk);
+}
+
+/* On transmit, associate with the tunnel socket */
+static void vxlan_set_owner(struct net_device *dev, struct sk_buff *skb)
+{
+ struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
+ struct sock *sk = vn->sock->sk;
+
+ skb_orphan(skb);
+ sock_hold(sk);
+ skb->sk = sk;
+ skb->destructor = vxlan_sock_free;
+}
+
/* Transmit local packets over Vxlan
*
* Outer IP header inherits ECN and DF from inner header.
@@ -732,6 +749,8 @@ static netdev_tx_t vxlan_xmit(struct sk_
iph->saddr = fl4.saddr;
iph->ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
+ vxlan_set_owner(dev, skb);
+
/* See __IPTUNNEL_XMIT */
skb->ip_summed = CHECKSUM_NONE;
ip_select_ident(iph, &rt->dst, NULL);
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 5/8] vxlan: allow configuring port range
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
` (3 preceding siblings ...)
2012-10-10 6:35 ` [PATCHv2 4/8] vxlan: associate with tunnel socket on transmit Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:41 ` [PATCH] iproute2: allow configuring vxlan " Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 6/8] vxlan: add additional headroom Stephen Hemminger
` (3 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-port-range.patch --]
[-- Type: text/plain, Size: 5917 bytes --]
VXLAN bases source UDP port based on flow to help the
receiver to be able to load balance based on outer header flow.
This patch restricts the port range to the normal UDP local
ports, and allows overriding via configuration.
It also uses jhash of Ethernet header when looking at flows
with out know L3 header.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
v2 - min/max are non-inclusive so allow min == max
drivers/net/vxlan.c | 62 ++++++++++++++++++++++++++++++++++++++++++++----
include/linux/if_link.h | 6 ++++
2 files changed, 63 insertions(+), 5 deletions(-)
--- a/drivers/net/vxlan.c 2012-10-09 18:08:34.066441861 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:35.086431755 -0700
@@ -106,6 +106,8 @@ struct vxlan_dev {
__be32 gaddr; /* multicast group */
__be32 saddr; /* source address */
unsigned int link; /* link to multicast over */
+ __u16 port_min; /* source port range */
+ __u16 port_max;
__u8 tos; /* TOS override */
__u8 ttl;
bool learn;
@@ -654,12 +656,29 @@ static void vxlan_set_owner(struct net_d
skb->destructor = vxlan_sock_free;
}
+/* Compute source port for outgoing packet
+ * first choice to use L4 flow hash since it will spread
+ * better and maybe available from hardware
+ * secondary choice is to use jhash on the Ethernet header
+ */
+static u16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb)
+{
+ unsigned int range = (vxlan->port_max - vxlan->port_min) + 1;
+ u32 hash;
+
+ hash = skb_get_rxhash(skb);
+ if (!hash)
+ hash = jhash(skb->data, 2 * ETH_ALEN,
+ (__force u32) skb->protocol);
+
+ return (((u64) hash * range) >> 32) + vxlan->port_min;
+}
+
/* Transmit local packets over Vxlan
*
* Outer IP header inherits ECN and DF from inner header.
* Outer UDP destination is the VXLAN assigned port.
- * source port is based on hash of flow if available
- * otherwise use a random value
+ * source port is based on hash of flow
*/
static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
{
@@ -671,8 +690,8 @@ static netdev_tx_t vxlan_xmit(struct sk_
struct udphdr *uh;
struct flowi4 fl4;
unsigned int pkt_len = skb->len;
- u32 hash;
__be32 dst;
+ __u16 src_port;
__be16 df = 0;
__u8 tos, ttl;
int err;
@@ -695,7 +714,7 @@ static netdev_tx_t vxlan_xmit(struct sk_
if (tos == 1)
tos = vxlan_get_dsfield(old_iph, skb);
- hash = skb_get_rxhash(skb);
+ src_port = vxlan_src_port(vxlan, skb);
memset(&fl4, 0, sizeof(fl4));
fl4.flowi4_oif = vxlan->link;
@@ -732,7 +751,7 @@ static netdev_tx_t vxlan_xmit(struct sk_
uh = udp_hdr(skb);
uh->dest = htons(vxlan_port);
- uh->source = hash ? :random32();
+ uh->source = htons(src_port);
uh->len = htons(skb->len);
uh->check = 0;
@@ -960,6 +979,7 @@ static void vxlan_setup(struct net_devic
{
struct vxlan_dev *vxlan = netdev_priv(dev);
unsigned h;
+ int low, high;
eth_hw_addr_random(dev);
ether_setup(dev);
@@ -979,6 +999,10 @@ static void vxlan_setup(struct net_devic
vxlan->age_timer.function = vxlan_cleanup;
vxlan->age_timer.data = (unsigned long) vxlan;
+ inet_get_local_port_range(&low, &high);
+ vxlan->port_min = low;
+ vxlan->port_max = high;
+
vxlan->dev = dev;
for (h = 0; h < FDB_HASH_SIZE; ++h)
@@ -995,6 +1019,7 @@ static const struct nla_policy vxlan_pol
[IFLA_VXLAN_LEARNING] = { .type = NLA_U8 },
[IFLA_VXLAN_AGEING] = { .type = NLA_U32 },
[IFLA_VXLAN_LIMIT] = { .type = NLA_U32 },
+ [IFLA_VXLAN_PORT_RANGE] = { .len = sizeof(struct ifla_vxlan_port_range) },
};
static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -1027,6 +1052,18 @@ static int vxlan_validate(struct nlattr
return -EADDRNOTAVAIL;
}
}
+
+ if (data[IFLA_VXLAN_PORT_RANGE]) {
+ const struct ifla_vxlan_port_range *p
+ = nla_data(data[IFLA_VXLAN_PORT_RANGE]);
+
+ if (ntohs(p->high) < ntohs(p->low)) {
+ pr_debug("port range %u .. %u not valid\n",
+ ntohs(p->low), ntohs(p->high));
+ return -EINVAL;
+ }
+ }
+
return 0;
}
@@ -1077,6 +1114,13 @@ static int vxlan_newlink(struct net *net
if (data[IFLA_VXLAN_LIMIT])
vxlan->addrmax = nla_get_u32(data[IFLA_VXLAN_LIMIT]);
+ if (data[IFLA_VXLAN_PORT_RANGE]) {
+ const struct ifla_vxlan_port_range *p
+ = nla_data(data[IFLA_VXLAN_PORT_RANGE]);
+ vxlan->port_min = ntohs(p->low);
+ vxlan->port_max = ntohs(p->high);
+ }
+
err = register_netdevice(dev);
if (!err)
hlist_add_head_rcu(&vxlan->hlist, vni_head(net, vxlan->vni));
@@ -1105,12 +1149,17 @@ static size_t vxlan_get_size(const struc
nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_LEARNING */
nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_AGEING */
nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_LIMIT */
+ nla_total_size(sizeof(struct ifla_vxlan_port_range)) +
0;
}
static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
{
const struct vxlan_dev *vxlan = netdev_priv(dev);
+ struct ifla_vxlan_port_range ports = {
+ .low = htons(vxlan->port_min),
+ .high = htons(vxlan->port_max),
+ };
if (nla_put_u32(skb, IFLA_VXLAN_ID, vxlan->vni))
goto nla_put_failure;
@@ -1131,6 +1180,9 @@ static int vxlan_fill_info(struct sk_buf
nla_put_u32(skb, IFLA_VXLAN_LIMIT, vxlan->addrmax))
goto nla_put_failure;
+ if (nla_put(skb, IFLA_VXLAN_PORT_RANGE, sizeof(ports), &ports))
+ goto nla_put_failure;
+
return 0;
nla_put_failure:
--- a/include/linux/if_link.h 2012-10-09 18:08:22.126560329 -0700
+++ b/include/linux/if_link.h 2012-10-09 18:08:35.086431755 -0700
@@ -284,10 +284,16 @@ enum {
IFLA_VXLAN_LEARNING,
IFLA_VXLAN_AGEING,
IFLA_VXLAN_LIMIT,
+ IFLA_VXLAN_PORT_RANGE,
__IFLA_VXLAN_MAX
};
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
+struct ifla_vxlan_port_range {
+ __be16 low;
+ __be16 high;
+};
+
/* SR-IOV virtual function management section */
enum {
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 6/8] vxlan: add additional headroom
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
` (4 preceding siblings ...)
2012-10-10 6:35 ` [PATCHv2 5/8] vxlan: allow configuring port range Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 7/8] vxlan: fix receive checksum handling Stephen Hemminger
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-more-headroom.patch --]
[-- Type: text/plain, Size: 543 bytes --]
Tell upper layer protocols to allocate skb with additional headroom.
This avoids allocation and copy in local packet sends.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/vxlan.c 2012-10-09 18:08:35.086431755 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:36.862414133 -0700
@@ -983,6 +983,7 @@ static void vxlan_setup(struct net_devic
eth_hw_addr_random(dev);
ether_setup(dev);
+ dev->hard_header_len = ETH_HLEN + VXLAN_HEADROOM;
dev->netdev_ops = &vxlan_netdev_ops;
dev->destructor = vxlan_free;
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 7/8] vxlan: fix receive checksum handling
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
` (5 preceding siblings ...)
2012-10-10 6:35 ` [PATCHv2 6/8] vxlan: add additional headroom Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 8/8] vxlan: fix oops when give unknown ifindex Stephen Hemminger
2012-10-11 2:42 ` [PATCHv2 0/8] vxlan: bug fixes David Miller
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-checksum.patch --]
[-- Type: text/plain, Size: 1189 bytes --]
Vxlan was trying to use postpull_rcsum to allow receive checksum
offload to work on drivers using CHECKSUM_COMPLETE method. But this
doesn't work correctly. Just force full receive checksum on received
packet.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/vxlan.c 2012-10-09 18:08:36.862414133 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 18:08:38.686396042 -0700
@@ -537,7 +537,6 @@ static int vxlan_udp_encap_recv(struct s
}
__skb_pull(skb, sizeof(struct vxlanhdr));
- skb_postpull_rcsum(skb, eth_hdr(skb), sizeof(struct vxlanhdr));
/* Is this VNI defined? */
vni = ntohl(vxh->vx_vni) >> 8;
@@ -556,7 +555,6 @@ static int vxlan_udp_encap_recv(struct s
/* Re-examine inner Ethernet packet */
oip = ip_hdr(skb);
skb->protocol = eth_type_trans(skb, vxlan->dev);
- skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
/* Ignore packet loops (and multicast echo) */
if (compare_ether_addr(eth_hdr(skb)->h_source,
@@ -568,6 +566,7 @@ static int vxlan_udp_encap_recv(struct s
__skb_tunnel_rx(skb, vxlan->dev);
skb_reset_network_header(skb);
+ skb->ip_summed = CHECKSUM_NONE;
err = IP_ECN_decapsulate(oip, skb);
if (unlikely(err)) {
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 8/8] vxlan: fix oops when give unknown ifindex
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
` (6 preceding siblings ...)
2012-10-10 6:35 ` [PATCHv2 7/8] vxlan: fix receive checksum handling Stephen Hemminger
@ 2012-10-10 6:35 ` Stephen Hemminger
2012-10-11 2:42 ` [PATCHv2 0/8] vxlan: bug fixes David Miller
8 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:35 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: vxlan-baddev.patch --]
[-- Type: text/plain, Size: 1163 bytes --]
If vxlan is created and the ifindex is passed; there are two cases which
are incorrectly handled by the existing code. The ifindex could be zero
(i.e. no device) or there could be no device with that ifindex.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/vxlan.c 2012-10-09 22:07:41.417308505 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 22:09:56.715949703 -0700
@@ -1090,14 +1090,18 @@ static int vxlan_newlink(struct net *net
if (data[IFLA_VXLAN_LOCAL])
vxlan->saddr = nla_get_be32(data[IFLA_VXLAN_LOCAL]);
- if (data[IFLA_VXLAN_LINK]) {
- vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]);
+ if (data[IFLA_VXLAN_LINK] &&
+ (vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]))) {
+ struct net_device *lowerdev
+ = __dev_get_by_index(net, vxlan->link);
- if (!tb[IFLA_MTU]) {
- struct net_device *lowerdev;
- lowerdev = __dev_get_by_index(net, vxlan->link);
- dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
+ if (!lowerdev) {
+ pr_info("ifindex %d does not exist\n", vxlan->link);
+ return -ENODEV;
}
+
+ if (!tb[IFLA_MTU])
+ dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
}
if (data[IFLA_VXLAN_TOS])
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] iproute2: allow configuring vxlan port range
2012-10-10 6:35 ` [PATCHv2 5/8] vxlan: allow configuring port range Stephen Hemminger
@ 2012-10-10 6:41 ` Stephen Hemminger
0 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-10 6:41 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev
New options to ip link to allow setting vxlan port range.
Also, don't print everything that is defaulted when showing device.
---
include/linux/if_link.h | 6 ++++++
ip/iplink_vxlan.c | 51 ++++++++++++++++++++++++++++++++---------------
2 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 1cf79fa..563e8fb 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -282,10 +282,16 @@ enum {
IFLA_VXLAN_LEARNING,
IFLA_VXLAN_AGEING,
IFLA_VXLAN_LIMIT,
+ IFLA_VXLAN_PORT_RANGE,
__IFLA_VXLAN_MAX
};
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
+struct ifla_vxlan_port_range {
+ __be16 low;
+ __be16 high;
+};
+
/* SR-IOV virtual function management section */
enum {
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index f52eb18..7957781 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -24,7 +24,8 @@
static void explain(void)
{
fprintf(stderr, "Usage: ... vxlan id VNI [ group ADDR ] [ local ADDR ]\n");
- fprintf(stderr, " [ ttl TTL ] [ tos TOS ] [ [no]learning ] [ dev PHYS_DEV ]\n");
+ fprintf(stderr, " [ ttl TTL ] [ tos TOS ] [ dev PHYS_DEV ]\n");
+ fprintf(stderr, " [ port MIN MAX ] [ [no]learning ]\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where: VNI := 0-16777215\n");
fprintf(stderr, " ADDR := { IP_ADDRESS | any }\n");
@@ -46,6 +47,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
__u8 noage = 0;
__u32 age = 0;
__u32 maxaddr = 0;
+ struct ifla_vxlan_port_range range = { 0, 0 };
while (argc > 0) {
if (!matches(*argv, "id") ||
@@ -79,9 +81,9 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
NEXT_ARG();
if (strcmp(*argv, "inherit") != 0) {
if (get_unsigned(&uval, *argv, 0))
- invarg("invalid TTL\n", *argv);
+ invarg("invalid TTL", *argv);
if (uval > 255)
- invarg("TTL must be <= 255\n", *argv);
+ invarg("TTL must be <= 255", *argv);
ttl = uval;
}
} else if (!matches(*argv, "tos") ||
@@ -100,13 +102,23 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
if (strcmp(*argv, "none") == 0)
noage = 1;
else if (get_u32(&age, *argv, 0))
- invarg("ageing timer\n", *argv);
+ invarg("ageing timer", *argv);
} else if (!matches(*argv, "maxaddress")) {
NEXT_ARG();
if (strcmp(*argv, "unlimited") == 0)
maxaddr = 0;
else if (get_u32(&maxaddr, *argv, 0))
- invarg("max addresses\n", *argv);
+ invarg("max addresses", *argv);
+ } else if (!matches(*argv, "port")) {
+ __u16 minport, maxport;
+ NEXT_ARG();
+ if (get_u16(&minport, *argv, 0))
+ invarg("min port", *argv);
+ NEXT_ARG();
+ if (get_u16(&maxport, *argv, 0))
+ invarg("max port", *argv);
+ range.low = htons(minport);
+ range.high = htons(maxport);
} else if (!matches(*argv, "nolearning")) {
learning = 0;
} else if (!matches(*argv, "learning")) {
@@ -140,6 +152,9 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
addattr32(n, 1024, IFLA_VXLAN_AGEING, age);
if (maxaddr)
addattr32(n, 1024, IFLA_VXLAN_LIMIT, maxaddr);
+ if (range.low || range.high)
+ addattr_l(n, 1024, IFLA_VXLAN_PORT_RANGE,
+ &range, sizeof(range));
return 0;
}
@@ -148,6 +163,8 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
__u32 vni;
unsigned link;
+ __u8 tos;
+ __u32 maxaddr;
char s1[1024];
char s2[64];
@@ -187,13 +204,18 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
fprintf(f, "dev %u ", link);
}
+ if (tb[IFLA_VXLAN_PORT_RANGE]) {
+ const struct ifla_vxlan_port_range *r
+ = RTA_DATA(tb[IFLA_VXLAN_PORT_RANGE]);
+ fprintf(f, "port %u %u ", ntohs(r->low), ntohs(r->high));
+ }
+
if (tb[IFLA_VXLAN_LEARNING] &&
!rta_getattr_u8(tb[IFLA_VXLAN_LEARNING]))
fputs("nolearning ", f);
-
- if (tb[IFLA_VXLAN_TOS]) {
- __u8 tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
-
+
+ if (tb[IFLA_VXLAN_TOS] &&
+ (tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]))) {
if (tos == 1)
fprintf(f, "tos inherit ");
else
@@ -213,13 +235,10 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
else
fprintf(f, "ageing %u ", age);
}
- if (tb[IFLA_VXLAN_LIMIT]) {
- __u32 maxaddr = rta_getattr_u32(tb[IFLA_VXLAN_LIMIT]);
- if (maxaddr == 0)
- fprintf(f, "maxaddr unlimited ");
- else
- fprintf(f, "maxaddr %u ", maxaddr);
- }
+
+ if (tb[IFLA_VXLAN_LIMIT] &&
+ (maxaddr = rta_getattr_u32(tb[IFLA_VXLAN_LIMIT]) != 0))
+ fprintf(f, "maxaddr %u ", maxaddr);
}
struct link_util vxlan_link_util = {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 0/8] vxlan: bug fixes
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
` (7 preceding siblings ...)
2012-10-10 6:35 ` [PATCHv2 8/8] vxlan: fix oops when give unknown ifindex Stephen Hemminger
@ 2012-10-11 2:42 ` David Miller
2012-10-11 14:59 ` Stephen Hemminger
8 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2012-10-11 2:42 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Tue, 09 Oct 2012 23:35:45 -0700
> Revision to earlier patch set for vxlan, includes a couple
> more issues.
Applied, but that checksum issue is extremely unfortunate.
Why does postpull rcsum work for GRE but not VXLAN?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 0/8] vxlan: bug fixes
2012-10-11 2:42 ` [PATCHv2 0/8] vxlan: bug fixes David Miller
@ 2012-10-11 14:59 ` Stephen Hemminger
0 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2012-10-11 14:59 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Wed, 10 Oct 2012 22:42:20 -0400 (EDT)
David Miller <davem@davemloft.net> wrote:
> From: Stephen Hemminger <shemminger@vyatta.com>
> Date: Tue, 09 Oct 2012 23:35:45 -0700
>
> > Revision to earlier patch set for vxlan, includes a couple
> > more issues.
>
> Applied, but that checksum issue is extremely unfortunate.
>
> Why does postpull rcsum work for GRE but not VXLAN?
Not sure, plan to investigate getting rx checksum offload
working and possibly tx checksum (using checksum start).
Part of the problem with Tx checksum is too many drivers are
looking directly at skb_network_header() and skb_transport_header()
when they should be using skb_checksum_start().
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-10-11 14:59 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 1/8] vxlan: minor output refactoring Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 2/8] vxlan: fix byte order in hash function Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 3/8] vxlan: use ip_route_output Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 4/8] vxlan: associate with tunnel socket on transmit Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 5/8] vxlan: allow configuring port range Stephen Hemminger
2012-10-10 6:41 ` [PATCH] iproute2: allow configuring vxlan " Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 6/8] vxlan: add additional headroom Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 7/8] vxlan: fix receive checksum handling Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 8/8] vxlan: fix oops when give unknown ifindex Stephen Hemminger
2012-10-11 2:42 ` [PATCHv2 0/8] vxlan: bug fixes David Miller
2012-10-11 14:59 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).