fib: rules: remove duplicated nla policies
authorFlorian Westphal <fw@strlen.de>
Thu, 16 Dec 2021 12:05:06 +0000 (13:05 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 16 Dec 2021 15:18:35 +0000 (07:18 -0800)
The attributes are identical in all implementations so move the ipv4 one
into the core and remove the per-family nla policies.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/fib_rules.h
net/core/fib_rules.c
net/decnet/dn_rules.c
net/ipv4/fib_rules.c
net/ipv4/ipmr.c
net/ipv6/fib6_rules.c
net/ipv6/ip6mr.c

index bd07484ab9dd5f9de0321f63393941b521a0b5fa..4183204915dcfe2ad20777d7c023cb2c9a57fbc9 100644 (file)
@@ -91,7 +91,6 @@ struct fib_rules_ops {
        void                    (*flush_cache)(struct fib_rules_ops *ops);
 
        int                     nlgroup;
-       const struct nla_policy *policy;
        struct list_head        rules_list;
        struct module           *owner;
        struct net              *fro_net;
index 1bb567a3b329cd06534f3e0fa27a463e06e538cc..f2ae5dcef0bcbfdd9e6cf0896528b296a2cca48d 100644 (file)
@@ -750,6 +750,11 @@ static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh,
        return 0;
 }
 
+static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = {
+       FRA_GENERIC_POLICY,
+       [FRA_FLOW]      = { .type = NLA_U32 },
+};
+
 int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
                   struct netlink_ext_ack *extack)
 {
@@ -774,7 +779,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
        }
 
        err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,
-                                    ops->policy, extack);
+                                    fib_rule_policy, extack);
        if (err < 0) {
                NL_SET_ERR_MSG(extack, "Error parsing msg");
                goto errout;
@@ -882,7 +887,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
        }
 
        err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,
-                                    ops->policy, extack);
+                                    fib_rule_policy, extack);
        if (err < 0) {
                NL_SET_ERR_MSG(extack, "Error parsing msg");
                goto errout;
index 4a4e3c17740cbb765dd3d11d41d32ef82e860d94..ee73057529cf9bb342529492f07fd0ed341837f2 100644 (file)
@@ -101,10 +101,6 @@ errout:
        return err;
 }
 
-static const struct nla_policy dn_fib_rule_policy[FRA_MAX+1] = {
-       FRA_GENERIC_POLICY,
-};
-
 static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
 {
        struct dn_fib_rule *r = (struct dn_fib_rule *)rule;
@@ -235,7 +231,6 @@ static const struct fib_rules_ops __net_initconst dn_fib_rules_ops_template = {
        .fill           = dn_fib_rule_fill,
        .flush_cache    = dn_fib_rule_flush_cache,
        .nlgroup        = RTNLGRP_DECnet_RULE,
-       .policy         = dn_fib_rule_policy,
        .owner          = THIS_MODULE,
        .fro_net        = &init_net,
 };
index d279cb8ac1584487885f66819634b421c01bf819..e0b6c8b6de573ae27acff133a170de69b66f7bfb 100644 (file)
@@ -216,11 +216,6 @@ static struct fib_table *fib_empty_table(struct net *net)
        return NULL;
 }
 
-static const struct nla_policy fib4_rule_policy[FRA_MAX+1] = {
-       FRA_GENERIC_POLICY,
-       [FRA_FLOW]      = { .type = NLA_U32 },
-};
-
 static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                               struct fib_rule_hdr *frh,
                               struct nlattr **tb,
@@ -386,7 +381,6 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = {
        .nlmsg_payload  = fib4_rule_nlmsg_payload,
        .flush_cache    = fib4_rule_flush_cache,
        .nlgroup        = RTNLGRP_IPV4_RULE,
-       .policy         = fib4_rule_policy,
        .owner          = THIS_MODULE,
 };
 
index 4c7aca884fa9a35816008a5f3a1a58dd1baf6c06..07274619b9ea11837501f8fe812d616d20573ee0 100644 (file)
@@ -195,10 +195,6 @@ static int ipmr_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
        return 1;
 }
 
-static const struct nla_policy ipmr_rule_policy[FRA_MAX + 1] = {
-       FRA_GENERIC_POLICY,
-};
-
 static int ipmr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                               struct fib_rule_hdr *frh, struct nlattr **tb,
                               struct netlink_ext_ack *extack)
@@ -231,7 +227,6 @@ static const struct fib_rules_ops __net_initconst ipmr_rules_ops_template = {
        .compare        = ipmr_rule_compare,
        .fill           = ipmr_rule_fill,
        .nlgroup        = RTNLGRP_IPV4_RULE,
-       .policy         = ipmr_rule_policy,
        .owner          = THIS_MODULE,
 };
 
index dcedfe29d9d932a3a85491021557005228860ffe..ec029c86ae06828c1cfe886ad0f401318b114310 100644 (file)
@@ -340,10 +340,6 @@ INDIRECT_CALLABLE_SCOPE int fib6_rule_match(struct fib_rule *rule,
        return 1;
 }
 
-static const struct nla_policy fib6_rule_policy[FRA_MAX+1] = {
-       FRA_GENERIC_POLICY,
-};
-
 static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                               struct fib_rule_hdr *frh,
                               struct nlattr **tb,
@@ -459,7 +455,6 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = {
        .fill                   = fib6_rule_fill,
        .nlmsg_payload          = fib6_rule_nlmsg_payload,
        .nlgroup                = RTNLGRP_IPV6_RULE,
-       .policy                 = fib6_rule_policy,
        .owner                  = THIS_MODULE,
        .fro_net                = &init_net,
 };
index a77a15a7f3dcb61c53a86e055b8a1507d9d591f8..7cf73e60e619ba92ea1eccc90c181ba7150225dd 100644 (file)
@@ -182,10 +182,6 @@ static int ip6mr_rule_match(struct fib_rule *rule, struct flowi *flp, int flags)
        return 1;
 }
 
-static const struct nla_policy ip6mr_rule_policy[FRA_MAX + 1] = {
-       FRA_GENERIC_POLICY,
-};
-
 static int ip6mr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                                struct fib_rule_hdr *frh, struct nlattr **tb,
                                struct netlink_ext_ack *extack)
@@ -218,7 +214,6 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = {
        .compare        = ip6mr_rule_compare,
        .fill           = ip6mr_rule_fill,
        .nlgroup        = RTNLGRP_IPV6_RULE,
-       .policy         = ip6mr_rule_policy,
        .owner          = THIS_MODULE,
 };