diff mbox series

[v2,net-next,2/4] fib: place common code in a helper

Message ID 20211214172731.3591-3-fw@strlen.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series fib: remove suppress indirection, merge nl policies | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 20 this patch: 20
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Florian Westphal Dec. 14, 2021, 5:27 p.m. UTC
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>
---
 v2: IPV6=n ifdef for fib6_rule_suppress helper.

 net/core/fib_rules.c | 62 +++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 32 deletions(-)

Comments

kernel test robot Dec. 15, 2021, 1:32 a.m. UTC | #1
Hi Florian,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Florian-Westphal/fib-remove-suppress-indirection-merge-nl-policies/20211215-013026
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git a3c62a042237d1adeb0290dcb768e17edd6dcd25
config: parisc-randconfig-r001-20211214 (https://download.01.org/0day-ci/archive/20211215/202112150951.hp1nDYE8-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/59837eba57ced3afe03ce1e6d8bd6da39efd398c
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Florian-Westphal/fib-remove-suppress-indirection-merge-nl-policies/20211215-013026
        git checkout 59837eba57ced3afe03ce1e6d8bd6da39efd398c
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=parisc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   hppa-linux-ld: net/core/fib_rules.o: in function `fib_rules_lookup':
>> (.text+0xb98): undefined reference to `free_fib_info'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 52e67f8aa0c5..c763b69eea8c 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -291,6 +291,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)
@@ -304,30 +323,19 @@  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,
 			       int flags,
 			       struct fib_lookup_arg *arg)
 {
+#if IS_ENABLED(CONFIG_IPV6)
 	struct fib6_result *res = arg->result;
 	struct rt6_info *rt = res->rt6;
 	struct net_device *dev = NULL;
@@ -338,23 +346,13 @@  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;
+	}
 
+#endif
 	return false;
-
-suppress_route:
-	ip6_rt_put_flags(rt, flags);
-	return true;
 }
 
 static bool fib_rule_suppress(int family,