From: Simon Horman <simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org
Subject: [PATCH net-next v11 6/6] openvswitch: use ipgre tunnel rather than gretap tunnel
Date: Wed, 6 Jul 2016 19:59:56 +0200 [thread overview]
Message-ID: <1467827996-32547-7-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1467827996-32547-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
This allows GRE tunnels to send and receive both
layer 2 packets (packets with an ethernet header) and
layer 3 packets (packets without an ethernet header).
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
v11
* Make use of skb_mac_header_was_set() to avoid needing to calculate mac_len
v10
* Handle case of l3 only packets on vport-netdev
* Use ARPHRD_NONE for ipgre interfaces as per recent changes in mainline
* Ensure skb->mac_len is set correctly in netdev_port_receive and
relay on this value to differentiate layer3 packets in
ovs_flow_key_extract()
---
include/net/gre.h | 4 ++--
net/ipv4/ip_gre.c | 9 +++++----
net/openvswitch/flow.c | 2 +-
net/openvswitch/vport-gre.c | 2 +-
net/openvswitch/vport-netdev.c | 18 ++++++++++++------
5 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/include/net/gre.h b/include/net/gre.h
index 7a54a31d1d4c..a218a4deffd1 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -23,8 +23,8 @@ struct gre_protocol {
int gre_add_protocol(const struct gre_protocol *proto, u8 version);
int gre_del_protocol(const struct gre_protocol *proto, u8 version);
-struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
- u8 name_assign_type);
+struct net_device *gre_fb_dev_create(struct net *net, const char *name,
+ u8 name_assign_type);
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
bool *csum_err, __be16 proto, int nhs);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 330d58e9c523..a20248355da0 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1147,8 +1147,8 @@ static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
.get_link_net = ip_tunnel_get_link_net,
};
-struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
- u8 name_assign_type)
+struct net_device *gre_fb_dev_create(struct net *net, const char *name,
+ u8 name_assign_type)
{
struct nlattr *tb[IFLA_MAX + 1];
struct net_device *dev;
@@ -1159,13 +1159,14 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
memset(&tb, 0, sizeof(tb));
dev = rtnl_create_link(net, name, name_assign_type,
- &ipgre_tap_ops, tb);
+ &ipgre_link_ops, tb);
if (IS_ERR(dev))
return dev;
/* Configure flow based GRE device. */
t = netdev_priv(dev);
t->collect_md = true;
+ dev->type = ARPHRD_NONE;
err = ipgre_newlink(net, dev, tb, NULL);
if (err < 0) {
@@ -1190,7 +1191,7 @@ out:
unregister_netdevice_many(&list_kill);
return ERR_PTR(err);
}
-EXPORT_SYMBOL_GPL(gretap_fb_dev_create);
+EXPORT_SYMBOL_GPL(gre_fb_dev_create);
static int __net_init ipgre_tap_init_net(struct net *net)
{
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 86f2cfb19de3..42587d5bf894 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -729,7 +729,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
key->phy.skb_mark = skb->mark;
ovs_ct_fill_key(skb, key);
key->ovs_flow_hash = 0;
- key->phy.is_layer3 = skb->mac_len == 0;
+ key->phy.is_layer3 = skb_mac_header_was_set(skb) == 0;
key->recirc_id = 0;
err = key_extract(skb, key);
diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c
index bcbc91b8b077..c1cab9dd392f 100644
--- a/net/openvswitch/vport-gre.c
+++ b/net/openvswitch/vport-gre.c
@@ -60,7 +60,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
return vport;
rtnl_lock();
- dev = gretap_fb_dev_create(net, parms->name, NET_NAME_USER);
+ dev = gre_fb_dev_create(net, parms->name, NET_NAME_USER);
if (IS_ERR(dev)) {
rtnl_unlock();
ovs_vport_free(vport);
diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c
index 733e7914f6bd..82b10802abe6 100644
--- a/net/openvswitch/vport-netdev.c
+++ b/net/openvswitch/vport-netdev.c
@@ -61,6 +61,7 @@ static void netdev_port_receive(struct sk_buff *skb)
skb_push(skb, ETH_HLEN);
skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
}
+
ovs_vport_receive(vport, skb, skb_tunnel_info(skb));
return;
error:
@@ -99,7 +100,8 @@ struct vport *ovs_netdev_link(struct vport *vport, const char *name)
}
if (vport->dev->flags & IFF_LOOPBACK ||
- vport->dev->type != ARPHRD_ETHER ||
+ (vport->dev->type != ARPHRD_ETHER &&
+ vport->dev->type != ARPHRD_NONE) ||
ovs_is_internal_dev(vport->dev)) {
err = -EINVAL;
goto error_put;
@@ -198,12 +200,16 @@ EXPORT_SYMBOL_GPL(ovs_netdev_tunnel_destroy);
int ovs_netdev_send(struct sk_buff *skb)
{
- /* Only send L2 packets */
- if (skb->mac_len)
- return dev_queue_xmit(skb);
+ struct net_device *dev = skb->dev;
- kfree_skb(skb);
- return -EINVAL;
+ if (dev->type != ARPHRD_ETHER && skb->mac_len) {
+ skb->protocol = htons(ETH_P_TEB);
+ } else if (dev->type == ARPHRD_ETHER && !skb->mac_len) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ return dev_queue_xmit(skb);
}
EXPORT_SYMBOL_GPL(ovs_netdev_send);
--
2.7.0.rc3.207.g0ac5344
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
prev parent reply other threads:[~2016-07-06 17:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 17:59 [PATCH net-next v11 0/6] openvswitch: support for layer 3 encapsulated packets Simon Horman
[not found] ` <1467827996-32547-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-06 17:59 ` [PATCH net-next v11 1/6] net: introduce skb_transport_header_was_set() Simon Horman
[not found] ` <1467827996-32547-2-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-07 20:51 ` pravin shelar
2016-07-06 17:59 ` [PATCH net-next v11 2/6] gre: unset mac header for non-TEB packets received by ipgre device Simon Horman
2016-07-07 20:51 ` [ovs-dev] " pravin shelar
2016-07-06 17:59 ` [PATCH net-next v11 3/6] openvswitch: set skb protocol and mac_len when receiving on internal device Simon Horman
[not found] ` <1467827996-32547-4-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-07 20:52 ` pravin shelar
[not found] ` <CAOrHB_B2VDPcEe0B471J+XjmviAbTO0JRPTHiS7jHzF5V8uHZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-13 7:17 ` Simon Horman
2016-07-06 17:59 ` [PATCH net-next v11 4/6] openvswitch: add support to push and pop mpls for layer3 packets Simon Horman
[not found] ` <1467827996-32547-5-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-07-07 20:52 ` pravin shelar
2016-07-10 11:14 ` [ovs-dev] " Simon Horman
2016-07-06 17:59 ` [PATCH net-next v11 5/6] openvswitch: add layer 3 flow/port support Simon Horman
2016-07-07 20:54 ` [ovs-dev] " pravin shelar
[not found] ` <CAOrHB_BYD40ZkWbU0dvhPOCcaCVgooksOUkejxyFoagyoiBTNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-13 7:31 ` Simon Horman
2016-07-15 21:07 ` [ovs-dev] " pravin shelar
2016-07-18 4:50 ` Simon Horman
2016-07-18 22:34 ` pravin shelar
[not found] ` <CAOrHB_C3Hq-V4uPWLELSc2VMywjYSnKiFJ4VJQDnPpCu7s1Xkw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-20 0:02 ` Simon Horman
[not found] ` <20160720000243.GA4688-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-07-20 18:06 ` pravin shelar
2016-08-08 15:17 ` [ovs-dev] " Simon Horman
2016-08-08 15:28 ` Jiri Benc
2016-08-10 10:16 ` Simon Horman
[not found] ` <20160808151716.GA8477-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-09 15:47 ` pravin shelar
[not found] ` <CAOrHB_BYtGsWPSs2pxTjPajqFEP=5YySmqjc93NbdtY96-dYfw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-10 10:20 ` Simon Horman
[not found] ` <20160810102043.GE5451-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-10 17:17 ` Joe Stringer
2016-08-22 11:04 ` [ovs-dev] " Simon Horman
[not found] ` <20160822110444.GA29971-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-22 21:47 ` Joe Stringer
[not found] ` <CAPWQB7EQhbcDEk==AmN58Qxndmd6oHpw8z78kj2Q4M4-mD7+Dw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-23 8:51 ` Simon Horman
[not found] ` <20160823085144.GA22304-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-25 10:08 ` Simon Horman
[not found] ` <20160825100833.GA31926-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-26 0:33 ` Joe Stringer
[not found] ` <CAPWQB7G8RekHoTMNR5jAJGu7n2i8fNZ1=Fvj4XX_tXVSovpGug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-26 9:13 ` Simon Horman
[not found] ` <20160826091322.GE22464-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-08-30 23:23 ` Joe Stringer
[not found] ` <20160718045025.GA2490-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-07-21 15:39 ` Jiri Benc
2016-09-26 16:53 ` [ovs-dev] " Jiri Benc
2016-09-27 4:09 ` pravin shelar
2016-07-06 17:59 ` Simon Horman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467827996-32547-7-git-send-email-simon.horman@netronome.com \
--to=simon.horman-wfxrvt7yatfl57midrcfdg@public.gmane.org \
--cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).