History

Merge branch 'fib-merge-nl-policies'

Florian Westphal says: ==================== fib: merge nl policies v4: resend with fixed subject line. I preserved review tags from David Ahern. v3: drop first two patches, otherwise unchanged. This series merges the different (largely identical) nla policies. v2 also squashed the ->suppress() implementation, I've dropped this. Problem is that it needs ugly ifdef'ry to avoid build breakage with CONFIG_INET=n || IPV6=n. Given that even microbenchmark doesn't show any noticeable improvement when ->suppress is inlined (it uses INDIRECT_CALLABLE) i decided to toss the patch instead of adding more ifdefs. ====================

Jakub Kicinski committed 4 years ago

Commit 0f473bb2 parents 604ba23 66495f37 files · +23 −49Browse files

Unified · Split

7 files
  1. include/net/fib_rules.h +0 −21
  2. net/core/fib_rules.c +23 −2
  3. net/decnet/dn_rules.c +0 −5
  4. net/ipv4/fib_rules.c +0 −6
  5. net/ipv4/ipmr.c +0 −5
  6. net/ipv6/fib6_rules.c +0 −5
  7. net/ipv6/ip6mr.c +0 −5
include/net/fib_rules.h+0−21
@@ -91,7 +91,6 @@ struct fib_rules_ops { · 90 unmodified lines
9191 void (*flush_cache)(struct fib_rules_ops *ops);
9292
9393 int nlgroup;
94− const struct nla_policy *policy;
9594 struct list_head rules_list;
9695 struct module *owner;
9796 struct net *fro_net;
@@ -103,26 +102,6 @@ struct fib_rule_notifier_info { · 5 unmodified lines
103102 struct fib_rule *rule;
104103 };
105104
106−#define FRA_GENERIC_POLICY \
107− [FRA_UNSPEC] = { .strict_start_type = FRA_DPORT_RANGE + 1 }, \
108− [FRA_IIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
109− [FRA_OIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
110− [FRA_PRIORITY] = { .type = NLA_U32 }, \
111− [FRA_FWMARK] = { .type = NLA_U32 }, \
112− [FRA_TUN_ID] = { .type = NLA_U64 }, \
113− [FRA_FWMASK] = { .type = NLA_U32 }, \
114− [FRA_TABLE] = { .type = NLA_U32 }, \
115− [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
116− [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
117− [FRA_GOTO] = { .type = NLA_U32 }, \
118− [FRA_L3MDEV] = { .type = NLA_U8 }, \
119− [FRA_UID_RANGE] = { .len = sizeof(struct fib_rule_uid_range) }, \
120− [FRA_PROTOCOL] = { .type = NLA_U8 }, \
121− [FRA_IP_PROTO] = { .type = NLA_U8 }, \
122− [FRA_SPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }, \
123− [FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }
124−
125−
126105 static inline void fib_rule_get(struct fib_rule *rule)
127106 {
128107 refcount_inc(&rule->refcnt);
net/core/fib_rules.c+23−2
@@ -750,6 +750,27 @@ static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh, · 749 unmodified lines
750750 return 0;
751751 }
752752
753+static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = {
754+ [FRA_UNSPEC] = { .strict_start_type = FRA_DPORT_RANGE + 1 },
755+ [FRA_IIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
756+ [FRA_OIFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
757+ [FRA_PRIORITY] = { .type = NLA_U32 },
758+ [FRA_FWMARK] = { .type = NLA_U32 },
759+ [FRA_FLOW] = { .type = NLA_U32 },
760+ [FRA_TUN_ID] = { .type = NLA_U64 },
761+ [FRA_FWMASK] = { .type = NLA_U32 },
762+ [FRA_TABLE] = { .type = NLA_U32 },
763+ [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 },
764+ [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 },
765+ [FRA_GOTO] = { .type = NLA_U32 },
766+ [FRA_L3MDEV] = { .type = NLA_U8 },
767+ [FRA_UID_RANGE] = { .len = sizeof(struct fib_rule_uid_range) },
768+ [FRA_PROTOCOL] = { .type = NLA_U8 },
769+ [FRA_IP_PROTO] = { .type = NLA_U8 },
770+ [FRA_SPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) },
771+ [FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }
772+};
773+
753774 int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
754775 struct netlink_ext_ack *extack)
755776 {
@@ -774,7 +795,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, · 18 unmodified lines
774795 }
775796
776797 err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,
777− ops->policy, extack);
798+ fib_rule_policy, extack);
778799 if (err < 0) {
779800 NL_SET_ERR_MSG(extack, "Error parsing msg");
780801 goto errout;
@@ -882,7 +903,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh, · 101 unmodified lines
882903 }
883904
884905 err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,
885− ops->policy, extack);
906+ fib_rule_policy, extack);
886907 if (err < 0) {
887908 NL_SET_ERR_MSG(extack, "Error parsing msg");
888909 goto errout;
net/decnet/dn_rules.c+0−5
@@ -101,10 +101,6 @@ errout: · 100 unmodified lines
101101 return err;
102102 }
103103
104−static const struct nla_policy dn_fib_rule_policy[FRA_MAX+1] = {
105− FRA_GENERIC_POLICY,
106−};
107−
108104 static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
109105 {
110106 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 = { · 124 unmodified lines
235231 .fill = dn_fib_rule_fill,
236232 .flush_cache = dn_fib_rule_flush_cache,
237233 .nlgroup = RTNLGRP_DECnet_RULE,
238− .policy = dn_fib_rule_policy,
239234 .owner = THIS_MODULE,
240235 .fro_net = &init_net,
241236 };
net/ipv4/fib_rules.c+0−6
@@ -216,11 +216,6 @@ static struct fib_table *fib_empty_table(struct net *net) · 215 unmodified lines
216216 return NULL;
217217 }
218218
219−static const struct nla_policy fib4_rule_policy[FRA_MAX+1] = {
220− FRA_GENERIC_POLICY,
221− [FRA_FLOW] = { .type = NLA_U32 },
222−};
223−
224219 static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
225220 struct fib_rule_hdr *frh,
226221 struct nlattr **tb,
@@ -386,7 +381,6 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = { · 159 unmodified lines
386381 .nlmsg_payload = fib4_rule_nlmsg_payload,
387382 .flush_cache = fib4_rule_flush_cache,
388383 .nlgroup = RTNLGRP_IPV4_RULE,
389− .policy = fib4_rule_policy,
390384 .owner = THIS_MODULE,
391385 };
392386
net/ipv4/ipmr.c+0−5
@@ -195,10 +195,6 @@ static int ipmr_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) · 194 unmodified lines
195195 return 1;
196196 }
197197
198−static const struct nla_policy ipmr_rule_policy[FRA_MAX + 1] = {
199− FRA_GENERIC_POLICY,
200−};
201−
202198 static int ipmr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
203199 struct fib_rule_hdr *frh, struct nlattr **tb,
204200 struct netlink_ext_ack *extack)
@@ -231,7 +227,6 @@ static const struct fib_rules_ops __net_initconst ipmr_rules_ops_template = { · 26 unmodified lines
231227 .compare = ipmr_rule_compare,
232228 .fill = ipmr_rule_fill,
233229 .nlgroup = RTNLGRP_IPV4_RULE,
234− .policy = ipmr_rule_policy,
235230 .owner = THIS_MODULE,
236231 };
237232
net/ipv6/fib6_rules.c+0−5
@@ -340,10 +340,6 @@ INDIRECT_CALLABLE_SCOPE int fib6_rule_match(struct fib_rule *rule, · 339 unmodified lines
340340 return 1;
341341 }
342342
343−static const struct nla_policy fib6_rule_policy[FRA_MAX+1] = {
344− FRA_GENERIC_POLICY,
345−};
346−
347343 static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
348344 struct fib_rule_hdr *frh,
349345 struct nlattr **tb,
@@ -459,7 +455,6 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { · 109 unmodified lines
459455 .fill = fib6_rule_fill,
460456 .nlmsg_payload = fib6_rule_nlmsg_payload,
461457 .nlgroup = RTNLGRP_IPV6_RULE,
462− .policy = fib6_rule_policy,
463458 .owner = THIS_MODULE,
464459 .fro_net = &init_net,
465460 };
net/ipv6/ip6mr.c+0−5
@@ -182,10 +182,6 @@ static int ip6mr_rule_match(struct fib_rule *rule, struct flowi *flp, int flags) · 181 unmodified lines
182182 return 1;
183183 }
184184
185−static const struct nla_policy ip6mr_rule_policy[FRA_MAX + 1] = {
186− FRA_GENERIC_POLICY,
187−};
188−
189185 static int ip6mr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
190186 struct fib_rule_hdr *frh, struct nlattr **tb,
191187 struct netlink_ext_ack *extack)
@@ -218,7 +214,6 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = { · 26 unmodified lines
218214 .compare = ip6mr_rule_compare,
219215 .fill = ip6mr_rule_fill,
220216 .nlgroup = RTNLGRP_IPV6_RULE,
221− .policy = ip6mr_rule_policy,
222217 .owner = THIS_MODULE,
223218 };
224219