The policy field of the genl_ops structure has been removed in recent
kernels.

Signed-off-by: Greg Rose <gvrose8...@gmail.com>
---
 acinclude.m4         |  3 +++
 datapath/conntrack.c |  8 ++++++++
 datapath/datapath.c  | 32 ++++++++++++++++++++++++++++++++
 datapath/meter.c     | 10 ++++++++++
 4 files changed, 53 insertions(+)

diff --git a/acinclude.m4 b/acinclude.m4
index cad76c7..a55c905 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1069,6 +1069,9 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
                   [OVS_DEFINE([HAVE_DST_OPS_CONFIRM_NEIGH])])
   OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [fqdir],
                   [OVS_DEFINE([HAVE_INET_FRAG_FQDIR])])
+  OVS_FIND_FIELD_IFELSE([$KSRC/include/net/genetlink.h], [genl_ops],
+                        [policy],
+                        [OVS_DEFINE([HAVE_GENL_OPS_POLICY])])
 
   if cmp -s datapath/linux/kcompat.h.new \
             datapath/linux/kcompat.h >/dev/null 2>&1; then
diff --git a/datapath/conntrack.c b/datapath/conntrack.c
index 838cf63..25da2a5 100644
--- a/datapath/conntrack.c
+++ b/datapath/conntrack.c
@@ -134,10 +134,12 @@ struct ovs_ct_limit_info {
        struct nf_conncount_data *data;
 };
 
+#ifdef HAVE_GENL_OPS_POLICY
 static const struct nla_policy ct_limit_policy[OVS_CT_LIMIT_ATTR_MAX + 1] = {
        [OVS_CT_LIMIT_ATTR_ZONE_LIMIT] = { .type = NLA_NESTED, },
 };
 #endif
+#endif
 
 static bool labels_nonzero(const struct ovs_key_ct_labels *labels);
 
@@ -2312,7 +2314,9 @@ static struct genl_ops ct_limit_genl_ops[] = {
 #endif
                .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
                                           * privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = ct_limit_policy,
+#endif
                .doit = ovs_ct_limit_cmd_set,
        },
        { .cmd = OVS_CT_LIMIT_CMD_DEL,
@@ -2321,7 +2325,9 @@ static struct genl_ops ct_limit_genl_ops[] = {
 #endif
                .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
                                           * privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = ct_limit_policy,
+#endif
                .doit = ovs_ct_limit_cmd_del,
        },
        { .cmd = OVS_CT_LIMIT_CMD_GET,
@@ -2329,7 +2335,9 @@ static struct genl_ops ct_limit_genl_ops[] = {
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
                .flags = 0,               /* OK for unprivileged users. */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = ct_limit_policy,
+#endif
                .doit = ovs_ct_limit_cmd_get,
        },
 };
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 853bfb5..55a835d 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -643,6 +643,7 @@ err:
        return err;
 }
 
+#ifdef HAVE_GENL_OPS_POLICY
 static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
        [OVS_PACKET_ATTR_PACKET] = { .len = ETH_HLEN },
        [OVS_PACKET_ATTR_KEY] = { .type = NLA_NESTED },
@@ -650,6 +651,7 @@ static const struct nla_policy 
packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
        [OVS_PACKET_ATTR_PROBE] = { .type = NLA_FLAG },
        [OVS_PACKET_ATTR_MRU] = { .type = NLA_U16 },
 };
+#endif
 
 static struct genl_ops dp_packet_genl_ops[] = {
        { .cmd = OVS_PACKET_CMD_EXECUTE,
@@ -657,7 +659,9 @@ static struct genl_ops dp_packet_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = packet_policy,
+#endif
          .doit = ovs_packet_cmd_execute
        }
 };
@@ -1449,7 +1453,9 @@ static const struct genl_ops dp_flow_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = flow_policy,
+#endif
          .doit = ovs_flow_cmd_new
        },
        { .cmd = OVS_FLOW_CMD_DEL,
@@ -1457,7 +1463,9 @@ static const struct genl_ops dp_flow_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = flow_policy,
+#endif
          .doit = ovs_flow_cmd_del
        },
        { .cmd = OVS_FLOW_CMD_GET,
@@ -1465,7 +1473,9 @@ static const struct genl_ops dp_flow_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = 0,               /* OK for unprivileged users. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = flow_policy,
+#endif
          .doit = ovs_flow_cmd_get,
          .dumpit = ovs_flow_cmd_dump
        },
@@ -1474,7 +1484,9 @@ static const struct genl_ops dp_flow_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = flow_policy,
+#endif
          .doit = ovs_flow_cmd_set,
        },
 };
@@ -1841,11 +1853,13 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct 
netlink_callback *cb)
        return skb->len;
 }
 
+#ifdef HAVE_GENL_OPS_POLICY
 static const struct nla_policy datapath_policy[OVS_DP_ATTR_MAX + 1] = {
        [OVS_DP_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
        [OVS_DP_ATTR_UPCALL_PID] = { .type = NLA_U32 },
        [OVS_DP_ATTR_USER_FEATURES] = { .type = NLA_U32 },
 };
+#endif
 
 static const struct genl_ops dp_datapath_genl_ops[] = {
        { .cmd = OVS_DP_CMD_NEW,
@@ -1853,7 +1867,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = datapath_policy,
+#endif
          .doit = ovs_dp_cmd_new
        },
        { .cmd = OVS_DP_CMD_DEL,
@@ -1861,7 +1877,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = datapath_policy,
+#endif
          .doit = ovs_dp_cmd_del
        },
        { .cmd = OVS_DP_CMD_GET,
@@ -1869,7 +1887,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = 0,               /* OK for unprivileged users. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = datapath_policy,
+#endif
          .doit = ovs_dp_cmd_get,
          .dumpit = ovs_dp_cmd_dump
        },
@@ -1878,7 +1898,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = datapath_policy,
+#endif
          .doit = ovs_dp_cmd_set,
        },
 };
@@ -2293,6 +2315,7 @@ out:
        return skb->len;
 }
 
+#ifdef HAVE_GENL_OPS_POLICY
 static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
        [OVS_VPORT_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
        [OVS_VPORT_ATTR_STATS] = { .len = sizeof(struct ovs_vport_stats) },
@@ -2303,6 +2326,7 @@ static const struct nla_policy 
vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
        [OVS_VPORT_ATTR_IFINDEX] = { .type = NLA_U32 },
        [OVS_VPORT_ATTR_NETNSID] = { .type = NLA_S32 },
 };
+#endif
 
 static const struct genl_ops dp_vport_genl_ops[] = {
        { .cmd = OVS_VPORT_CMD_NEW,
@@ -2310,7 +2334,9 @@ static const struct genl_ops dp_vport_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = vport_policy,
+#endif
          .doit = ovs_vport_cmd_new
        },
        { .cmd = OVS_VPORT_CMD_DEL,
@@ -2318,7 +2344,9 @@ static const struct genl_ops dp_vport_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = vport_policy,
+#endif
          .doit = ovs_vport_cmd_del
        },
        { .cmd = OVS_VPORT_CMD_GET,
@@ -2326,7 +2354,9 @@ static const struct genl_ops dp_vport_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = 0,               /* OK for unprivileged users. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = vport_policy,
+#endif
          .doit = ovs_vport_cmd_get,
          .dumpit = ovs_vport_cmd_dump
        },
@@ -2335,7 +2365,9 @@ static const struct genl_ops dp_vport_genl_ops[] = {
          .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
          .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
+#ifdef HAVE_GENL_OPS_POLICY
          .policy = vport_policy,
+#endif
          .doit = ovs_vport_cmd_set,
        },
 };
diff --git a/datapath/meter.c b/datapath/meter.c
index 7d8f51a..8478d80 100644
--- a/datapath/meter.c
+++ b/datapath/meter.c
@@ -26,6 +26,7 @@
 
 #define METER_HASH_BUCKETS 1024
 
+#ifdef HAVE_GENL_OPS_POLICY
 static const struct nla_policy meter_policy[OVS_METER_ATTR_MAX + 1] = {
        [OVS_METER_ATTR_ID] = { .type = NLA_U32, },
        [OVS_METER_ATTR_KBPS] = { .type = NLA_FLAG },
@@ -36,6 +37,7 @@ static const struct nla_policy 
meter_policy[OVS_METER_ATTR_MAX + 1] = {
        [OVS_METER_ATTR_MAX_METERS] = { .type = NLA_U32 },
        [OVS_METER_ATTR_MAX_BANDS] = { .type = NLA_U32 },
 };
+#endif
 
 static const struct nla_policy band_policy[OVS_BAND_ATTR_MAX + 1] = {
        [OVS_BAND_ATTR_TYPE] = { .type = NLA_U32, },
@@ -542,7 +544,9 @@ static struct genl_ops dp_meter_genl_ops[] = {
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
                .flags = 0,               /* OK for unprivileged users. */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = meter_policy,
+#endif
                .doit = ovs_meter_cmd_features
        },
        { .cmd = OVS_METER_CMD_SET,
@@ -552,7 +556,9 @@ static struct genl_ops dp_meter_genl_ops[] = {
                .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
                                           *  privilege.
                                           */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = meter_policy,
+#endif
                .doit = ovs_meter_cmd_set,
        },
        { .cmd = OVS_METER_CMD_GET,
@@ -560,7 +566,9 @@ static struct genl_ops dp_meter_genl_ops[] = {
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
                .flags = 0,               /* OK for unprivileged users. */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = meter_policy,
+#endif
                .doit = ovs_meter_cmd_get,
        },
        { .cmd = OVS_METER_CMD_DEL,
@@ -570,7 +578,9 @@ static struct genl_ops dp_meter_genl_ops[] = {
                .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
                                           *  privilege.
                                           */
+#ifdef HAVE_GENL_OPS_POLICY
                .policy = meter_policy,
+#endif
                .doit = ovs_meter_cmd_del
        },
 };
-- 
1.8.3.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to