openvswitch: add IPv6 tunneling support
Subsystems (3)
v3 cover openvswitch: add IPv6 tunneling support
This builds on the previous work that added IPv6 support to lwtunnels and adds IPv6 tunneling support to ovs.
To use IPv6 tunneling, there needs to be a metadata based tunnel net_device created and added to the ovs bridge. Currently, only vxlan is supported by the kernel, with geneve to follow shortly. There's no need nor intent to add a support for this into the vport-vxlan (etc.) compat layer.
---
v3: dropped the last two patches added in v2.
Jiri Benc (2):
openvswitch: add tunnel protocol to sw_flow_key
openvswitch: netlink attributes for IPv6 tunneling
include/uapi/linux/openvswitch.h | 2 + net/openvswitch/flow.c | 4 +- net/openvswitch/flow.h | 1 + net/openvswitch/flow_netlink.c | 129 +++++++++++++++++++++++++++------------ net/openvswitch/flow_table.c | 2 +- 5 files changed, 97 insertions(+), 41 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/2 openvswitch: add tunnel protocol to sw_flow_key
Store tunnel protocol (AF_INET or AF_INET6) in sw_flow_key. This field now also acts as an indicator whether the flow contains tunnel data (this was previously indicated by tun_key.u.ipv4.dst being set but with IPv6 addresses in an union with IPv4 ones this won't work anymore).
The new field was added to a hole in sw_flow_key.
---
v2: Set the tun_proto mask to 0xff in ip_tun_from_nlattr.
v3: No change.
--- net/openvswitch/flow.c | 4 ++-- net/openvswitch/flow.h | 1 + net/openvswitch/flow_netlink.c | 10 ++++++++-- net/openvswitch/flow_table.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-)
net/openvswitch/flow.c +2 -2
@@ -698,8 +698,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, {/* Extract metadata from packet. */ if (tun_info) { -if (ip_tunnel_info_af (tun_info) !=AF_INET ) -return -EINVAL ; + key->tun_proto =ip_tunnel_info_af (tun_info);memcpy (&key->tun_key, &tun_info->key,sizeof (key->tun_key));if (tun_info->options_len) {
@@ -714,6 +713,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, key->tun_opts_len =0 ; } }else { + key->tun_proto =0 ; key->tun_opts_len =0 ;memset (&key->tun_key,0 ,sizeof (key->tun_key)); }
net/openvswitch/flow.h +1 -0
@@ -63,6 +63,7 @@ struct sw_flow_key {u32 skb_mark;/* SKB mark. */ u16 in_port;/* Input switch port (or DP_MAX_PORTS). */ }__packed phy;/* Safe when right after 'tun_key'. */ +u8 tun_proto;/* Protocol of encapsulating tunnel. */ u32 ovs_flow_hash;/* Datapath computed hash value. */ u32 recirc_id;/* Recirculation ID. */ struct {
net/openvswitch/flow_netlink.c +8 -2
@@ -643,6 +643,10 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr, }SW_FLOW_KEY_PUT (match, tun_key.tun_flags, tun_flags, is_mask); +if (is_mask) +SW_FLOW_KEY_MEMSET_FIELD (match, tun_proto,0xff , true); +else +SW_FLOW_KEY_PUT (match, tun_proto,AF_INET , false);if (rem >0 ) { OVS_NLERR(log, "IPv4 tunnel attribute has %d unknown bytes.",
@@ -1194,7 +1198,7 @@ int ovs_nla_get_match(struct net *net, struct sw_flow_match *match,/* The userspace does not send tunnel attributes that * are 0, but we should not wildcard them nonetheless. */ -if (match->key->tun_key.u.ipv4.dst) +if (match->key->tun_proto)SW_FLOW_KEY_MEMSET_FIELD (match, tun_key,0xff , true);
@@ -1367,7 +1371,7 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey,if (nla_put_u32 (skb,OVS_KEY_ATTR_PRIORITY , output->phy.priority)) goto nla_put_failure; -if ((swkey->tun_key.u.ipv4.dst || is_mask)) { +if ((swkey->tun_proto || is_mask)) {const void *opts =NULL ;if (output->tun_key.tun_flags &TUNNEL_OPTIONS_PRESENT )
@@ -1913,6 +1917,8 @@ static int validate_and_copy_set_tun(const struct nlattr *attr, tun_info = &tun_dst->u.tun_info; tun_info->mode =IP_TUNNEL_INFO_TX ; +if (key.tun_proto ==AF_INET6 ) + tun_info->mode |=IP_TUNNEL_INFO_IPV6 ; tun_info->key = key.tun_key;/* We need to store the options in the action itself since
net/openvswitch/flow_table.c +1 -1
@@ -427,7 +427,7 @@ static u32 flow_hash(const struct sw_flow_key *key,static int flow_key_start (const struct sw_flow_key *key) { -if (key->tun_key.u.ipv4.dst) +if (key->tun_proto)return 0 ;else return rounddown(offsetof(struct sw_flow_key, phy),
Signature · 1 line
1.8.3.1
A message that is not in the archive (sent off-list or not yet received): a8a99b9e11a824ca078f92f8e13aef5955b2a6d4.1444041801.git.jbenc-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Thomas Graf
Acked-byRe: [PATCH net-next v3 1/2] openvswitch: add tunnel protocol to sw_flow_key
Quoted 9 lines · Jiri Benc
Store tunnel protocol (
AF_INETorAF_INET6) insw_flow_key. This field now also acts as an indicator whether the flow contains tunnel data (this was previously indicated by tun_key.u.ipv4.dst being set but with IPv6 addresses in an union with IPv4 ones this won't work anymore).The new field was added to a hole in
sw_flow_key.Signed-off-by Jiri Benc <[email protected]>Acked-by Pravin B Shelar <[email protected]>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev
PATCH v3 2/2 openvswitch: netlink attributes for IPv6 tunneling
In reply to Jiri BencAdd netlink attributes for IPv6 tunnel addresses. This enables IPv6 support for tunnels.
---
v2: Changed description. Rebased tun_proto assignment in ip_tun_from_nlattr
to accomodate changes in the previous patch.
v3: No change.
--- include/uapi/linux/openvswitch.h | 2 + net/openvswitch/flow_netlink.c | 121 +++++++++++++++++++++++++++------------ 2 files changed, 86 insertions(+), 37 deletions(-)
include/uapi/linux/openvswitch.h +2 -0
@@ -349,6 +349,8 @@ enum ovs_tunnel_key_attr {OVS_TUNNEL_KEY_ATTR_TP_SRC ,/* be16 src Transport Port. */ OVS_TUNNEL_KEY_ATTR_TP_DST ,/* be16 dst Transport Port. */ OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS ,/* Nested OVS_VXLAN_EXT_* */ +OVS_TUNNEL_KEY_ATTR_IPV6_SRC ,/* struct in6_addr src IPv6 address. */ +OVS_TUNNEL_KEY_ATTR_IPV6_DST ,/* struct in6_addr dst IPv6 address. */ __OVS_TUNNEL_KEY_ATTR_MAX };
net/openvswitch/flow_netlink.c +84 -37
230 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH net-next v3 2/2] openvswitch: netlink attributes for IPv6 tunneling
Quoted 5 lines · Jiri Benc
Add netlink attributes for IPv6 tunnel addresses. This enables IPv6 support for tunnels.
Signed-off-by Jiri Benc <[email protected]>Acked-by Pravin B Shelar <[email protected]>
Thanks for doing this!
David Miller
maintainerFrom: Jiri Benc <[email protected]>
Date: Mon, 5 Oct 2015 13:09:45 +0200
Quoted 10 lines
This builds on the previous work that added IPv6 support to lwtunnels and adds IPv6 tunneling support to ovs.
To use IPv6 tunneling, there needs to be a metadata based tunnel
net_devicecreated and added to the ovs bridge. Currently, only vxlan is supported by the kernel, with geneve to follow shortly. There's no need nor intent to add a support for this into the vport-vxlan (etc.) compat layer.
---v3: dropped the last two patches added in v2.
Series applied, thanks.