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
91 void (*flush_cache)(struct fib_rules_ops *ops);91 void (*flush_cache)(struct fib_rules_ops *ops);
92 92
93 int nlgroup;93 int nlgroup;
94 const struct nla_policy *policy;
95 struct list_head rules_list;94 struct list_head rules_list;
96 struct module *owner;95 struct module *owner;
97 struct net *fro_net;96 struct net *fro_net;
@@ -103,26 +102,6 @@ struct fib_rule_notifier_info { · 5 unmodified lines
103 struct fib_rule *rule;102 struct fib_rule *rule;
104};103};
105 104
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
126static inline void fib_rule_get(struct fib_rule *rule)105static inline void fib_rule_get(struct fib_rule *rule)
127{106{
128 refcount_inc(&rule->refcnt);107 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
750 return 0;750 return 0;
751}751}
752 752
753static 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
753int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,774int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
754 struct netlink_ext_ack *extack)775 struct netlink_ext_ack *extack)
755{776{
@@ -774,7 +795,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, · 18 unmodified lines
774 }795 }
775 796
776 err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,797 err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,
777 ops->policy, extack);798 fib_rule_policy, extack);
778 if (err < 0) {799 if (err < 0) {
779 NL_SET_ERR_MSG(extack, "Error parsing msg");800 NL_SET_ERR_MSG(extack, "Error parsing msg");
780 goto errout;801 goto errout;
@@ -882,7 +903,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh, · 101 unmodified lines
882 }903 }
883 904
884 err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,905 err = nlmsg_parse_deprecated(nlh, sizeof(*frh), tb, FRA_MAX,
885 ops->policy, extack);906 fib_rule_policy, extack);
886 if (err < 0) {907 if (err < 0) {
887 NL_SET_ERR_MSG(extack, "Error parsing msg");908 NL_SET_ERR_MSG(extack, "Error parsing msg");
888 goto errout;909 goto errout;
net/decnet/dn_rules.c+0−5
@@ -101,10 +101,6 @@ errout: · 100 unmodified lines
101 return err;101 return err;
102}102}
103 103
104static const struct nla_policy dn_fib_rule_policy[FRA_MAX+1] = {
105 FRA_GENERIC_POLICY,
106};
107
108static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)104static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
109{105{
110 struct dn_fib_rule *r = (struct dn_fib_rule *)rule;106 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
235 .fill = dn_fib_rule_fill,231 .fill = dn_fib_rule_fill,
236 .flush_cache = dn_fib_rule_flush_cache,232 .flush_cache = dn_fib_rule_flush_cache,
237 .nlgroup = RTNLGRP_DECnet_RULE,233 .nlgroup = RTNLGRP_DECnet_RULE,
238 .policy = dn_fib_rule_policy,
239 .owner = THIS_MODULE,234 .owner = THIS_MODULE,
240 .fro_net = &init_net,235 .fro_net = &init_net,
241};236};
net/ipv4/fib_rules.c+0−6
@@ -216,11 +216,6 @@ static struct fib_table *fib_empty_table(struct net *net) · 215 unmodified lines
216 return NULL;216 return NULL;
217}217}
218 218
219static const struct nla_policy fib4_rule_policy[FRA_MAX+1] = {
220 FRA_GENERIC_POLICY,
221 [FRA_FLOW] = { .type = NLA_U32 },
222};
223
224static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,219static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
225 struct fib_rule_hdr *frh,220 struct fib_rule_hdr *frh,
226 struct nlattr **tb,221 struct nlattr **tb,
@@ -386,7 +381,6 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = { · 159 unmodified lines
386 .nlmsg_payload = fib4_rule_nlmsg_payload,381 .nlmsg_payload = fib4_rule_nlmsg_payload,
387 .flush_cache = fib4_rule_flush_cache,382 .flush_cache = fib4_rule_flush_cache,
388 .nlgroup = RTNLGRP_IPV4_RULE,383 .nlgroup = RTNLGRP_IPV4_RULE,
389 .policy = fib4_rule_policy,
390 .owner = THIS_MODULE,384 .owner = THIS_MODULE,
391};385};
392 386
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
195 return 1;195 return 1;
196}196}
197 197
198static const struct nla_policy ipmr_rule_policy[FRA_MAX + 1] = {
199 FRA_GENERIC_POLICY,
200};
201
202static int ipmr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,198static int ipmr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
203 struct fib_rule_hdr *frh, struct nlattr **tb,199 struct fib_rule_hdr *frh, struct nlattr **tb,
204 struct netlink_ext_ack *extack)200 struct netlink_ext_ack *extack)
@@ -231,7 +227,6 @@ static const struct fib_rules_ops __net_initconst ipmr_rules_ops_template = { · 26 unmodified lines
231 .compare = ipmr_rule_compare,227 .compare = ipmr_rule_compare,
232 .fill = ipmr_rule_fill,228 .fill = ipmr_rule_fill,
233 .nlgroup = RTNLGRP_IPV4_RULE,229 .nlgroup = RTNLGRP_IPV4_RULE,
234 .policy = ipmr_rule_policy,
235 .owner = THIS_MODULE,230 .owner = THIS_MODULE,
236};231};
237 232
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
340 return 1;340 return 1;
341}341}
342 342
343static const struct nla_policy fib6_rule_policy[FRA_MAX+1] = {
344 FRA_GENERIC_POLICY,
345};
346
347static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,343static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
348 struct fib_rule_hdr *frh,344 struct fib_rule_hdr *frh,
349 struct nlattr **tb,345 struct nlattr **tb,
@@ -459,7 +455,6 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { · 109 unmodified lines
459 .fill = fib6_rule_fill,455 .fill = fib6_rule_fill,
460 .nlmsg_payload = fib6_rule_nlmsg_payload,456 .nlmsg_payload = fib6_rule_nlmsg_payload,
461 .nlgroup = RTNLGRP_IPV6_RULE,457 .nlgroup = RTNLGRP_IPV6_RULE,
462 .policy = fib6_rule_policy,
463 .owner = THIS_MODULE,458 .owner = THIS_MODULE,
464 .fro_net = &init_net,459 .fro_net = &init_net,
465};460};
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
182 return 1;182 return 1;
183}183}
184 184
185static const struct nla_policy ip6mr_rule_policy[FRA_MAX + 1] = {
186 FRA_GENERIC_POLICY,
187};
188
189static int ip6mr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,185static int ip6mr_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
190 struct fib_rule_hdr *frh, struct nlattr **tb,186 struct fib_rule_hdr *frh, struct nlattr **tb,
191 struct netlink_ext_ack *extack)187 struct netlink_ext_ack *extack)
@@ -218,7 +214,6 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = { · 26 unmodified lines
218 .compare = ip6mr_rule_compare,214 .compare = ip6mr_rule_compare,
219 .fill = ip6mr_rule_fill,215 .fill = ip6mr_rule_fill,
220 .nlgroup = RTNLGRP_IPV6_RULE,216 .nlgroup = RTNLGRP_IPV6_RULE,
221 .policy = ip6mr_rule_policy,
222 .owner = THIS_MODULE,217 .owner = THIS_MODULE,
223};218};
224 219