Skip to content

Commit f852c12

Browse files
IVandeVeirecarlescufi
authored andcommitted
net: ip: igmp: Fix wrong header length
The header length of the net ip packet was calculated using only the net_pkt_ip_hdr_len function. The correct header length should be calculated by adding net_pkt_ip_hdr_len and net_pkt_ipv4_opts_len. This resulted in an incorrect IGMP version type in case of IGMPv2 message (when IGMPv3 was enabled). The IGMP message was not parsed correctly and therefore dropped. Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
1 parent 3c82cd6 commit f852c12

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

subsys/net/ip/igmp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ enum net_verdict net_ipv4_igmp_input(struct net_pkt *pkt, struct net_ipv4_hdr *i
424424
struct net_ipv4_igmp_v2_query *igmpv2_hdr;
425425
enum igmp_version version;
426426
int ret;
427-
int igmp_buf_len = pkt->buffer->len - net_pkt_ip_hdr_len(pkt);
427+
int igmp_buf_len =
428+
pkt->buffer->len - (net_pkt_ip_hdr_len(pkt) + net_pkt_ipv4_opts_len(pkt));
428429

429430
/* Detect IGMP type (RFC 3376 ch 7.1) */
430431
if (igmp_buf_len == 8) {

0 commit comments

Comments
 (0)