forked from luck/tmp_suning_uos_patched
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 net: 1) Endianness issue in IPv4 option support in nft_exthdr, from Stephen Suryaputra. 2) Removes the waitcount optimization in nft_compat, from Florian Westphal. 3) Remove ipv6 -> nf_defrag_ipv6 module dependency, from Florian Westphal. 4) Memleak in chain binding support, also from Florian. 5) Simplify nft_flowtable.sh selftest, from Fabian Frederick. 6) Optional MTU arguments for selftest nft_flowtable.sh, also from Fabian. 7) Remove noise error report when killing process in selftest nft_flowtable.sh, from Fabian Frederick. 8) Reject bogus getsockopt option length in ebtables, from Florian Westphal. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
8c26544f5a
|
@ -58,7 +58,6 @@ struct nf_ipv6_ops {
|
|||
int (*output)(struct net *, struct sock *, struct sk_buff *));
|
||||
int (*reroute)(struct sk_buff *skb, const struct nf_queue_entry *entry);
|
||||
#if IS_MODULE(CONFIG_IPV6)
|
||||
int (*br_defrag)(struct net *net, struct sk_buff *skb, u32 user);
|
||||
int (*br_fragment)(struct net *net, struct sock *sk,
|
||||
struct sk_buff *skb,
|
||||
struct nf_bridge_frag_data *data,
|
||||
|
@ -117,23 +116,6 @@ static inline int nf_ip6_route(struct net *net, struct dst_entry **dst,
|
|||
|
||||
#include <net/netfilter/ipv6/nf_defrag_ipv6.h>
|
||||
|
||||
static inline int nf_ipv6_br_defrag(struct net *net, struct sk_buff *skb,
|
||||
u32 user)
|
||||
{
|
||||
#if IS_MODULE(CONFIG_IPV6)
|
||||
const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
|
||||
|
||||
if (!v6_ops)
|
||||
return 1;
|
||||
|
||||
return v6_ops->br_defrag(net, skb, user);
|
||||
#elif IS_BUILTIN(CONFIG_IPV6)
|
||||
return nf_ct_frag6_gather(net, skb, user);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
|
||||
struct nf_bridge_frag_data *data,
|
||||
int (*output)(struct net *, struct sock *sk,
|
||||
|
|
|
@ -2238,6 +2238,10 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
|
|||
struct ebt_table *t;
|
||||
struct net *net = sock_net(sk);
|
||||
|
||||
if ((cmd == EBT_SO_GET_INFO || cmd == EBT_SO_GET_INIT_INFO) &&
|
||||
*len != sizeof(struct compat_ebt_replace))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(&tmp, user, sizeof(tmp)))
|
||||
return -EFAULT;
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ static unsigned int nf_ct_br_defrag4(struct sk_buff *skb,
|
|||
static unsigned int nf_ct_br_defrag6(struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
||||
u16 zone_id = NF_CT_DEFAULT_ZONE_ID;
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct br_input_skb_cb cb;
|
||||
|
@ -180,14 +181,17 @@ static unsigned int nf_ct_br_defrag6(struct sk_buff *skb,
|
|||
|
||||
br_skb_cb_save(skb, &cb, sizeof(struct inet6_skb_parm));
|
||||
|
||||
err = nf_ipv6_br_defrag(state->net, skb,
|
||||
IP_DEFRAG_CONNTRACK_BRIDGE_IN + zone_id);
|
||||
err = nf_ct_frag6_gather(state->net, skb,
|
||||
IP_DEFRAG_CONNTRACK_BRIDGE_IN + zone_id);
|
||||
/* queued */
|
||||
if (err == -EINPROGRESS)
|
||||
return NF_STOLEN;
|
||||
|
||||
br_skb_cb_restore(skb, &cb, IP6CB(skb)->frag_max_size);
|
||||
return err == 0 ? NF_ACCEPT : NF_DROP;
|
||||
#else
|
||||
return NF_ACCEPT;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int nf_ct_br_ip_check(const struct sk_buff *skb)
|
||||
|
|
|
@ -245,9 +245,6 @@ static const struct nf_ipv6_ops ipv6ops = {
|
|||
.route_input = ip6_route_input,
|
||||
.fragment = ip6_fragment,
|
||||
.reroute = nf_ip6_reroute,
|
||||
#if IS_MODULE(CONFIG_IPV6) && IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
||||
.br_defrag = nf_ct_frag6_gather,
|
||||
#endif
|
||||
#if IS_MODULE(CONFIG_IPV6)
|
||||
.br_fragment = br_ip6_fragment,
|
||||
#endif
|
||||
|
|
|
@ -2018,8 +2018,10 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
|
|||
if (nla[NFTA_CHAIN_NAME]) {
|
||||
chain->name = nla_strdup(nla[NFTA_CHAIN_NAME], GFP_KERNEL);
|
||||
} else {
|
||||
if (!(flags & NFT_CHAIN_BINDING))
|
||||
return -EINVAL;
|
||||
if (!(flags & NFT_CHAIN_BINDING)) {
|
||||
err = -EINVAL;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "__chain%llu", ++chain_id);
|
||||
chain->name = kstrdup(name, GFP_KERNEL);
|
||||
|
|
|
@ -27,8 +27,6 @@ struct nft_xt_match_priv {
|
|||
void *info;
|
||||
};
|
||||
|
||||
static refcount_t nft_compat_pending_destroy = REFCOUNT_INIT(1);
|
||||
|
||||
static int nft_compat_chain_validate_dependency(const struct nft_ctx *ctx,
|
||||
const char *tablename)
|
||||
{
|
||||
|
@ -215,6 +213,17 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void nft_compat_wait_for_destructors(void)
|
||||
{
|
||||
/* xtables matches or targets can have side effects, e.g.
|
||||
* creation/destruction of /proc files.
|
||||
* The xt ->destroy functions are run asynchronously from
|
||||
* work queue. If we have pending invocations we thus
|
||||
* need to wait for those to finish.
|
||||
*/
|
||||
nf_tables_trans_destroy_flush_work();
|
||||
}
|
||||
|
||||
static int
|
||||
nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
|
||||
const struct nlattr * const tb[])
|
||||
|
@ -238,14 +247,7 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
|
|||
|
||||
nft_target_set_tgchk_param(&par, ctx, target, info, &e, proto, inv);
|
||||
|
||||
/* xtables matches or targets can have side effects, e.g.
|
||||
* creation/destruction of /proc files.
|
||||
* The xt ->destroy functions are run asynchronously from
|
||||
* work queue. If we have pending invocations we thus
|
||||
* need to wait for those to finish.
|
||||
*/
|
||||
if (refcount_read(&nft_compat_pending_destroy) > 1)
|
||||
nf_tables_trans_destroy_flush_work();
|
||||
nft_compat_wait_for_destructors();
|
||||
|
||||
ret = xt_check_target(&par, size, proto, inv);
|
||||
if (ret < 0)
|
||||
|
@ -260,7 +262,6 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
|
|||
|
||||
static void __nft_mt_tg_destroy(struct module *me, const struct nft_expr *expr)
|
||||
{
|
||||
refcount_dec(&nft_compat_pending_destroy);
|
||||
module_put(me);
|
||||
kfree(expr->ops);
|
||||
}
|
||||
|
@ -468,6 +469,8 @@ __nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
|
|||
|
||||
nft_match_set_mtchk_param(&par, ctx, match, info, &e, proto, inv);
|
||||
|
||||
nft_compat_wait_for_destructors();
|
||||
|
||||
return xt_check_match(&par, size, proto, inv);
|
||||
}
|
||||
|
||||
|
@ -716,14 +719,6 @@ static const struct nfnetlink_subsystem nfnl_compat_subsys = {
|
|||
|
||||
static struct nft_expr_type nft_match_type;
|
||||
|
||||
static void nft_mt_tg_deactivate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr,
|
||||
enum nft_trans_phase phase)
|
||||
{
|
||||
if (phase == NFT_TRANS_COMMIT)
|
||||
refcount_inc(&nft_compat_pending_destroy);
|
||||
}
|
||||
|
||||
static const struct nft_expr_ops *
|
||||
nft_match_select_ops(const struct nft_ctx *ctx,
|
||||
const struct nlattr * const tb[])
|
||||
|
@ -762,7 +757,6 @@ nft_match_select_ops(const struct nft_ctx *ctx,
|
|||
ops->type = &nft_match_type;
|
||||
ops->eval = nft_match_eval;
|
||||
ops->init = nft_match_init;
|
||||
ops->deactivate = nft_mt_tg_deactivate,
|
||||
ops->destroy = nft_match_destroy;
|
||||
ops->dump = nft_match_dump;
|
||||
ops->validate = nft_match_validate;
|
||||
|
@ -853,7 +847,6 @@ nft_target_select_ops(const struct nft_ctx *ctx,
|
|||
ops->size = NFT_EXPR_SIZE(XT_ALIGN(target->targetsize));
|
||||
ops->init = nft_target_init;
|
||||
ops->destroy = nft_target_destroy;
|
||||
ops->deactivate = nft_mt_tg_deactivate,
|
||||
ops->dump = nft_target_dump;
|
||||
ops->validate = nft_target_validate;
|
||||
ops->data = target;
|
||||
|
@ -917,8 +910,6 @@ static void __exit nft_compat_module_exit(void)
|
|||
nfnetlink_subsys_unregister(&nfnl_compat_subsys);
|
||||
nft_unregister_expr(&nft_target_type);
|
||||
nft_unregister_expr(&nft_match_type);
|
||||
|
||||
WARN_ON_ONCE(refcount_read(&nft_compat_pending_destroy) != 1);
|
||||
}
|
||||
|
||||
MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_NFT_COMPAT);
|
||||
|
|
|
@ -44,7 +44,7 @@ static void nft_exthdr_ipv6_eval(const struct nft_expr *expr,
|
|||
|
||||
err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
|
||||
if (priv->flags & NFT_EXTHDR_F_PRESENT) {
|
||||
*dest = (err >= 0);
|
||||
nft_reg_store8(dest, err >= 0);
|
||||
return;
|
||||
} else if (err < 0) {
|
||||
goto err;
|
||||
|
@ -141,7 +141,7 @@ static void nft_exthdr_ipv4_eval(const struct nft_expr *expr,
|
|||
|
||||
err = ipv4_find_option(nft_net(pkt), skb, &offset, priv->type);
|
||||
if (priv->flags & NFT_EXTHDR_F_PRESENT) {
|
||||
*dest = (err >= 0);
|
||||
nft_reg_store8(dest, err >= 0);
|
||||
return;
|
||||
} else if (err < 0) {
|
||||
goto err;
|
||||
|
|
|
@ -2,13 +2,18 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# This tests basic flowtable functionality.
|
||||
# Creates following topology:
|
||||
# Creates following default topology:
|
||||
#
|
||||
# Originator (MTU 9000) <-Router1-> MTU 1500 <-Router2-> Responder (MTU 2000)
|
||||
# Router1 is the one doing flow offloading, Router2 has no special
|
||||
# purpose other than having a link that is smaller than either Originator
|
||||
# and responder, i.e. TCPMSS announced values are too large and will still
|
||||
# result in fragmentation and/or PMTU discovery.
|
||||
#
|
||||
# You can check with different Orgininator/Link/Responder MTU eg:
|
||||
# sh nft_flowtable.sh -o1000 -l500 -r100
|
||||
#
|
||||
|
||||
|
||||
# Kselftest framework requirement - SKIP code is 4.
|
||||
ksft_skip=4
|
||||
|
@ -21,29 +26,18 @@ ns2out=""
|
|||
|
||||
log_netns=$(sysctl -n net.netfilter.nf_log_all_netns)
|
||||
|
||||
nft --version > /dev/null 2>&1
|
||||
if [ $? -ne 0 ];then
|
||||
echo "SKIP: Could not run test without nft tool"
|
||||
exit $ksft_skip
|
||||
fi
|
||||
checktool (){
|
||||
$1 > /dev/null 2>&1
|
||||
if [ $? -ne 0 ];then
|
||||
echo "SKIP: Could not $2"
|
||||
exit $ksft_skip
|
||||
fi
|
||||
}
|
||||
|
||||
ip -Version > /dev/null 2>&1
|
||||
if [ $? -ne 0 ];then
|
||||
echo "SKIP: Could not run test without ip tool"
|
||||
exit $ksft_skip
|
||||
fi
|
||||
|
||||
which nc > /dev/null 2>&1
|
||||
if [ $? -ne 0 ];then
|
||||
echo "SKIP: Could not run test without nc (netcat)"
|
||||
exit $ksft_skip
|
||||
fi
|
||||
|
||||
ip netns add nsr1
|
||||
if [ $? -ne 0 ];then
|
||||
echo "SKIP: Could not create net namespace"
|
||||
exit $ksft_skip
|
||||
fi
|
||||
checktool "nft --version" "run test without nft tool"
|
||||
checktool "ip -Version" "run test without ip tool"
|
||||
checktool "which nc" "run test without nc (netcat)"
|
||||
checktool "ip netns add nsr1" "create net namespace"
|
||||
|
||||
ip netns add ns1
|
||||
ip netns add ns2
|
||||
|
@ -89,11 +83,24 @@ ip -net nsr2 addr add dead:2::1/64 dev veth1
|
|||
# ns2 is going via nsr2 with a smaller mtu, so that TCPMSS announced by both peers
|
||||
# is NOT the lowest link mtu.
|
||||
|
||||
ip -net nsr1 link set veth0 mtu 9000
|
||||
ip -net ns1 link set eth0 mtu 9000
|
||||
omtu=9000
|
||||
lmtu=1500
|
||||
rmtu=2000
|
||||
|
||||
ip -net nsr2 link set veth1 mtu 2000
|
||||
ip -net ns2 link set eth0 mtu 2000
|
||||
while getopts "o:l:r:" o
|
||||
do
|
||||
case $o in
|
||||
o) omtu=$OPTARG;;
|
||||
l) lmtu=$OPTARG;;
|
||||
r) rmtu=$OPTARG;;
|
||||
esac
|
||||
done
|
||||
|
||||
ip -net nsr1 link set veth0 mtu $omtu
|
||||
ip -net ns1 link set eth0 mtu $omtu
|
||||
|
||||
ip -net nsr2 link set veth1 mtu $rmtu
|
||||
ip -net ns2 link set eth0 mtu $rmtu
|
||||
|
||||
# transfer-net between nsr1 and nsr2.
|
||||
# these addresses are not used for connections.
|
||||
|
@ -147,7 +154,7 @@ table inet filter {
|
|||
# as PMTUd is off.
|
||||
# This rule is deleted for the last test, when we expect PMTUd
|
||||
# to kick in and ensure all packets meet mtu requirements.
|
||||
meta length gt 1500 accept comment something-to-grep-for
|
||||
meta length gt $lmtu accept comment something-to-grep-for
|
||||
|
||||
# next line blocks connection w.o. working offload.
|
||||
# we only do this for reverse dir, because we expect packets to
|
||||
|
@ -243,8 +250,14 @@ test_tcp_forwarding_ip()
|
|||
|
||||
sleep 3
|
||||
|
||||
kill $lpid
|
||||
kill $cpid
|
||||
if ps -p $lpid > /dev/null;then
|
||||
kill $lpid
|
||||
fi
|
||||
|
||||
if ps -p $cpid > /dev/null;then
|
||||
kill $cpid
|
||||
fi
|
||||
|
||||
wait
|
||||
|
||||
check_transfer "$ns1in" "$ns2out" "ns1 -> ns2"
|
||||
|
|
Loading…
Reference in New Issue
Block a user