summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-04-09 08:52:37 +0000
committerJakub Kicinski <kuba@kernel.org>2026-04-12 09:05:54 -0700
commit441ec8b5bdcc77f084b63800fd39404d9fc7c9f5 (patch)
tree0c733313d7f5690c940e7c4ff6f4dc4199881602
parentb258cba1e05df758e4e99a0e374da3e044618475 (diff)
downloadlwn-441ec8b5bdcc77f084b63800fd39404d9fc7c9f5.tar.gz
lwn-441ec8b5bdcc77f084b63800fd39404d9fc7c9f5.zip
ipvlan: ipvlan_handle_mode_l2() refactoring
Reduce indentation level, and add a likely() clause as we expect to process more unicast packets than multicast ones. No functional change, this eases the following patch review. Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260409085238.1122947-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/ipvlan/ipvlan_core.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 0b493a8aa338..214fd299a5aa 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -744,34 +744,32 @@ out:
static rx_handler_result_t ipvlan_handle_mode_l2(struct sk_buff **pskb,
struct ipvl_port *port)
{
- struct sk_buff *skb = *pskb;
+ struct sk_buff *nskb, *skb = *pskb;
struct ethhdr *eth = eth_hdr(skb);
- rx_handler_result_t ret = RX_HANDLER_PASS;
if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
return RX_HANDLER_PASS;
- if (is_multicast_ether_addr(eth->h_dest)) {
- if (ipvlan_external_frame(skb, port)) {
- struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
+ /* Perform like l3 mode for non-multicast packet */
+ if (likely(!is_multicast_ether_addr(eth->h_dest)))
+ return ipvlan_handle_mode_l3(pskb, port);
- /* External frames are queued for device local
- * distribution, but a copy is given to master
- * straight away to avoid sending duplicates later
- * when work-queue processes this frame. This is
- * achieved by returning RX_HANDLER_PASS.
- */
- if (nskb) {
- ipvlan_skb_crossing_ns(nskb, NULL);
- ipvlan_multicast_enqueue(port, nskb, false);
- }
- }
- } else {
- /* Perform like l3 mode for non-multicast packet */
- ret = ipvlan_handle_mode_l3(pskb, port);
+ /* External frames are queued for device local
+ * distribution, but a copy is given to master
+ * straight away to avoid sending duplicates later
+ * when work-queue processes this frame.
+ * This is achieved by returning RX_HANDLER_PASS.
+ */
+ if (!ipvlan_external_frame(skb, port))
+ return RX_HANDLER_PASS;
+
+ nskb = skb_clone(skb, GFP_ATOMIC);
+ if (nskb) {
+ ipvlan_skb_crossing_ns(nskb, NULL);
+ ipvlan_multicast_enqueue(port, nskb, false);
}
- return ret;
+ return RX_HANDLER_PASS;
}
rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb)