diff mbox

[ovs-dev,1/5] datapath: correct {new,del}link compat code

Message ID 1450414204-9038-2-git-send-email-simon.horman@netronome.com
State Changes Requested
Headers show

Commit Message

Simon Horman Dec. 18, 2015, 4:50 a.m. UTC
* The net parameter of newlink and the head parameter of dellink were
  introduced introduced in v2.6.33
* The head parameter of dellink cannot be used if its not present

Fixes: e23775f20e1a ("datapath: Add support for lwtunnel")
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 .travis.yml                             |  3 +++
 datapath/linux/compat/dev-openvswitch.c |  2 +-
 datapath/linux/compat/geneve.c          | 22 ++++++++++++++--------
 datapath/linux/compat/ip_gre.c          |  4 ++--
 datapath/linux/compat/lisp.c            | 14 ++++++++++----
 datapath/linux/compat/vxlan.c           | 23 ++++++++++++++++-------
 6 files changed, 46 insertions(+), 22 deletions(-)

Comments

Pravin B Shelar Dec. 23, 2015, 10:11 p.m. UTC | #1
On Thu, Dec 17, 2015 at 8:50 PM, Simon Horman
<simon.horman@netronome.com> wrote:
> * The net parameter of newlink and the head parameter of dellink were
>   introduced introduced in v2.6.33
> * The head parameter of dellink cannot be used if its not present
>
> Fixes: e23775f20e1a ("datapath: Add support for lwtunnel")
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> ---
>  .travis.yml                             |  3 +++
>  datapath/linux/compat/dev-openvswitch.c |  2 +-
>  datapath/linux/compat/geneve.c          | 22 ++++++++++++++--------
>  datapath/linux/compat/ip_gre.c          |  4 ++--
>  datapath/linux/compat/lisp.c            | 14 ++++++++++----
>  datapath/linux/compat/vxlan.c           | 23 ++++++++++++++++-------
>  6 files changed, 46 insertions(+), 22 deletions(-)
>
> diff --git a/.travis.yml b/.travis.yml
> index ea1d7e7ebea4..90df67454a22 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -32,6 +32,9 @@ env:
>    - KERNEL=3.10.92
>    - KERNEL=3.4.110
>    - KERNEL=3.2.72
> +  - KERNEL=2.6.38.8
> +  - KERNEL=2.6.37.6
> +  - KERNEL=2.6.33.20
>    - KERNEL=2.6.32.68

Currently we have kept it insync with kernel versions from kernel.org.
So that we can get compilation test coverage against stable kernel and
keep build matrix in shape. The added kernels are not in use much use
and they are not maintained by linux community. so I do not think we
should add these older kernel to the list.
>
>  script: ./.travis/build.sh $OPTS
> diff --git a/datapath/linux/compat/dev-openvswitch.c b/datapath/linux/compat/dev-openvswitch.c
> index d7d4224a1cb3..5fe356a1cefd 100644
> --- a/datapath/linux/compat/dev-openvswitch.c
> +++ b/datapath/linux/compat/dev-openvswitch.c
> @@ -103,7 +103,7 @@ int rpl_rtnl_delete_link(struct net_device *dev)
>         if (!ops || !ops->dellink)
>                 return -EOPNOTSUPP;
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
>         ops->dellink(dev);
>  #else
>         {
> diff --git a/datapath/linux/compat/geneve.c b/datapath/linux/compat/geneve.c
> index 297593ce6e1a..38e8abbc0c36 100644
> --- a/datapath/linux/compat/geneve.c
> +++ b/datapath/linux/compat/geneve.c
> @@ -909,15 +909,15 @@ static int geneve_configure(struct net *net, struct net_device *dev,
>         return 0;
>  }
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
> -static int geneve_newlink(struct net_device *dev,
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
> +static int geneve_newlink(struct net *net, struct net_device *dev,
>                           struct nlattr *tb[], struct nlattr *data[])
>  {
> -       struct net *net = &init_net;
>  #else
> -static int geneve_newlink(struct net *net, struct net_device *dev,
> +static int geneve_newlink(struct net_device *dev,
>                           struct nlattr *tb[], struct nlattr *data[])
>  {
> +       struct net *net = &init_net;
>  #endif
>         __be16 dst_port = htons(GENEVE_UDP_PORT);
>         __u8 ttl = 0, tos = 0;
> @@ -947,17 +947,23 @@ static int geneve_newlink(struct net *net, struct net_device *dev,
>                                 ttl, tos, dst_port, metadata);
>  }
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
> -static void geneve_dellink(struct net_device *dev)
> -#else
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
>  static void geneve_dellink(struct net_device *dev, struct list_head *head)
> -#endif
>  {
>         struct geneve_dev *geneve = netdev_priv(dev);
>
>         list_del(&geneve->next);
>         unregister_netdevice_queue(dev, head);
>  }
> +#else
> +static void geneve_dellink(struct net_device *dev)
> +{
> +       struct geneve_dev *geneve = netdev_priv(dev);
> +
> +       list_del(&geneve->next);
> +       unregister_netdevice(dev);
> +}
> +#endif
>

I do not see reason to define another function body here.
unregister_netdevice_queue() is defined as unregister_netdevice() on
older kernel.
diff mbox

Patch

diff --git a/.travis.yml b/.travis.yml
index ea1d7e7ebea4..90df67454a22 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,6 +32,9 @@  env:
   - KERNEL=3.10.92
   - KERNEL=3.4.110
   - KERNEL=3.2.72
+  - KERNEL=2.6.38.8
+  - KERNEL=2.6.37.6
+  - KERNEL=2.6.33.20
   - KERNEL=2.6.32.68
 
 script: ./.travis/build.sh $OPTS
diff --git a/datapath/linux/compat/dev-openvswitch.c b/datapath/linux/compat/dev-openvswitch.c
index d7d4224a1cb3..5fe356a1cefd 100644
--- a/datapath/linux/compat/dev-openvswitch.c
+++ b/datapath/linux/compat/dev-openvswitch.c
@@ -103,7 +103,7 @@  int rpl_rtnl_delete_link(struct net_device *dev)
 	if (!ops || !ops->dellink)
 		return -EOPNOTSUPP;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
 	ops->dellink(dev);
 #else
 	{
diff --git a/datapath/linux/compat/geneve.c b/datapath/linux/compat/geneve.c
index 297593ce6e1a..38e8abbc0c36 100644
--- a/datapath/linux/compat/geneve.c
+++ b/datapath/linux/compat/geneve.c
@@ -909,15 +909,15 @@  static int geneve_configure(struct net *net, struct net_device *dev,
 	return 0;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
-static int geneve_newlink(struct net_device *dev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+static int geneve_newlink(struct net *net, struct net_device *dev,
 			  struct nlattr *tb[], struct nlattr *data[])
 {
-	struct net *net = &init_net;
 #else
-static int geneve_newlink(struct net *net, struct net_device *dev,
+static int geneve_newlink(struct net_device *dev,
 			  struct nlattr *tb[], struct nlattr *data[])
 {
+	struct net *net = &init_net;
 #endif
 	__be16 dst_port = htons(GENEVE_UDP_PORT);
 	__u8 ttl = 0, tos = 0;
@@ -947,17 +947,23 @@  static int geneve_newlink(struct net *net, struct net_device *dev,
 				ttl, tos, dst_port, metadata);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
-static void geneve_dellink(struct net_device *dev)
-#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 static void geneve_dellink(struct net_device *dev, struct list_head *head)
-#endif
 {
 	struct geneve_dev *geneve = netdev_priv(dev);
 
 	list_del(&geneve->next);
 	unregister_netdevice_queue(dev, head);
 }
+#else
+static void geneve_dellink(struct net_device *dev)
+{
+	struct geneve_dev *geneve = netdev_priv(dev);
+
+	list_del(&geneve->next);
+	unregister_netdevice(dev);
+}
+#endif
 
 static size_t geneve_get_size(const struct net_device *dev)
 {
diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
index c9197e9652fd..3abcf4149d92 100644
--- a/datapath/linux/compat/ip_gre.c
+++ b/datapath/linux/compat/ip_gre.c
@@ -482,7 +482,7 @@  static void ipgre_tap_setup(struct net_device *dev)
 	ip_tunnel_setup(dev, gre_tap_net_id);
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 static int ipgre_newlink(struct net *src_net, struct net_device *dev,
 			 struct nlattr *tb[], struct nlattr *data[])
 #else
@@ -606,7 +606,7 @@  struct net_device *rpl_gretap_fb_dev_create(struct net *net, const char *name,
 	t = netdev_priv(dev);
 	t->collect_md = true;
 	/* Configure flow based GRE device. */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 	err = ipgre_newlink(net, dev, tb, NULL);
 #else
 	err = ipgre_newlink(dev, tb, NULL);
diff --git a/datapath/linux/compat/lisp.c b/datapath/linux/compat/lisp.c
index e5a6a7fe00a4..6e8231691db1 100644
--- a/datapath/linux/compat/lisp.c
+++ b/datapath/linux/compat/lisp.c
@@ -557,7 +557,7 @@  static int lisp_configure(struct net *net, struct net_device *dev,
 	return 0;
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 static int lisp_newlink(struct net *net, struct net_device *dev,
 		struct nlattr *tb[], struct nlattr *data[])
 {
@@ -576,17 +576,23 @@  static int lisp_newlink(struct net_device *dev,
 	return lisp_configure(net, dev, dst_port);
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 static void lisp_dellink(struct net_device *dev, struct list_head *head)
+{
+	struct lisp_dev *lisp = netdev_priv(dev);
+
+	list_del(&lisp->next);
+	unregister_netdevice_queue(dev, head);
+}
 #else
 static void lisp_dellink(struct net_device *dev)
-#endif
 {
 	struct lisp_dev *lisp = netdev_priv(dev);
 
 	list_del(&lisp->next);
-	unregister_netdevice_queue(dev, head);
+	unregister_netdevice(dev);
 }
+#endif
 
 static size_t lisp_get_size(const struct net_device *dev)
 {
diff --git a/datapath/linux/compat/vxlan.c b/datapath/linux/compat/vxlan.c
index dd0015d01c32..c40c914d3e8f 100644
--- a/datapath/linux/compat/vxlan.c
+++ b/datapath/linux/compat/vxlan.c
@@ -2006,7 +2006,7 @@  struct net_device *rpl_vxlan_dev_create(struct net *net, const char *name,
 }
 EXPORT_SYMBOL_GPL(rpl_vxlan_dev_create);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 static int vxlan_newlink(struct net *src_net, struct net_device *dev,
 			 struct nlattr *tb[], struct nlattr *data[])
 #else
@@ -2017,11 +2017,7 @@  static int vxlan_newlink(struct net_device *dev,
 	return -EINVAL;
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
-static void vxlan_dellink(struct net_device *dev, struct list_head *head)
-#else
-static void vxlan_dellink(struct net_device *dev)
-#endif
+static void vxlan_dellink__(struct net_device *dev)
 {
 	struct vxlan_dev *vxlan = netdev_priv(dev);
 	struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
@@ -2032,8 +2028,21 @@  static void vxlan_dellink(struct net_device *dev)
 	spin_unlock(&vn->sock_lock);
 
 	list_del(&vxlan->next);
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+static void vxlan_dellink(struct net_device *dev, struct list_head *head)
+{
+	vxlan_dellink__(dev);
 	unregister_netdevice_queue(dev, head);
 }
+#else
+static void vxlan_dellink(struct net_device *dev)
+{
+	vxlan_dellink__(dev);
+	unregister_netdevice(dev);
+}
+#endif
 
 static size_t vxlan_get_size(const struct net_device *dev)
 {
@@ -2116,7 +2125,7 @@  static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn,
 		 * is 0 here, so no matches.
 		 */
 		if (dst->remote_ifindex == dev->ifindex)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
 			vxlan_dellink(vxlan->dev, &list_kill);
 #else
 			vxlan_dellink(vxlan->dev);