@@ -289,6 +289,25 @@ static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
return (rule->flags & FIB_RULE_INVERT) ? !ret : ret;
}
+static bool fib_rule_should_suppress(const struct fib_rule *rule,
+ const struct net_device *dev,
+ int prefixlen)
+{
+ /* do not accept result if the route does
+ * not meet the required prefix length
+ */
+ if (prefixlen <= rule->suppress_prefixlen)
+ return true;
+
+ /* do not accept result if the route uses a device
+ * belonging to a forbidden interface group
+ */
+ if (rule->suppress_ifgroup != -1 && dev && dev->group == rule->suppress_ifgroup)
+ return true;
+
+ return false;
+}
+
static bool fib4_rule_suppress(struct fib_rule *rule,
int flags,
struct fib_lookup_arg *arg)
@@ -302,24 +321,12 @@ static bool fib4_rule_suppress(struct fib_rule *rule,
dev = nhc->nhc_dev;
}
- /* do not accept result if the route does
- * not meet the required prefix length
- */
- if (result->prefixlen <= rule->suppress_prefixlen)
- goto suppress_route;
-
- /* do not accept result if the route uses a device
- * belonging to a forbidden interface group
- */
- if (rule->suppress_ifgroup != -1 && dev && dev->group == rule->suppress_ifgroup)
- goto suppress_route;
-
+ if (fib_rule_should_suppress(rule, dev, result->prefixlen)) {
+ if (!(arg->flags & FIB_LOOKUP_NOREF))
+ fib_info_put(result->fi);
+ return true;
+ }
return false;
-
-suppress_route:
- if (!(arg->flags & FIB_LOOKUP_NOREF))
- fib_info_put(result->fi);
- return true;
}
static bool fib6_rule_suppress(struct fib_rule *rule,
@@ -336,23 +343,12 @@ static bool fib6_rule_suppress(struct fib_rule *rule,
if (rt->rt6i_idev)
dev = rt->rt6i_idev->dev;
- /* do not accept result if the route does
- * not meet the required prefix length
- */
- if (rt->rt6i_dst.plen <= rule->suppress_prefixlen)
- goto suppress_route;
-
- /* do not accept result if the route uses a device
- * belonging to a forbidden interface group
- */
- if (rule->suppress_ifgroup != -1 && dev && dev->group == rule->suppress_ifgroup)
- goto suppress_route;
+ if (fib_rule_should_suppress(rule, dev, rt->rt6i_dst.plen)) {
+ ip6_rt_put_flags(rt, flags);
+ return true;
+ }
return false;
-
-suppress_route:
- ip6_rt_put_flags(rt, flags);
- return true;
}
static bool fib_rule_suppress(int family,
After moving the ipv4/ipv6 helpers to the core, there is some overlapping code that can be collapsed into a helper. This change has no effect on generated code. Signed-off-by: Florian Westphal <fw@strlen.de> --- net/core/fib_rules.c | 60 +++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 32 deletions(-)