netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING [Linux 3.16.72]

This Linux kernel change "netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING" is included in the Linux 3.16.72 release. This change is authored by Xin Long < [at]> on Wed Mar 13 16:33:29 2019 +0800. The commit for this change in Linux stable tree is 5d17c80 (patch) which is from upstream commit e166e4f. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream e166e4f.

netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING

commit e166e4fdaced850bee3d5ee12a5740258fb30587 upstream.

Since Commit 21d1196a35f5 ("ipv4: set transport header earlier"),
skb->transport_header has been always set before entering INET
netfilter. This patch is to set skb->transport_header for bridge
before entering INET netfilter by bridge-nf-call-iptables.

It also fixes an issue that sctp_error() couldn't compute a right
csum due to unset skb->transport_header.

Fixes: e6d8b64b34aa ("net: sctp: fix and consolidate SCTP checksumming code")
Reported-by: Li Shuang <>
Suggested-by: Pablo Neira Ayuso <>
Signed-off-by: Xin Long <>
Acked-by: Neil Horman <>
Acked-by: Florian Westphal <>
Signed-off-by: Pablo Neira Ayuso <>
[bwh: Backported to 3.16: adjust filenames, context]
Signed-off-by: Ben Hutchings <>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/bridge/br_netfilter.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 2cf4e30..7ddb8b3 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -659,6 +659,8 @@ static unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
        return NF_DROP;

    skb->protocol = htons(ETH_P_IPV6);
+   skb->transport_header = skb->network_header + sizeof(struct ipv6hdr);

@@ -715,6 +717,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
        return NF_DROP;
    skb->protocol = htons(ETH_P_IP);
+   skb->transport_header = skb->network_header + ip_hdr(skb)->ihl * 4;


Leave a Reply

Your email address will not be published. Required fields are marked *