Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5e693ab authored by Gao Feng's avatar Gao Feng Committed by Pablo Neira Ayuso
Browse files

netfilter: conntrack: Only need first 4 bytes to get l4proto ports



We only need first 4 bytes instead of 8 bytes to get the ports of
tcp/udp/dccp/sctp/udplite in their pkt_to_tuple function.

Signed-off-by: default avatarGao Feng <fgao@ikuai8.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent f08aff44
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -402,7 +402,8 @@ static bool dccp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
{
	struct dccp_hdr _hdr, *dh;

	dh = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
	/* Actually only need first 4 bytes to get ports. */
	dh = skb_header_pointer(skb, dataoff, 4, &_hdr);
	if (dh == NULL)
		return false;

+2 −2
Original line number Diff line number Diff line
@@ -161,8 +161,8 @@ static bool sctp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
	const struct sctphdr *hp;
	struct sctphdr _hdr;

	/* Actually only need first 8 bytes. */
	hp = skb_header_pointer(skb, dataoff, 8, &_hdr);
	/* Actually only need first 4 bytes to get ports. */
	hp = skb_header_pointer(skb, dataoff, 4, &_hdr);
	if (hp == NULL)
		return false;

+2 −2
Original line number Diff line number Diff line
@@ -282,8 +282,8 @@ static bool tcp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
	const struct tcphdr *hp;
	struct tcphdr _hdr;

	/* Actually only need first 8 bytes. */
	hp = skb_header_pointer(skb, dataoff, 8, &_hdr);
	/* Actually only need first 4 bytes to get ports. */
	hp = skb_header_pointer(skb, dataoff, 4, &_hdr);
	if (hp == NULL)
		return false;

+2 −2
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ static bool udp_pkt_to_tuple(const struct sk_buff *skb,
	const struct udphdr *hp;
	struct udphdr _hdr;

	/* Actually only need first 8 bytes. */
	hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
	/* Actually only need first 4 bytes to get ports. */
	hp = skb_header_pointer(skb, dataoff, 4, &_hdr);
	if (hp == NULL)
		return false;

+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ static bool udplite_pkt_to_tuple(const struct sk_buff *skb,
	const struct udphdr *hp;
	struct udphdr _hdr;

	hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
	/* Actually only need first 4 bytes to get ports. */
	hp = skb_header_pointer(skb, dataoff, 4, &_hdr);
	if (hp == NULL)
		return false;