aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/fib_rules.h1
-rw-r--r--net/core/fib_rules.c18
-rw-r--r--net/decnet/dn_rules.c19
-rw-r--r--net/ipv4/fib_rules.c19
4 files changed, 21 insertions, 36 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index c49086d2bc7d..52bd9e6c9141 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -114,4 +114,5 @@ extern int fib_rules_lookup(struct fib_rules_ops *,
114extern int fib_default_rule_add(struct fib_rules_ops *, 114extern int fib_default_rule_add(struct fib_rules_ops *,
115 u32 pref, u32 table, 115 u32 pref, u32 table,
116 u32 flags); 116 u32 flags);
117extern u32 fib_default_rule_pref(struct fib_rules_ops *ops);
117#endif 118#endif
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 05cce4ec84dd..1eb32276be77 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -39,6 +39,24 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
39} 39}
40EXPORT_SYMBOL(fib_default_rule_add); 40EXPORT_SYMBOL(fib_default_rule_add);
41 41
42u32 fib_default_rule_pref(struct fib_rules_ops *ops)
43{
44 struct list_head *pos;
45 struct fib_rule *rule;
46
47 if (!list_empty(&ops->rules_list)) {
48 pos = ops->rules_list.next;
49 if (pos->next != &ops->rules_list) {
50 rule = list_entry(pos->next, struct fib_rule, list);
51 if (rule->pref)
52 return rule->pref - 1;
53 }
54 }
55
56 return 0;
57}
58EXPORT_SYMBOL(fib_default_rule_pref);
59
42static void notify_rule_change(int event, struct fib_rule *rule, 60static void notify_rule_change(int event, struct fib_rule *rule,
43 struct fib_rules_ops *ops, struct nlmsghdr *nlh, 61 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
44 u32 pid); 62 u32 pid);
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 7466c546f286..2d14093a2c3a 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -212,23 +212,6 @@ nla_put_failure:
212 return -ENOBUFS; 212 return -ENOBUFS;
213} 213}
214 214
215static u32 dn_fib_rule_default_pref(struct fib_rules_ops *ops)
216{
217 struct list_head *pos;
218 struct fib_rule *rule;
219
220 if (!list_empty(&dn_fib_rules_ops->rules_list)) {
221 pos = dn_fib_rules_ops->rules_list.next;
222 if (pos->next != &dn_fib_rules_ops->rules_list) {
223 rule = list_entry(pos->next, struct fib_rule, list);
224 if (rule->pref)
225 return rule->pref - 1;
226 }
227 }
228
229 return 0;
230}
231
232static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops) 215static void dn_fib_rule_flush_cache(struct fib_rules_ops *ops)
233{ 216{
234 dn_rt_cache_flush(-1); 217 dn_rt_cache_flush(-1);
@@ -243,7 +226,7 @@ static struct fib_rules_ops dn_fib_rules_ops_template = {
243 .configure = dn_fib_rule_configure, 226 .configure = dn_fib_rule_configure,
244 .compare = dn_fib_rule_compare, 227 .compare = dn_fib_rule_compare,
245 .fill = dn_fib_rule_fill, 228 .fill = dn_fib_rule_fill,
246 .default_pref = dn_fib_rule_default_pref, 229 .default_pref = fib_default_rule_pref,
247 .flush_cache = dn_fib_rule_flush_cache, 230 .flush_cache = dn_fib_rule_flush_cache,
248 .nlgroup = RTNLGRP_DECnet_RULE, 231 .nlgroup = RTNLGRP_DECnet_RULE,
249 .policy = dn_fib_rule_policy, 232 .policy = dn_fib_rule_policy,
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index ca2d07b1c706..73b67849c5b9 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -234,23 +234,6 @@ nla_put_failure:
234 return -ENOBUFS; 234 return -ENOBUFS;
235} 235}
236 236
237static u32 fib4_rule_default_pref(struct fib_rules_ops *ops)
238{
239 struct list_head *pos;
240 struct fib_rule *rule;
241
242 if (!list_empty(&ops->rules_list)) {
243 pos = ops->rules_list.next;
244 if (pos->next != &ops->rules_list) {
245 rule = list_entry(pos->next, struct fib_rule, list);
246 if (rule->pref)
247 return rule->pref - 1;
248 }
249 }
250
251 return 0;
252}
253
254static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule) 237static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
255{ 238{
256 return nla_total_size(4) /* dst */ 239 return nla_total_size(4) /* dst */
@@ -272,7 +255,7 @@ static struct fib_rules_ops fib4_rules_ops_template = {
272 .configure = fib4_rule_configure, 255 .configure = fib4_rule_configure,
273 .compare = fib4_rule_compare, 256 .compare = fib4_rule_compare,
274 .fill = fib4_rule_fill, 257 .fill = fib4_rule_fill,
275 .default_pref = fib4_rule_default_pref, 258 .default_pref = fib_default_rule_pref,
276 .nlmsg_payload = fib4_rule_nlmsg_payload, 259 .nlmsg_payload = fib4_rule_nlmsg_payload,
277 .flush_cache = fib4_rule_flush_cache, 260 .flush_cache = fib4_rule_flush_cache,
278 .nlgroup = RTNLGRP_IPV4_RULE, 261 .nlgroup = RTNLGRP_IPV4_RULE,