Commit d8a566be authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

net: fib_rules: consolidate IPv4 and DECnet ->default_pref() functions.

Both functions are equivalent, consolidate them since a following patch
needs a third implementation for multicast routing.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 56115511
...@@ -114,4 +114,5 @@ extern int fib_rules_lookup(struct fib_rules_ops *, ...@@ -114,4 +114,5 @@ extern int fib_rules_lookup(struct fib_rules_ops *,
extern int fib_default_rule_add(struct fib_rules_ops *, extern int fib_default_rule_add(struct fib_rules_ops *,
u32 pref, u32 table, u32 pref, u32 table,
u32 flags); u32 flags);
extern u32 fib_default_rule_pref(struct fib_rules_ops *ops);
#endif #endif
...@@ -39,6 +39,24 @@ int fib_default_rule_add(struct fib_rules_ops *ops, ...@@ -39,6 +39,24 @@ 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)
{
struct list_head *pos;
struct fib_rule *rule;
if (!list_empty(&ops->rules_list)) {
pos = ops->rules_list.next;
if (pos->next != &ops->rules_list) {
rule = list_entry(pos->next, struct fib_rule, list);
if (rule->pref)
return rule->pref - 1;
}
}
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,
u32 pid); u32 pid);
......
...@@ -212,23 +212,6 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb, ...@@ -212,23 +212,6 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
return -ENOBUFS; return -ENOBUFS;
} }
static u32 dn_fib_rule_default_pref(struct fib_rules_ops *ops)
{
struct list_head *pos;
struct fib_rule *rule;
if (!list_empty(&dn_fib_rules_ops->rules_list)) {
pos = dn_fib_rules_ops->rules_list.next;
if (pos->next != &dn_fib_rules_ops->rules_list) {
rule = list_entry(pos->next, struct fib_rule, list);
if (rule->pref)
return rule->pref - 1;
}
}
return 0;
}
static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops) static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops)
{ {
dn_rt_cache_flush(-1); dn_rt_cache_flush(-1);
...@@ -243,7 +226,7 @@ static struct fib_rules_ops dn_fib_rules_ops_template = { ...@@ -243,7 +226,7 @@ static struct fib_rules_ops 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 = dn_fib_rule_default_pref, .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,
......
...@@ -234,23 +234,6 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb, ...@@ -234,23 +234,6 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
return -ENOBUFS; return -ENOBUFS;
} }
static u32 fib4_rule_default_pref(struct fib_rules_ops *ops)
{
struct list_head *pos;
struct fib_rule *rule;
if (!list_empty(&ops->rules_list)) {
pos = ops->rules_list.next;
if (pos->next != &ops->rules_list) {
rule = list_entry(pos->next, struct fib_rule, list);
if (rule->pref)
return rule->pref - 1;
}
}
return 0;
}
static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule) static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
{ {
return nla_total_size(4) /* dst */ return nla_total_size(4) /* dst */
...@@ -272,7 +255,7 @@ static struct fib_rules_ops fib4_rules_ops_template = { ...@@ -272,7 +255,7 @@ static struct fib_rules_ops fib4_rules_ops_template = {
.configure = fib4_rule_configure, .configure = fib4_rule_configure,
.compare = fib4_rule_compare, .compare = fib4_rule_compare,
.fill = fib4_rule_fill, .fill = fib4_rule_fill,
.default_pref = fib4_rule_default_pref, .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,
......
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