[linux-next:master 5404/5655] net/core/filter.c:12578:18: warning: unused variable 'nskb'

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.llvm,dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   bee763d5f341b99cf472afeb508d4988f62a6ca1
commit: f3603df9aebb2a2fe2f745bd71ca38aeca60e6e7 [5404/5655] bpf: Add bpf_icmp_send kfunc
config: i386-buildonly-randconfig-001-20260710 (https://download.01.org/0day-ci/archive/20260711/[email protected]/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260711/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> net/core/filter.c:12578:18: warning: unused variable 'nskb' [-Wunused-variable]
    12578 |         struct sk_buff *nskb;
          |                         ^~~~
   1 warning generated.


vim +/nskb +12578 net/core/filter.c

 12553	
 12554	/**
 12555	 * bpf_icmp_send - Send an ICMP control message
 12556	 * @skb_ctx: Packet that triggered the control message
 12557	 * @type: ICMP type (only ICMP_DEST_UNREACH/ICMPV6_DEST_UNREACH supported)
 12558	 * @code: ICMP code (0-15 except ICMP_FRAG_NEEDED for IPv4, 0-6 for IPv6)
 12559	 *
 12560	 * Sends an ICMP control message in response to the packet. The original packet
 12561	 * is cloned before sending the ICMP message, so the BPF program can still let
 12562	 * the packet pass if desired.
 12563	 *
 12564	 * Currently only ICMP_DEST_UNREACH (IPv4) and ICMPV6_DEST_UNREACH (IPv6) are
 12565	 * supported.
 12566	 *
 12567	 * Return: 0 on success (send attempt), negative error code on failure:
 12568	 *         -EBUSY: Recursion detected
 12569	 *         -EPROTONOSUPPORT: Non-IP protocol
 12570	 *         -EOPNOTSUPP: Unsupported ICMP type
 12571	 *         -EINVAL: Invalid code parameter
 12572	 *         -ENETUNREACH: No usable route/dst for the ICMP reply
 12573	 *         -ENOMEM: Memory allocation failed
 12574	 */
 12575	__bpf_kfunc int bpf_icmp_send(struct __sk_buff *skb_ctx, int type, int code)
 12576	{
 12577		struct sk_buff *skb = (struct sk_buff *)skb_ctx;
 12578		struct sk_buff *nskb;
 12579		struct sock *sk;
 12580	
 12581		sk = skb_to_full_sk(skb);
 12582		if (sk && sk->sk_kern_sock &&
 12583		    (sk->sk_protocol == IPPROTO_ICMP || sk->sk_protocol == IPPROTO_ICMPV6))
 12584			return -EBUSY;
 12585	
 12586		if (!skb_valid_dst(skb))
 12587			return -ENETUNREACH;
 12588	
 12589		switch (skb->protocol) {
 12590	#if IS_ENABLED(CONFIG_INET)
 12591		case htons(ETH_P_IP): {
 12592			if (type != ICMP_DEST_UNREACH)
 12593				return -EOPNOTSUPP;
 12594			if (code < 0 || code > NR_ICMP_UNREACH ||
 12595			    code == ICMP_FRAG_NEEDED) /* needs a valid next-hop MTU */
 12596				return -EINVAL;
 12597	
 12598			nskb = skb_clone(skb, GFP_ATOMIC);
 12599			if (!nskb)
 12600				return -ENOMEM;
 12601	
 12602			memset(IPCB(nskb), 0, sizeof(*IPCB(nskb)));
 12603			icmp_send(nskb, type, code, 0);
 12604			consume_skb(nskb);
 12605			break;
 12606		}
 12607	#endif
 12608	#if IS_ENABLED(CONFIG_IPV6)
 12609		case htons(ETH_P_IPV6):
 12610			if (type != ICMPV6_DEST_UNREACH)
 12611				return -EOPNOTSUPP;
 12612			if (code < 0 || code > ICMPV6_REJECT_ROUTE)
 12613				return -EINVAL;
 12614	
 12615			nskb = skb_clone(skb, GFP_ATOMIC);
 12616			if (!nskb)
 12617				return -ENOMEM;
 12618	
 12619			memset(IP6CB(nskb), 0, sizeof(*IP6CB(nskb)));
 12620			icmpv6_send(nskb, type, code, 0);
 12621			consume_skb(nskb);
 12622			break;
 12623	#endif
 12624		default:
 12625			return -EPROTONOSUPPORT;
 12626		}
 12627	
 12628		return 0;
 12629	}
 12630	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.