[ovs-dev] [PATCH 1/2] ovs: add brcompat configuration option

Tony Zelenoff antonz at parallels.com
Tue Jun 26 05:54:44 PDT 2012


It is good, when linux bridge compatibility is present inside
kernel in case there is lot of scripts written, which are using
standart bridge-utilities.

Signed-off-by: Tony Zelenoff <antonz at parallels.com>
---
 net/openvswitch/Kconfig              |    9 +++++++++
 net/openvswitch/datapath.c           |    6 ++++++
 net/openvswitch/datapath.h           |    4 +++-
 net/openvswitch/vport-internal_dev.c |   14 ++++++++++++++
 4 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/net/openvswitch/Kconfig b/net/openvswitch/Kconfig
index d9ea33c..884b64d 100644
--- a/net/openvswitch/Kconfig
+++ b/net/openvswitch/Kconfig
@@ -26,3 +26,12 @@ config OPENVSWITCH
 	  called openvswitch.
 
 	  If unsure, say N.
+
+config OVS_BRCOMPAT
+	tristate "Open vSwitch bridge compatibility"
+	depends on OPENVSWITCH
+	---help---
+	  Enable this option if you want to control Open vSwitch with bridge
+	  control utilities like brctl.
+
+	  This option adds compatibility layer to implement ioctl transferring.
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 2c74daa..1ea9c79 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -76,6 +76,12 @@
  */
 static LIST_HEAD(dps);
 
+#if defined(CONFIG_OVS_BRCOMPAT) || defined(CONFIG_OVS_BRCOMPAT_MODULE)
+/* Allow brcompat module be loaded and hooked to bridge */
+int (*ovs_dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
+EXPORT_SYMBOL_GPL(ovs_dp_ioctl_hook);
+#endif
+
 #define REHASH_FLOW_INTERVAL (10 * 60 * HZ)
 static void rehash_flow_table(struct work_struct *work);
 static DECLARE_DELAYED_WORK(rehash_flow_wq, rehash_flow_table);
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index c73370c..edaf1da 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -110,7 +110,9 @@ struct dp_upcall_info {
 
 extern struct notifier_block ovs_dp_device_notifier;
 extern struct genl_multicast_group ovs_dp_vport_multicast_group;
-
+#if defined(CONFIG_OVS_BRCOMPAT) || defined(CONFIG_OVS_BRCOMPAT_MODULE)
+extern int (*ovs_dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
+#endif
 void ovs_dp_process_received_packet(struct vport *, struct sk_buff *);
 void ovs_dp_detach_port(struct vport *);
 int ovs_dp_upcall(struct datapath *, struct sk_buff *,
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index b6b1d7d..5549674 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -112,6 +112,17 @@ static int internal_dev_change_mtu(struct net_device *netdev, int new_mtu)
 	return 0;
 }
 
+#if defined(CONFIG_OVS_BRCOMPAT) || defined(CONFIG_OVS_BRCOMPAT_MODULE)
+static int internal_dev_do_ioctl(struct net_device *dev,
+				 struct ifreq *ifr, int cmd)
+{
+	if (ovs_dp_ioctl_hook)
+		return ovs_dp_ioctl_hook(dev, ifr, cmd);
+
+	return -EOPNOTSUPP;
+}
+#endif
+
 static void internal_dev_destructor(struct net_device *dev)
 {
 	struct vport *vport = ovs_internal_dev_get_vport(dev);
@@ -127,6 +138,9 @@ static const struct net_device_ops internal_dev_netdev_ops = {
 	.ndo_set_mac_address = internal_dev_mac_addr,
 	.ndo_change_mtu = internal_dev_change_mtu,
 	.ndo_get_stats64 = internal_dev_get_stats,
+#if defined(CONFIG_OVS_BRCOMPAT) || defined(CONFIG_OVS_BRCOMPAT_MODULE)
+	.ndo_do_ioctl = internal_dev_do_ioctl,
+#endif
 };
 
 static void do_setup(struct net_device *netdev)
-- 
1.7.1




More information about the dev mailing list