-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter/IPVS updates for net-next The following patchset contains another batch with Netfilter/IPVS updates for net-next, they are: 1) Add abstracted ICMP codes to the nf_tables reject expression. We introduce four reasons to reject using ICMP that overlap in IPv4 and IPv6 from the semantic point of view. This should simplify the maintainance of dual stack rule-sets through the inet table. 2) Move nf_send_reset() functions from header files to per-family nf_reject modules, suggested by Patrick McHardy. 3) We have to use IS_ENABLED(CONFIG_BRIDGE_NETFILTER) everywhere in the code now that br_netfilter can be modularized. Convert remaining spots in the network stack code. 4) Use rcu_barrier() in the nf_tables module removal path to ensure that we don't leave object that are still pending to be released via call_rcu (that may likely result in a crash). 5) Remove incomplete arch 32/64 compat from nft_compat. The original (bad) idea was to probe the word size based on the xtables match/target info size, but this assumption is wrong when you have to dump the information back to userspace. 6) Allow to filter from prerouting and postrouting in the nf_tables bridge. In order to emulate the ebtables NAT chains (which are actually simple filter chains with no special semantics), we have support filtering from this hooks too. 7) Add explicit module dependency between xt_physdev and br_netfilter. This provides a way to detect if the user needs br_netfilter from the configuration path. This should reduce the breakage of the br_netfilter modularization. 8) Cleanup coding style in ip_vs.h, from Simon Horman. 9) Fix crash in the recently added nf_tables masq expression. We have to register/unregister the notifiers to clean up the conntrack table entries from the module init/exit path, not from the rule addition / deletion path. From Arturo Borrero. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
32 changed files
with
699 additions
and
440 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef _BR_NETFILTER_H_ | ||
#define _BR_NETFILTER_H_ | ||
|
||
void br_netfilter_enable(void); | ||
|
||
#endif /* _BR_NETFILTER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,13 @@ | ||
#ifndef _IPV4_NF_REJECT_H | ||
#define _IPV4_NF_REJECT_H | ||
|
||
#include <net/ip.h> | ||
#include <net/tcp.h> | ||
#include <net/route.h> | ||
#include <net/dst.h> | ||
#include <net/icmp.h> | ||
|
||
static inline void nf_send_unreach(struct sk_buff *skb_in, int code) | ||
{ | ||
icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0); | ||
} | ||
|
||
/* Send RST reply */ | ||
static void nf_send_reset(struct sk_buff *oldskb, int hook) | ||
{ | ||
struct sk_buff *nskb; | ||
const struct iphdr *oiph; | ||
struct iphdr *niph; | ||
const struct tcphdr *oth; | ||
struct tcphdr _otcph, *tcph; | ||
|
||
/* IP header checks: fragment. */ | ||
if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET)) | ||
return; | ||
|
||
oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb), | ||
sizeof(_otcph), &_otcph); | ||
if (oth == NULL) | ||
return; | ||
|
||
/* No RST for RST. */ | ||
if (oth->rst) | ||
return; | ||
|
||
if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) | ||
return; | ||
|
||
/* Check checksum */ | ||
if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP)) | ||
return; | ||
oiph = ip_hdr(oldskb); | ||
|
||
nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) + | ||
LL_MAX_HEADER, GFP_ATOMIC); | ||
if (!nskb) | ||
return; | ||
|
||
skb_reserve(nskb, LL_MAX_HEADER); | ||
|
||
skb_reset_network_header(nskb); | ||
niph = (struct iphdr *)skb_put(nskb, sizeof(struct iphdr)); | ||
niph->version = 4; | ||
niph->ihl = sizeof(struct iphdr) / 4; | ||
niph->tos = 0; | ||
niph->id = 0; | ||
niph->frag_off = htons(IP_DF); | ||
niph->protocol = IPPROTO_TCP; | ||
niph->check = 0; | ||
niph->saddr = oiph->daddr; | ||
niph->daddr = oiph->saddr; | ||
|
||
skb_reset_transport_header(nskb); | ||
tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr)); | ||
memset(tcph, 0, sizeof(*tcph)); | ||
tcph->source = oth->dest; | ||
tcph->dest = oth->source; | ||
tcph->doff = sizeof(struct tcphdr) / 4; | ||
|
||
if (oth->ack) | ||
tcph->seq = oth->ack_seq; | ||
else { | ||
tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin + | ||
oldskb->len - ip_hdrlen(oldskb) - | ||
(oth->doff << 2)); | ||
tcph->ack = 1; | ||
} | ||
|
||
tcph->rst = 1; | ||
tcph->check = ~tcp_v4_check(sizeof(struct tcphdr), niph->saddr, | ||
niph->daddr, 0); | ||
nskb->ip_summed = CHECKSUM_PARTIAL; | ||
nskb->csum_start = (unsigned char *)tcph - nskb->head; | ||
nskb->csum_offset = offsetof(struct tcphdr, check); | ||
|
||
/* ip_route_me_harder expects skb->dst to be set */ | ||
skb_dst_set_noref(nskb, skb_dst(oldskb)); | ||
|
||
nskb->protocol = htons(ETH_P_IP); | ||
if (ip_route_me_harder(nskb, RTN_UNSPEC)) | ||
goto free_nskb; | ||
|
||
niph->ttl = ip4_dst_hoplimit(skb_dst(nskb)); | ||
|
||
/* "Never happens" */ | ||
if (nskb->len > dst_mtu(skb_dst(nskb))) | ||
goto free_nskb; | ||
|
||
nf_ct_attach(nskb, oldskb); | ||
|
||
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) | ||
/* If we use ip_local_out for bridged traffic, the MAC source on | ||
* the RST will be ours, instead of the destination's. This confuses | ||
* some routers/firewalls, and they drop the packet. So we need to | ||
* build the eth header using the original destination's MAC as the | ||
* source, and send the RST packet directly. | ||
*/ | ||
if (oldskb->nf_bridge) { | ||
struct ethhdr *oeth = eth_hdr(oldskb); | ||
nskb->dev = oldskb->nf_bridge->physindev; | ||
niph->tot_len = htons(nskb->len); | ||
ip_send_check(niph); | ||
if (dev_hard_header(nskb, nskb->dev, ntohs(nskb->protocol), | ||
oeth->h_source, oeth->h_dest, nskb->len) < 0) | ||
goto free_nskb; | ||
dev_queue_xmit(nskb); | ||
} else | ||
#endif | ||
ip_local_out(nskb); | ||
|
||
return; | ||
|
||
free_nskb: | ||
kfree_skb(nskb); | ||
} | ||
|
||
void nf_send_reset(struct sk_buff *oldskb, int hook); | ||
|
||
#endif /* _IPV4_NF_REJECT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.