Skip to content

Commit e0831ef

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for your net tree: 1) Remove a direct dependency with IPv6 introduced by the sip_external_media feature, from Alin Nastac. 2) Fix bogus ENOENT when removing interval elements from set. 3) Set transport_header from br_netfilter to mimic the stack behaviour, this partially fixes a checksum validation bug from the SCTP connection tracking, from Xin Long. 4) Fix undefined reference to symbol in xt_TEE, due to missing Kconfig dependencies, from Arnd Bergmann. 5) Check for NULL in skb_header_pointer() calls in ip6t_shr, from Kangjie Lu. 6) Fix bogus EBUSY when removing an existing conntrack helper from a transaction. 7) Fix module autoload of the redirect extension. 8) Remove duplicated transition in flowtable diagram in the existing documentation. 9) Missing .release_ops call from error path in newrule() which results module refcount leak, from Taehee Yoo. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ceabee6 + b25a31b commit e0831ef

File tree

10 files changed

+54
-34
lines changed

10 files changed

+54
-34
lines changed

Documentation/networking/nf_flowtable.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ including the Netfilter hooks and the flowtable fastpath bypass.
4444
/ \ / \ |Routing | / \
4545
--> ingress ---> prerouting ---> |decision| | postrouting |--> neigh_xmit
4646
\_________/ \__________/ ---------- \____________/ ^
47-
| ^ | | ^ |
48-
flowtable | | ____\/___ | |
49-
| | | / \ | |
50-
__\/___ | --------->| forward |------------ |
47+
| ^ | ^ |
48+
flowtable | ____\/___ | |
49+
| | / \ | |
50+
__\/___ | | forward |------------ |
5151
|-----| | \_________/ |
5252
|-----| | 'flow offload' rule |
5353
|-----| | adds entry to |

net/bridge/br_netfilter_hooks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static unsigned int br_nf_pre_routing(void *priv,
502502
nf_bridge->ipv4_daddr = ip_hdr(skb)->daddr;
503503

504504
skb->protocol = htons(ETH_P_IP);
505+
skb->transport_header = skb->network_header + ip_hdr(skb)->ihl * 4;
505506

506507
NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
507508
skb->dev, NULL,

net/bridge/br_netfilter_ipv6.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ unsigned int br_nf_pre_routing_ipv6(void *priv,
235235
nf_bridge->ipv6_daddr = ipv6_hdr(skb)->daddr;
236236

237237
skb->protocol = htons(ETH_P_IPV6);
238+
skb->transport_header = skb->network_header + sizeof(struct ipv6hdr);
239+
238240
NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
239241
skb->dev, NULL,
240242
br_nf_pre_routing_finish_ipv6);

net/ipv6/netfilter/ip6t_srh.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ static bool srh1_mt6(const struct sk_buff *skb, struct xt_action_param *par)
210210
psidoff = srhoff + sizeof(struct ipv6_sr_hdr) +
211211
((srh->segments_left + 1) * sizeof(struct in6_addr));
212212
psid = skb_header_pointer(skb, psidoff, sizeof(_psid), &_psid);
213+
if (!psid)
214+
return false;
213215
if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_PSID,
214216
ipv6_masked_addr_cmp(psid, &srhinfo->psid_msk,
215217
&srhinfo->psid_addr)))
@@ -223,6 +225,8 @@ static bool srh1_mt6(const struct sk_buff *skb, struct xt_action_param *par)
223225
nsidoff = srhoff + sizeof(struct ipv6_sr_hdr) +
224226
((srh->segments_left - 1) * sizeof(struct in6_addr));
225227
nsid = skb_header_pointer(skb, nsidoff, sizeof(_nsid), &_nsid);
228+
if (!nsid)
229+
return false;
226230
if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_NSID,
227231
ipv6_masked_addr_cmp(nsid, &srhinfo->nsid_msk,
228232
&srhinfo->nsid_addr)))
@@ -233,6 +237,8 @@ static bool srh1_mt6(const struct sk_buff *skb, struct xt_action_param *par)
233237
if (srhinfo->mt_flags & IP6T_SRH_LSID) {
234238
lsidoff = srhoff + sizeof(struct ipv6_sr_hdr);
235239
lsid = skb_header_pointer(skb, lsidoff, sizeof(_lsid), &_lsid);
240+
if (!lsid)
241+
return false;
236242
if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_LSID,
237243
ipv6_masked_addr_cmp(lsid, &srhinfo->lsid_msk,
238244
&srhinfo->lsid_addr)))

net/netfilter/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ config NETFILTER_XT_TARGET_TEE
10071007
depends on NETFILTER_ADVANCED
10081008
depends on IPV6 || IPV6=n
10091009
depends on !NF_CONNTRACK || NF_CONNTRACK
1010+
depends on IP6_NF_IPTABLES || !IP6_NF_IPTABLES
10101011
select NF_DUP_IPV4
10111012
select NF_DUP_IPV6 if IP6_NF_IPTABLES
10121013
---help---

net/netfilter/nf_conntrack_sip.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include <linux/udp.h>
2121
#include <linux/tcp.h>
2222
#include <linux/netfilter.h>
23+
#include <linux/netfilter_ipv4.h>
24+
#include <linux/netfilter_ipv6.h>
2325

24-
#include <net/route.h>
25-
#include <net/ip6_route.h>
2626
#include <net/netfilter/nf_conntrack.h>
2727
#include <net/netfilter/nf_conntrack_core.h>
2828
#include <net/netfilter/nf_conntrack_expect.h>
@@ -871,38 +871,33 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,
871871
} else if (sip_external_media) {
872872
struct net_device *dev = skb_dst(skb)->dev;
873873
struct net *net = dev_net(dev);
874-
struct rtable *rt;
875-
struct flowi4 fl4 = {};
876-
#if IS_ENABLED(CONFIG_IPV6)
877-
struct flowi6 fl6 = {};
878-
#endif
874+
struct flowi fl;
879875
struct dst_entry *dst = NULL;
880876

877+
memset(&fl, 0, sizeof(fl));
878+
881879
switch (nf_ct_l3num(ct)) {
882880
case NFPROTO_IPV4:
883-
fl4.daddr = daddr->ip;
884-
rt = ip_route_output_key(net, &fl4);
885-
if (!IS_ERR(rt))
886-
dst = &rt->dst;
881+
fl.u.ip4.daddr = daddr->ip;
882+
nf_ip_route(net, &dst, &fl, false);
887883
break;
888884

889-
#if IS_ENABLED(CONFIG_IPV6)
890885
case NFPROTO_IPV6:
891-
fl6.daddr = daddr->in6;
892-
dst = ip6_route_output(net, NULL, &fl6);
893-
if (dst->error) {
894-
dst_release(dst);
895-
dst = NULL;
896-
}
886+
fl.u.ip6.daddr = daddr->in6;
887+
nf_ip6_route(net, &dst, &fl, false);
897888
break;
898-
#endif
899889
}
900890

901891
/* Don't predict any conntracks when media endpoint is reachable
902892
* through the same interface as the signalling peer.
903893
*/
904-
if (dst && dst->dev == dev)
905-
return NF_ACCEPT;
894+
if (dst) {
895+
bool external_media = (dst->dev == dev);
896+
897+
dst_release(dst);
898+
if (external_media)
899+
return NF_ACCEPT;
900+
}
906901
}
907902

908903
/* We need to check whether the registration exists before attempting

net/netfilter/nf_tables_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2806,8 +2806,11 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
28062806
nf_tables_rule_release(&ctx, rule);
28072807
err1:
28082808
for (i = 0; i < n; i++) {
2809-
if (info[i].ops != NULL)
2809+
if (info[i].ops) {
28102810
module_put(info[i].ops->type->owner);
2811+
if (info[i].ops->type->release_ops)
2812+
info[i].ops->type->release_ops(info[i].ops);
2813+
}
28112814
}
28122815
kvfree(info);
28132816
return err;

net/netfilter/nft_objref.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,34 @@ static int nft_objref_dump(struct sk_buff *skb, const struct nft_expr *expr)
6565
return -1;
6666
}
6767

68-
static void nft_objref_destroy(const struct nft_ctx *ctx,
69-
const struct nft_expr *expr)
68+
static void nft_objref_deactivate(const struct nft_ctx *ctx,
69+
const struct nft_expr *expr,
70+
enum nft_trans_phase phase)
7071
{
7172
struct nft_object *obj = nft_objref_priv(expr);
7273

74+
if (phase == NFT_TRANS_COMMIT)
75+
return;
76+
7377
obj->use--;
7478
}
7579

80+
static void nft_objref_activate(const struct nft_ctx *ctx,
81+
const struct nft_expr *expr)
82+
{
83+
struct nft_object *obj = nft_objref_priv(expr);
84+
85+
obj->use++;
86+
}
87+
7688
static struct nft_expr_type nft_objref_type;
7789
static const struct nft_expr_ops nft_objref_ops = {
7890
.type = &nft_objref_type,
7991
.size = NFT_EXPR_SIZE(sizeof(struct nft_object *)),
8092
.eval = nft_objref_eval,
8193
.init = nft_objref_init,
82-
.destroy = nft_objref_destroy,
94+
.activate = nft_objref_activate,
95+
.deactivate = nft_objref_deactivate,
8396
.dump = nft_objref_dump,
8497
};
8598

net/netfilter/nft_redir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,5 @@ module_exit(nft_redir_module_exit);
233233

234234
MODULE_LICENSE("GPL");
235235
MODULE_AUTHOR("Arturo Borrero Gonzalez <[email protected]>");
236-
MODULE_ALIAS_NFT_AF_EXPR(AF_INET4, "redir");
236+
MODULE_ALIAS_NFT_AF_EXPR(AF_INET, "redir");
237237
MODULE_ALIAS_NFT_AF_EXPR(AF_INET6, "redir");

net/netfilter/nft_set_rbtree.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,6 @@ static void *nft_rbtree_deactivate(const struct net *net,
308308
else if (d > 0)
309309
parent = parent->rb_right;
310310
else {
311-
if (!nft_set_elem_active(&rbe->ext, genmask)) {
312-
parent = parent->rb_left;
313-
continue;
314-
}
315311
if (nft_rbtree_interval_end(rbe) &&
316312
!nft_rbtree_interval_end(this)) {
317313
parent = parent->rb_left;
@@ -320,6 +316,9 @@ static void *nft_rbtree_deactivate(const struct net *net,
320316
nft_rbtree_interval_end(this)) {
321317
parent = parent->rb_right;
322318
continue;
319+
} else if (!nft_set_elem_active(&rbe->ext, genmask)) {
320+
parent = parent->rb_left;
321+
continue;
323322
}
324323
nft_rbtree_flush(net, set, rbe);
325324
return rbe;

0 commit comments

Comments
 (0)