@@ -124,16 +124,19 @@ static int mld_create_packet(struct net_pkt *pkt, uint16_t count)
124124
125125static int mld_send (struct net_pkt * pkt )
126126{
127+ int ret ;
128+
127129 net_pkt_cursor_init (pkt );
128130 net_ipv6_finalize (pkt , IPPROTO_ICMPV6 );
129131
130- if (net_send_data (pkt ) < 0 ) {
132+ ret = net_send_data (pkt );
133+ if (ret < 0 ) {
131134 net_stats_update_icmp_drop (net_pkt_iface (pkt ));
132135 net_stats_update_ipv6_mld_drop (net_pkt_iface (pkt ));
133136
134137 net_pkt_unref (pkt );
135138
136- return -1 ;
139+ return ret ;
137140 }
138141
139142 net_stats_update_icmp_sent (net_pkt_iface (pkt ));
@@ -251,11 +254,12 @@ int net_ipv6_mld_leave(struct net_if *iface, const struct in6_addr *addr)
251254 return ret ;
252255}
253256
254- static void send_mld_report (struct net_if * iface )
257+ static int send_mld_report (struct net_if * iface )
255258{
256259 struct net_if_ipv6 * ipv6 = iface -> config .ip .ipv6 ;
257260 struct net_pkt * pkt ;
258261 int i , count = 0 ;
262+ int ret ;
259263
260264 NET_ASSERT (ipv6 );
261265
@@ -273,10 +277,11 @@ static void send_mld_report(struct net_if *iface)
273277 AF_INET6 , IPPROTO_ICMPV6 ,
274278 PKT_WAIT_TIME );
275279 if (!pkt ) {
276- return ;
280+ return - ENOBUFS ;
277281 }
278282
279- if (mld_create_packet (pkt , count )) {
283+ ret = mld_create_packet (pkt , count );
284+ if (ret < 0 ) {
280285 goto drop ;
281286 }
282287
@@ -285,18 +290,22 @@ static void send_mld_report(struct net_if *iface)
285290 continue ;
286291 }
287292
288- if (!mld_create (pkt , & ipv6 -> mcast [i ].address .in6_addr ,
289- NET_IPV6_MLDv2_MODE_IS_EXCLUDE , 0 )) {
293+ ret = mld_create (pkt , & ipv6 -> mcast [i ].address .in6_addr ,
294+ NET_IPV6_MLDv2_MODE_IS_EXCLUDE , 0 );
295+ if (ret < 0 ) {
290296 goto drop ;
291297 }
292298 }
293299
294- if (!mld_send (pkt )) {
295- return ;
300+ ret = mld_send (pkt );
301+ if (ret < 0 ) {
302+ return ret ;
296303 }
297304
298305drop :
299306 net_pkt_unref (pkt );
307+
308+ return ret ;
300309}
301310
302311#define dbg_addr (action , pkt_str , src , dst ) \
@@ -361,9 +370,7 @@ static int handle_mld_query(struct net_icmp_ctx *ctx,
361370 goto drop ;
362371 }
363372
364- send_mld_report (net_pkt_iface (pkt ));
365-
366- return 0 ;
373+ return send_mld_report (net_pkt_iface (pkt ));
367374
368375drop :
369376 net_stats_update_ipv6_mld_drop (net_pkt_iface (pkt ));
0 commit comments