Commit f53de1e9 authored by Phil Sutter's avatar Phil Sutter Committed by David S. Miller

net: ipv6: use common fib_default_rule_pref

This switches IPv6 policy routing to use the shared
fib_default_rule_pref() function of IPv4 and DECnet. It is also used in
multicast routing for IPv4 as well as IPv6.

The motivation for this patch is a complaint about iproute2 behaving
inconsistent between IPv4 and IPv6 when adding policy rules: Formerly,
IPv6 rules were assigned a fixed priority of 0x3FFF whereas for IPv4 the
assigned priority value was decreased with each rule added.

Since then all users of the default_pref field have been converted to
assign the generic function fib_default_rule_pref(), fib_nl_newrule()
may just use it directly instead. Therefore get rid of the function
pointer altogether and make fib_default_rule_pref() static, as it's not
used outside fib_rules.c anymore.
Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 444c5f92
...@@ -66,7 +66,6 @@ struct fib_rules_ops { ...@@ -66,7 +66,6 @@ struct fib_rules_ops {
struct nlattr **); struct nlattr **);
int (*fill)(struct fib_rule *, struct sk_buff *, int (*fill)(struct fib_rule *, struct sk_buff *,
struct fib_rule_hdr *); struct fib_rule_hdr *);
u32 (*default_pref)(struct fib_rules_ops *ops);
size_t (*nlmsg_payload)(struct fib_rule *); size_t (*nlmsg_payload)(struct fib_rule *);
/* Called after modifications to the rules set, must flush /* Called after modifications to the rules set, must flush
...@@ -118,5 +117,4 @@ int fib_rules_lookup(struct fib_rules_ops *, struct flowi *, int flags, ...@@ -118,5 +117,4 @@ int fib_rules_lookup(struct fib_rules_ops *, struct flowi *, int flags,
struct fib_lookup_arg *); struct fib_lookup_arg *);
int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table, int fib_default_rule_add(struct fib_rules_ops *, u32 pref, u32 table,
u32 flags); u32 flags);
u32 fib_default_rule_pref(struct fib_rules_ops *ops);
#endif #endif
...@@ -44,7 +44,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops, ...@@ -44,7 +44,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
} }
EXPORT_SYMBOL(fib_default_rule_add); EXPORT_SYMBOL(fib_default_rule_add);
u32 fib_default_rule_pref(struct fib_rules_ops *ops) static u32 fib_default_rule_pref(struct fib_rules_ops *ops)
{ {
struct list_head *pos; struct list_head *pos;
struct fib_rule *rule; struct fib_rule *rule;
...@@ -60,7 +60,6 @@ u32 fib_default_rule_pref(struct fib_rules_ops *ops) ...@@ -60,7 +60,6 @@ u32 fib_default_rule_pref(struct fib_rules_ops *ops)
return 0; return 0;
} }
EXPORT_SYMBOL(fib_default_rule_pref);
static void notify_rule_change(int event, struct fib_rule *rule, static void notify_rule_change(int event, struct fib_rule *rule,
struct fib_rules_ops *ops, struct nlmsghdr *nlh, struct fib_rules_ops *ops, struct nlmsghdr *nlh,
...@@ -299,8 +298,8 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh) ...@@ -299,8 +298,8 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
} }
rule->fr_net = net; rule->fr_net = net;
if (tb[FRA_PRIORITY]) rule->pref = tb[FRA_PRIORITY] ? nla_get_u32(tb[FRA_PRIORITY])
rule->pref = nla_get_u32(tb[FRA_PRIORITY]); : fib_default_rule_pref(ops);
if (tb[FRA_IIFNAME]) { if (tb[FRA_IIFNAME]) {
struct net_device *dev; struct net_device *dev;
...@@ -350,9 +349,6 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh) ...@@ -350,9 +349,6 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
else else
rule->suppress_ifgroup = -1; rule->suppress_ifgroup = -1;
if (!tb[FRA_PRIORITY] && ops->default_pref)
rule->pref = ops->default_pref(ops);
err = -EINVAL; err = -EINVAL;
if (tb[FRA_GOTO]) { if (tb[FRA_GOTO]) {
if (rule->action != FR_ACT_GOTO) if (rule->action != FR_ACT_GOTO)
......
...@@ -229,7 +229,6 @@ static const struct fib_rules_ops __net_initconst dn_fib_rules_ops_template = { ...@@ -229,7 +229,6 @@ static const struct fib_rules_ops __net_initconst dn_fib_rules_ops_template = {
.configure = dn_fib_rule_configure, .configure = dn_fib_rule_configure,
.compare = dn_fib_rule_compare, .compare = dn_fib_rule_compare,
.fill = dn_fib_rule_fill, .fill = dn_fib_rule_fill,
.default_pref = fib_default_rule_pref,
.flush_cache = dn_fib_rule_flush_cache, .flush_cache = dn_fib_rule_flush_cache,
.nlgroup = RTNLGRP_DECnet_RULE, .nlgroup = RTNLGRP_DECnet_RULE,
.policy = dn_fib_rule_policy, .policy = dn_fib_rule_policy,
......
...@@ -318,7 +318,6 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = { ...@@ -318,7 +318,6 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = {
.delete = fib4_rule_delete, .delete = fib4_rule_delete,
.compare = fib4_rule_compare, .compare = fib4_rule_compare,
.fill = fib4_rule_fill, .fill = fib4_rule_fill,
.default_pref = fib_default_rule_pref,
.nlmsg_payload = fib4_rule_nlmsg_payload, .nlmsg_payload = fib4_rule_nlmsg_payload,
.flush_cache = fib4_rule_flush_cache, .flush_cache = fib4_rule_flush_cache,
.nlgroup = RTNLGRP_IPV4_RULE, .nlgroup = RTNLGRP_IPV4_RULE,
......
...@@ -233,7 +233,6 @@ static const struct fib_rules_ops __net_initconst ipmr_rules_ops_template = { ...@@ -233,7 +233,6 @@ static const struct fib_rules_ops __net_initconst ipmr_rules_ops_template = {
.match = ipmr_rule_match, .match = ipmr_rule_match,
.configure = ipmr_rule_configure, .configure = ipmr_rule_configure,
.compare = ipmr_rule_compare, .compare = ipmr_rule_compare,
.default_pref = fib_default_rule_pref,
.fill = ipmr_rule_fill, .fill = ipmr_rule_fill,
.nlgroup = RTNLGRP_IPV4_RULE, .nlgroup = RTNLGRP_IPV4_RULE,
.policy = ipmr_rule_policy, .policy = ipmr_rule_policy,
......
...@@ -258,11 +258,6 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb, ...@@ -258,11 +258,6 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
return -ENOBUFS; return -ENOBUFS;
} }
static u32 fib6_rule_default_pref(struct fib_rules_ops *ops)
{
return 0x3FFF;
}
static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule) static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
{ {
return nla_total_size(16) /* dst */ return nla_total_size(16) /* dst */
...@@ -279,7 +274,6 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { ...@@ -279,7 +274,6 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = {
.configure = fib6_rule_configure, .configure = fib6_rule_configure,
.compare = fib6_rule_compare, .compare = fib6_rule_compare,
.fill = fib6_rule_fill, .fill = fib6_rule_fill,
.default_pref = fib6_rule_default_pref,
.nlmsg_payload = fib6_rule_nlmsg_payload, .nlmsg_payload = fib6_rule_nlmsg_payload,
.nlgroup = RTNLGRP_IPV6_RULE, .nlgroup = RTNLGRP_IPV6_RULE,
.policy = fib6_rule_policy, .policy = fib6_rule_policy,
......
...@@ -217,7 +217,6 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = { ...@@ -217,7 +217,6 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = {
.match = ip6mr_rule_match, .match = ip6mr_rule_match,
.configure = ip6mr_rule_configure, .configure = ip6mr_rule_configure,
.compare = ip6mr_rule_compare, .compare = ip6mr_rule_compare,
.default_pref = fib_default_rule_pref,
.fill = ip6mr_rule_fill, .fill = ip6mr_rule_fill,
.nlgroup = RTNLGRP_IPV6_RULE, .nlgroup = RTNLGRP_IPV6_RULE,
.policy = ip6mr_rule_policy, .policy = ip6mr_rule_policy,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment