]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/ipv4/fib_rules.c
net: add SNMP counters tracking incoming ECN bits
[karo-tx-linux.git] / net / ipv4 / fib_rules.c
index 26aa65d1fce49dfeaa45cbc02046218b5bc70453..523be38e37de82736a28bc9aa229f1911d2eaa31 100644 (file)
@@ -101,6 +101,30 @@ errout:
        return err;
 }
 
+static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
+{
+       struct fib_result *result = (struct fib_result *) arg->result;
+       struct net_device *dev = result->fi->fib_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;
+
+       return false;
+
+suppress_route:
+       if (!(arg->flags & FIB_LOOKUP_NOREF))
+               fib_info_put(result->fi);
+       return true;
+}
 
 static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
 {
@@ -267,6 +291,7 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = {
        .rule_size      = sizeof(struct fib4_rule),
        .addr_size      = sizeof(u32),
        .action         = fib4_rule_action,
+       .suppress       = fib4_rule_suppress,
        .match          = fib4_rule_match,
        .configure      = fib4_rule_configure,
        .delete         = fib4_rule_delete,