* [PATCH net-next] ipvlan: remove ipvlan_ht_addr_lookup()
@ 2026-01-21 21:57 Eric Dumazet
2026-01-22 3:58 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2026-01-21 21:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet, Mahesh Bandewar
ipvlan_ht_addr_lookup() is called four times and not inlined.
Split it to ipvlan_ht_addr_lookup6() and ipvlan_ht_addr_lookup4()
and rework ipvlan_addr_lookup() to call these helpers once,
so that they are (auto)inlined.
After this change, ipvlan_addr_lookup() is faster, and we save
350 bytes of text on x86_64.
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 1/0 up/down: 123/-473 (-350)
Function old new delta
ipvlan_addr_lookup 467 590 +123
__pfx_ipvlan_ht_addr_lookup 16 - -16
ipvlan_ht_addr_lookup 457 - -457
Total: Before=22571833, After=22571483, chg -0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Mahesh Bandewar <maheshb@google.com>
---
drivers/net/ipvlan/ipvlan_core.c | 53 +++++++++++++++++++-------------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 2efa3ba148aa7efed999dc3c06ccbb787eca92e5..dea8b9fead5d32fcccc978bb304a77bb305d2c9e 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -48,11 +48,9 @@ static u8 ipvlan_get_v6_hash(const void *iaddr)
}
#endif
-static u8 ipvlan_get_v4_hash(const void *iaddr)
+static u8 ipvlan_get_v4_hash(__be32 addr)
{
- const struct in_addr *ip4_addr = iaddr;
-
- return jhash_1word((__force u32)ip4_addr->s_addr, ipvlan_jhash_secret) &
+ return jhash_1word((__force u32)addr, ipvlan_jhash_secret) &
IPVLAN_HASH_MASK;
}
@@ -73,16 +71,28 @@ static bool addr_equal(bool is_v6, struct ipvl_addr *addr, const void *iaddr)
return false;
}
-static struct ipvl_addr *ipvlan_ht_addr_lookup(const struct ipvl_port *port,
- const void *iaddr, bool is_v6)
+static struct ipvl_addr *ipvlan_ht_addr_lookup6(const struct ipvl_port *port,
+ const void *iaddr)
{
struct ipvl_addr *addr;
u8 hash;
- hash = is_v6 ? ipvlan_get_v6_hash(iaddr) :
- ipvlan_get_v4_hash(iaddr);
+ hash = ipvlan_get_v6_hash(iaddr);
hlist_for_each_entry_rcu(addr, &port->hlhead[hash], hlnode)
- if (addr_equal(is_v6, addr, iaddr))
+ if (addr_equal(true, addr, iaddr))
+ return addr;
+ return NULL;
+}
+
+static struct ipvl_addr *ipvlan_ht_addr_lookup4(const struct ipvl_port *port,
+ __be32 addr4)
+{
+ struct ipvl_addr *addr;
+ u8 hash;
+
+ hash = ipvlan_get_v4_hash(addr4);
+ hlist_for_each_entry_rcu(addr, &port->hlhead[hash], hlnode)
+ if (addr->atype == IPVL_IPV4 && addr->ip4addr.s_addr == addr4)
return addr;
return NULL;
}
@@ -94,7 +104,7 @@ void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr)
hash = (addr->atype == IPVL_IPV6) ?
ipvlan_get_v6_hash(&addr->ip6addr) :
- ipvlan_get_v4_hash(&addr->ip4addr);
+ ipvlan_get_v4_hash(addr->ip4addr.s_addr);
if (hlist_unhashed(&addr->hlnode))
hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]);
}
@@ -357,21 +367,24 @@ struct ipvl_addr *ipvlan_addr_lookup(struct ipvl_port *port, void *lyr3h,
int addr_type, bool use_dest)
{
struct ipvl_addr *addr = NULL;
+#if IS_ENABLED(CONFIG_IPV6)
+ struct in6_addr *i6addr;
+#endif
+ __be32 addr4;
switch (addr_type) {
#if IS_ENABLED(CONFIG_IPV6)
case IPVL_IPV6: {
struct ipv6hdr *ip6h;
- struct in6_addr *i6addr;
ip6h = (struct ipv6hdr *)lyr3h;
i6addr = use_dest ? &ip6h->daddr : &ip6h->saddr;
- addr = ipvlan_ht_addr_lookup(port, i6addr, true);
+lookup6:
+ addr = ipvlan_ht_addr_lookup6(port, i6addr);
break;
}
case IPVL_ICMPV6: {
struct nd_msg *ndmh;
- struct in6_addr *i6addr;
/* Make sure that the NeighborSolicitation ICMPv6 packets
* are handled to avoid DAD issue.
@@ -379,24 +392,23 @@ struct ipvl_addr *ipvlan_addr_lookup(struct ipvl_port *port, void *lyr3h,
ndmh = (struct nd_msg *)lyr3h;
if (ndmh->icmph.icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
i6addr = &ndmh->target;
- addr = ipvlan_ht_addr_lookup(port, i6addr, true);
+ goto lookup6;
}
break;
}
#endif
case IPVL_IPV4: {
struct iphdr *ip4h;
- __be32 *i4addr;
ip4h = (struct iphdr *)lyr3h;
- i4addr = use_dest ? &ip4h->daddr : &ip4h->saddr;
- addr = ipvlan_ht_addr_lookup(port, i4addr, false);
+ addr4 = use_dest ? ip4h->daddr : ip4h->saddr;
+lookup4:
+ addr = ipvlan_ht_addr_lookup4(port, addr4);
break;
}
case IPVL_ARP: {
struct arphdr *arph;
unsigned char *arp_ptr;
- __be32 dip;
arph = (struct arphdr *)lyr3h;
arp_ptr = (unsigned char *)(arph + 1);
@@ -405,9 +417,8 @@ struct ipvl_addr *ipvlan_addr_lookup(struct ipvl_port *port, void *lyr3h,
else
arp_ptr += port->dev->addr_len;
- memcpy(&dip, arp_ptr, 4);
- addr = ipvlan_ht_addr_lookup(port, &dip, false);
- break;
+ addr4 = get_unaligned((__be32 *)arp_ptr);
+ goto lookup4;
}
}
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ipvlan: remove ipvlan_ht_addr_lookup()
2026-01-21 21:57 [PATCH net-next] ipvlan: remove ipvlan_ht_addr_lookup() Eric Dumazet
@ 2026-01-22 3:58 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-01-22 3:58 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: oe-kbuild-all, Simon Horman, netdev, eric.dumazet, Eric Dumazet,
Mahesh Bandewar
Hi Eric,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/ipvlan-remove-ipvlan_ht_addr_lookup/20260122-060038
base: net-next/main
patch link: https://lore.kernel.org/r/20260121215728.560645-1-edumazet%40google.com
patch subject: [PATCH net-next] ipvlan: remove ipvlan_ht_addr_lookup()
config: i386-randconfig-054-20260122 (https://download.01.org/0day-ci/archive/20260122/202601221121.jJSK4gxB-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260122/202601221121.jJSK4gxB-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601221121.jJSK4gxB-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/net/ipvlan/ipvlan_core.c:74:26: warning: 'ipvlan_ht_addr_lookup6' defined but not used [-Wunused-function]
74 | static struct ipvl_addr *ipvlan_ht_addr_lookup6(const struct ipvl_port *port,
| ^~~~~~~~~~~~~~~~~~~~~~
vim +/ipvlan_ht_addr_lookup6 +74 drivers/net/ipvlan/ipvlan_core.c
73
> 74 static struct ipvl_addr *ipvlan_ht_addr_lookup6(const struct ipvl_port *port,
75 const void *iaddr)
76 {
77 struct ipvl_addr *addr;
78 u8 hash;
79
80 hash = ipvlan_get_v6_hash(iaddr);
81 hlist_for_each_entry_rcu(addr, &port->hlhead[hash], hlnode)
82 if (addr_equal(true, addr, iaddr))
83 return addr;
84 return NULL;
85 }
86
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-22 3:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 21:57 [PATCH net-next] ipvlan: remove ipvlan_ht_addr_lookup() Eric Dumazet
2026-01-22 3:58 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox