The nl_lookup_genl_mcgroup() function can fail on older kernels
which do not support the required netlink interface.  Before this
patch, dpif-linux would refuse to create a datapath when this
happened.  With this patch, it attempts to use a workaround.  If
the workaround fails it simply disables the affected features
without completely disabling the dpif.
---
 lib/dpif-linux.c     |   15 +++++++++++----
 lib/netlink-socket.c |    7 ++++++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 53ec071..5362ed4 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -1127,11 +1127,18 @@ dpif_linux_init(void)
             error = nl_sock_create(NETLINK_GENERIC, &genl_sock);
         }
         if (!error) {
-            error = nl_lookup_genl_mcgroup(OVS_VPORT_FAMILY, OVS_VPORT_MCGROUP,
-                                           &ovs_vport_mcgroup);
-        }
-        if (!error) {
             static struct dpif_linux_vport vport;
+            int mcgroup_error;
+
+            mcgroup_error = nl_lookup_genl_mcgroup(OVS_VPORT_FAMILY,
+                                                   OVS_VPORT_MCGROUP,
+                                                   &ovs_vport_mcgroup);
+            if (mcgroup_error) {
+                VLOG_INFO("failed to lookup ovs_vport_mcgroup id (%s), using"
+                          " fallback value", strerror(mcgroup_error));
+                ovs_vport_mcgroup = OVS_VPORT_MCGROUP_FALLBACK_ID;
+            }
+
             nln = nln_create(NETLINK_GENERIC, ovs_vport_mcgroup,
                              dpif_linux_nln_parse, &vport);
         }
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index 2d2aa29..dde5838 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -680,7 +680,7 @@ static struct hmap genl_families = 
HMAP_INITIALIZER(&genl_families);
 
 static const struct nl_policy family_policy[CTRL_ATTR_MAX + 1] = {
     [CTRL_ATTR_FAMILY_ID] = {.type = NL_A_U16},
-    [CTRL_ATTR_MCAST_GROUPS] = {.type = NL_A_NESTED},
+    [CTRL_ATTR_MCAST_GROUPS] = {.type = NL_A_NESTED, .optional = true},
 };
 
 static struct genl_family *
@@ -784,6 +784,11 @@ nl_lookup_genl_mcgroup(const char *family_name, const char 
*group_name,
         return error;
     }
 
+    if (!family_attrs[CTRL_ATTR_MCAST_GROUPS]) {
+        error = EPROTO;
+        goto exit;
+    }
+
     nl_attr_get_nested(family_attrs[CTRL_ATTR_MCAST_GROUPS], &all_mcs);
     NL_ATTR_FOR_EACH (mc, left, all_mcs.data, all_mcs.size) {
         static const struct nl_policy mc_policy[] = {
-- 
1.7.6.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to