mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
netfilter: reject: skip csum verification for protocols that don't support it
Some protocols have other means to verify the payload integrity (AH, ESP, SCTP) while others are incompatible with nf_ip(6)_checksum implementation because checksum is either optional or might be partial (UDPLITE, DCCP, GRE). Because nf_ip(6)_checksum was used to validate the packets, ip(6)tables REJECT rules were not capable to generate ICMP(v6) errors for the protocols mentioned above. This commit also fixes the incorrect pseudo-header protocol used for IPv4 packets that carry other transport protocols than TCP or UDP (pseudo-header used protocol 0 iso the proper value). Signed-off-by: Alin Nastac <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
This commit is contained in:
parent
13f5251fd1
commit
7fc3822536
6 changed files with 39 additions and 12 deletions
|
|
@ -125,13 +125,10 @@ static void nft_reject_br_send_v4_unreach(struct net *net,
|
|||
if (pskb_trim_rcsum(oldskb, ntohs(ip_hdr(oldskb)->tot_len)))
|
||||
return;
|
||||
|
||||
if (ip_hdr(oldskb)->protocol == IPPROTO_TCP ||
|
||||
ip_hdr(oldskb)->protocol == IPPROTO_UDP)
|
||||
proto = ip_hdr(oldskb)->protocol;
|
||||
else
|
||||
proto = 0;
|
||||
proto = ip_hdr(oldskb)->protocol;
|
||||
|
||||
if (!skb_csum_unnecessary(oldskb) &&
|
||||
nf_reject_verify_csum(proto) &&
|
||||
nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), proto))
|
||||
return;
|
||||
|
||||
|
|
@ -234,6 +231,9 @@ static bool reject6_br_csum_ok(struct sk_buff *skb, int hook)
|
|||
if (thoff < 0 || thoff >= skb->len || (fo & htons(~0x7)) != 0)
|
||||
return false;
|
||||
|
||||
if (!nf_reject_verify_csum(proto))
|
||||
return true;
|
||||
|
||||
return nf_ip6_checksum(skb, hook, thoff, proto) == 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue