Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next

Pablo Neira Ayuso says:

====================
Netfilter updates for net-next

1) UAF in chain binding support from previous batch, from Dan Carpenter.

2) Queue up delayed work to expire connections with no destination,
   from Andrew Sy Kim.

3) Use fallthrough pseudo-keyword, from Gustavo A. R. Silva.

4) Replace HTTP links with HTTPS, from Alexander A. Klimov.

5) Remove superfluous null header checks in ip6tables, from
   Gaurav Singh.

6) Add extended netlink error reporting for expression.

7) Report EEXIST on overlapping chain, set elements and flowtable
   devices.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2020-08-03 16:03:18 -07:00
Родитель c23cf402d0 77a92189ec
Коммит f2e0b29a9a
35 изменённых файлов: 173 добавлений и 93 удалений

Просмотреть файл

@ -14,6 +14,7 @@
#include <linux/spinlock.h> /* for struct rwlock_t */ #include <linux/spinlock.h> /* for struct rwlock_t */
#include <linux/atomic.h> /* for struct atomic_t */ #include <linux/atomic.h> /* for struct atomic_t */
#include <linux/refcount.h> /* for struct refcount_t */ #include <linux/refcount.h> /* for struct refcount_t */
#include <linux/workqueue.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/timer.h> #include <linux/timer.h>
@ -886,6 +887,8 @@ struct netns_ipvs {
atomic_t conn_out_counter; atomic_t conn_out_counter;
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
/* delayed work for expiring no dest connections */
struct delayed_work expire_nodest_conn_work;
/* 1/rate drop and drop-entry variables */ /* 1/rate drop and drop-entry variables */
struct delayed_work defense_work; /* Work handler */ struct delayed_work defense_work; /* Work handler */
int drop_rate; int drop_rate;
@ -1051,6 +1054,11 @@ static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)
return ipvs->sysctl_conn_reuse_mode; return ipvs->sysctl_conn_reuse_mode;
} }
static inline int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs)
{
return ipvs->sysctl_expire_nodest_conn;
}
static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs) static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs)
{ {
return ipvs->sysctl_schedule_icmp; return ipvs->sysctl_schedule_icmp;
@ -1138,6 +1146,11 @@ static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)
return 1; return 1;
} }
static inline int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs)
{
return 0;
}
static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs) static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs)
{ {
return 0; return 0;
@ -1507,6 +1520,22 @@ static inline int ip_vs_todrop(struct netns_ipvs *ipvs)
static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; } static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; }
#endif #endif
#ifdef CONFIG_SYSCTL
/* Enqueue delayed work for expiring no dest connections
* Only run when sysctl_expire_nodest=1
*/
static inline void ip_vs_enqueue_expire_nodest_conns(struct netns_ipvs *ipvs)
{
if (sysctl_expire_nodest_conn(ipvs))
queue_delayed_work(system_long_wq,
&ipvs->expire_nodest_conn_work, 1);
}
void ip_vs_expire_nodest_conn_flush(struct netns_ipvs *ipvs);
#else
static inline void ip_vs_enqueue_expire_nodest_conns(struct netns_ipvs *ipvs) {}
#endif
#define IP_VS_DFWD_METHOD(dest) (atomic_read(&(dest)->conn_flags) & \ #define IP_VS_DFWD_METHOD(dest) (atomic_read(&(dest)->conn_flags) & \
IP_VS_CONN_F_FWD_MASK) IP_VS_CONN_F_FWD_MASK)

Просмотреть файл

@ -4,7 +4,7 @@
#include <linux/types.h> #include <linux/types.h>
/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> /* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com>
* by Henrik Nordstrom <hno@marasystems.com> * by Henrik Nordstrom <hno@marasystems.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

Просмотреть файл

@ -1852,7 +1852,7 @@ static int compat_mtw_from_user(const struct compat_ebt_entry_mwt *mwt,
size_kern = match_size; size_kern = match_size;
module_put(match->me); module_put(match->me);
break; break;
case EBT_COMPAT_WATCHER: /* fallthrough */ case EBT_COMPAT_WATCHER:
case EBT_COMPAT_TARGET: case EBT_COMPAT_TARGET:
wt = xt_request_find_target(NFPROTO_BRIDGE, name, wt = xt_request_find_target(NFPROTO_BRIDGE, name,
mwt->u.revision); mwt->u.revision);

Просмотреть файл

@ -6,7 +6,7 @@
* *
* DECnet Routing Message Grabulator * DECnet Routing Message Grabulator
* *
* (C) 2000 ChyGwyn Limited - http://www.chygwyn.com/ * (C) 2000 ChyGwyn Limited - https://www.chygwyn.com/
* *
* Author: Steven Whitehouse <steve@chygwyn.com> * Author: Steven Whitehouse <steve@chygwyn.com>
*/ */

Просмотреть файл

@ -74,8 +74,7 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
ahinfo->hdrres, ah->reserved, ahinfo->hdrres, ah->reserved,
!(ahinfo->hdrres && ah->reserved)); !(ahinfo->hdrres && ah->reserved));
return (ah != NULL) && return spi_match(ahinfo->spis[0], ahinfo->spis[1],
spi_match(ahinfo->spis[0], ahinfo->spis[1],
ntohl(ah->spi), ntohl(ah->spi),
!!(ahinfo->invflags & IP6T_AH_INV_SPI)) && !!(ahinfo->invflags & IP6T_AH_INV_SPI)) &&
(!ahinfo->hdrlen || (!ahinfo->hdrlen ||

Просмотреть файл

@ -85,8 +85,7 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par)
!((fraginfo->flags & IP6T_FRAG_NMF) && !((fraginfo->flags & IP6T_FRAG_NMF) &&
(ntohs(fh->frag_off) & IP6_MF))); (ntohs(fh->frag_off) & IP6_MF)));
return (fh != NULL) && return id_match(fraginfo->ids[0], fraginfo->ids[1],
id_match(fraginfo->ids[0], fraginfo->ids[1],
ntohl(fh->identification), ntohl(fh->identification),
!!(fraginfo->invflags & IP6T_FRAG_INV_IDS)) && !!(fraginfo->invflags & IP6T_FRAG_INV_IDS)) &&
!((fraginfo->flags & IP6T_FRAG_RES) && !((fraginfo->flags & IP6T_FRAG_RES) &&

Просмотреть файл

@ -86,8 +86,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
((optinfo->hdrlen == hdrlen) ^ ((optinfo->hdrlen == hdrlen) ^
!!(optinfo->invflags & IP6T_OPTS_INV_LEN)))); !!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
ret = (oh != NULL) && ret = (!(optinfo->flags & IP6T_OPTS_LEN) ||
(!(optinfo->flags & IP6T_OPTS_LEN) ||
((optinfo->hdrlen == hdrlen) ^ ((optinfo->hdrlen == hdrlen) ^
!!(optinfo->invflags & IP6T_OPTS_INV_LEN))); !!(optinfo->invflags & IP6T_OPTS_INV_LEN)));

Просмотреть файл

@ -89,8 +89,7 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
!((rtinfo->flags & IP6T_RT_RES) && !((rtinfo->flags & IP6T_RT_RES) &&
(((const struct rt0_hdr *)rh)->reserved))); (((const struct rt0_hdr *)rh)->reserved)));
ret = (rh != NULL) && ret = (segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
(segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
rh->segments_left, rh->segments_left,
!!(rtinfo->invflags & IP6T_RT_INV_SGS))) && !!(rtinfo->invflags & IP6T_RT_INV_SGS))) &&
(!(rtinfo->flags & IP6T_RT_LEN) || (!(rtinfo->flags & IP6T_RT_LEN) ||

Просмотреть файл

@ -447,7 +447,7 @@ config NF_TABLES
replace the existing {ip,ip6,arp,eb}_tables infrastructure. It replace the existing {ip,ip6,arp,eb}_tables infrastructure. It
provides a pseudo-state machine with an extensible instruction-set provides a pseudo-state machine with an extensible instruction-set
(also known as expressions) that the userspace 'nft' utility (also known as expressions) that the userspace 'nft' utility
(http://www.netfilter.org/projects/nftables) uses to build the (https://www.netfilter.org/projects/nftables) uses to build the
rule-set. It also comes with the generic set infrastructure that rule-set. It also comes with the generic set infrastructure that
allows you to construct mappings between matchings and actions allows you to construct mappings between matchings and actions
for performance lookups. for performance lookups.

Просмотреть файл

@ -1644,7 +1644,7 @@ dump_last:
goto next_set; goto next_set;
if (set->variant->uref) if (set->variant->uref)
set->variant->uref(set, cb, true); set->variant->uref(set, cb, true);
/* fall through */ fallthrough;
default: default:
ret = set->variant->list(set, skb, cb); ret = set->variant->list(set, skb, cb);
if (!cb->args[IPSET_CB_ARG0]) if (!cb->args[IPSET_CB_ARG0])

Просмотреть файл

@ -1389,6 +1389,45 @@ flush_again:
goto flush_again; goto flush_again;
} }
} }
#ifdef CONFIG_SYSCTL
void ip_vs_expire_nodest_conn_flush(struct netns_ipvs *ipvs)
{
int idx;
struct ip_vs_conn *cp, *cp_c;
struct ip_vs_dest *dest;
rcu_read_lock();
for (idx = 0; idx < ip_vs_conn_tab_size; idx++) {
hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[idx], c_list) {
if (cp->ipvs != ipvs)
continue;
dest = cp->dest;
if (!dest || (dest->flags & IP_VS_DEST_F_AVAILABLE))
continue;
if (atomic_read(&cp->n_control))
continue;
cp_c = cp->control;
IP_VS_DBG(4, "del connection\n");
ip_vs_conn_del(cp);
if (cp_c && !atomic_read(&cp_c->n_control)) {
IP_VS_DBG(4, "del controlling connection\n");
ip_vs_conn_del(cp_c);
}
}
cond_resched_rcu();
/* netns clean up started, abort delayed work */
if (!ipvs->enable)
break;
}
rcu_read_unlock();
}
#endif
/* /*
* per netns init and exit * per netns init and exit
*/ */

Просмотреть файл

@ -694,16 +694,10 @@ static int sysctl_nat_icmp_send(struct netns_ipvs *ipvs)
return ipvs->sysctl_nat_icmp_send; return ipvs->sysctl_nat_icmp_send;
} }
static int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs)
{
return ipvs->sysctl_expire_nodest_conn;
}
#else #else
static int sysctl_snat_reroute(struct netns_ipvs *ipvs) { return 0; } static int sysctl_snat_reroute(struct netns_ipvs *ipvs) { return 0; }
static int sysctl_nat_icmp_send(struct netns_ipvs *ipvs) { return 0; } static int sysctl_nat_icmp_send(struct netns_ipvs *ipvs) { return 0; }
static int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs) { return 0; }
#endif #endif
@ -2097,6 +2091,26 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
} }
} }
/* Check the server status */
if (cp && cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) {
/* the destination server is not available */
if (sysctl_expire_nodest_conn(ipvs)) {
bool old_ct = ip_vs_conn_uses_old_conntrack(cp, skb);
if (!old_ct)
cp->flags &= ~IP_VS_CONN_F_NFCT;
ip_vs_conn_expire_now(cp);
__ip_vs_conn_put(cp);
if (old_ct)
return NF_DROP;
cp = NULL;
} else {
__ip_vs_conn_put(cp);
return NF_DROP;
}
}
if (unlikely(!cp)) { if (unlikely(!cp)) {
int v; int v;
@ -2106,27 +2120,6 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
IP_VS_DBG_PKT(11, af, pp, skb, iph.off, "Incoming packet"); IP_VS_DBG_PKT(11, af, pp, skb, iph.off, "Incoming packet");
/* Check the server status */
if (cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) {
/* the destination server is not available */
__u32 flags = cp->flags;
/* when timer already started, silently drop the packet.*/
if (timer_pending(&cp->timer))
__ip_vs_conn_put(cp);
else
ip_vs_conn_put(cp);
if (sysctl_expire_nodest_conn(ipvs) &&
!(flags & IP_VS_CONN_F_ONE_PACKET)) {
/* try to expire the connection immediately */
ip_vs_conn_expire_now(cp);
}
return NF_DROP;
}
ip_vs_in_stats(cp, skb); ip_vs_in_stats(cp, skb);
ip_vs_set_state(cp, IP_VS_DIR_INPUT, skb, pd); ip_vs_set_state(cp, IP_VS_DIR_INPUT, skb, pd);
if (cp->packet_xmit) if (cp->packet_xmit)

Просмотреть файл

@ -210,6 +210,17 @@ static void update_defense_level(struct netns_ipvs *ipvs)
local_bh_enable(); local_bh_enable();
} }
/* Handler for delayed work for expiring no
* destination connections
*/
static void expire_nodest_conn_handler(struct work_struct *work)
{
struct netns_ipvs *ipvs;
ipvs = container_of(work, struct netns_ipvs,
expire_nodest_conn_work.work);
ip_vs_expire_nodest_conn_flush(ipvs);
}
/* /*
* Timer for checking the defense * Timer for checking the defense
@ -1164,6 +1175,12 @@ static void __ip_vs_del_dest(struct netns_ipvs *ipvs, struct ip_vs_dest *dest,
list_add(&dest->t_list, &ipvs->dest_trash); list_add(&dest->t_list, &ipvs->dest_trash);
dest->idle_start = 0; dest->idle_start = 0;
spin_unlock_bh(&ipvs->dest_trash_lock); spin_unlock_bh(&ipvs->dest_trash_lock);
/* Queue up delayed work to expire all no destination connections.
* No-op when CONFIG_SYSCTL is disabled.
*/
if (!cleanup)
ip_vs_enqueue_expire_nodest_conns(ipvs);
} }
@ -4086,6 +4103,10 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
queue_delayed_work(system_long_wq, &ipvs->defense_work, queue_delayed_work(system_long_wq, &ipvs->defense_work,
DEFENSE_TIMER_PERIOD); DEFENSE_TIMER_PERIOD);
/* Init delayed work for expiring no dest conn */
INIT_DELAYED_WORK(&ipvs->expire_nodest_conn_work,
expire_nodest_conn_handler);
return 0; return 0;
} }
@ -4093,6 +4114,7 @@ static void __net_exit ip_vs_control_net_cleanup_sysctl(struct netns_ipvs *ipvs)
{ {
struct net *net = ipvs->net; struct net *net = ipvs->net;
cancel_delayed_work_sync(&ipvs->expire_nodest_conn_work);
cancel_delayed_work_sync(&ipvs->defense_work); cancel_delayed_work_sync(&ipvs->defense_work);
cancel_work_sync(&ipvs->defense_work.work); cancel_work_sync(&ipvs->defense_work.work);
unregister_net_sysctl_table(ipvs->sysctl_hdr); unregister_net_sysctl_table(ipvs->sysctl_hdr);

Просмотреть файл

@ -257,15 +257,15 @@ static unsigned int get_uint(struct bitstr *bs, int b)
case 4: case 4:
v |= *bs->cur++; v |= *bs->cur++;
v <<= 8; v <<= 8;
/* fall through */ fallthrough;
case 3: case 3:
v |= *bs->cur++; v |= *bs->cur++;
v <<= 8; v <<= 8;
/* fall through */ fallthrough;
case 2: case 2:
v |= *bs->cur++; v |= *bs->cur++;
v <<= 8; v <<= 8;
/* fall through */ fallthrough;
case 1: case 1:
v |= *bs->cur++; v |= *bs->cur++;
break; break;

Просмотреть файл

@ -610,7 +610,7 @@ void nf_ct_netns_put(struct net *net, uint8_t nfproto)
switch (nfproto) { switch (nfproto) {
case NFPROTO_BRIDGE: case NFPROTO_BRIDGE:
nf_ct_netns_do_put(net, NFPROTO_BRIDGE); nf_ct_netns_do_put(net, NFPROTO_BRIDGE);
/* fall through */ fallthrough;
case NFPROTO_INET: case NFPROTO_INET:
nf_ct_netns_do_put(net, NFPROTO_IPV4); nf_ct_netns_do_put(net, NFPROTO_IPV4);
nf_ct_netns_do_put(net, NFPROTO_IPV6); nf_ct_netns_do_put(net, NFPROTO_IPV6);

Просмотреть файл

@ -900,7 +900,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
return -NF_REPEAT; return -NF_REPEAT;
return NF_DROP; return NF_DROP;
} }
/* Fall through */ fallthrough;
case TCP_CONNTRACK_IGNORE: case TCP_CONNTRACK_IGNORE:
/* Ignored packets: /* Ignored packets:
* *

Просмотреть файл

@ -60,7 +60,7 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
ntohs(tuple->src.u.tcp.port), ntohs(tuple->src.u.tcp.port),
ntohs(tuple->dst.u.tcp.port)); ntohs(tuple->dst.u.tcp.port));
break; break;
case IPPROTO_UDPLITE: /* fallthrough */ case IPPROTO_UDPLITE:
case IPPROTO_UDP: case IPPROTO_UDP:
seq_printf(s, "sport=%hu dport=%hu ", seq_printf(s, "sport=%hu dport=%hu ",
ntohs(tuple->src.u.udp.port), ntohs(tuple->src.u.udp.port),

Просмотреть файл

@ -408,7 +408,7 @@ static void nf_nat_l4proto_unique_tuple(struct nf_conntrack_tuple *tuple,
static const unsigned int max_attempts = 128; static const unsigned int max_attempts = 128;
switch (tuple->dst.protonum) { switch (tuple->dst.protonum) {
case IPPROTO_ICMP: /* fallthrough */ case IPPROTO_ICMP:
case IPPROTO_ICMPV6: case IPPROTO_ICMPV6:
/* id is same for either direction... */ /* id is same for either direction... */
keyptr = &tuple->src.u.icmp.id; keyptr = &tuple->src.u.icmp.id;
@ -442,11 +442,11 @@ static void nf_nat_l4proto_unique_tuple(struct nf_conntrack_tuple *tuple,
} }
goto find_free_id; goto find_free_id;
#endif #endif
case IPPROTO_UDP: /* fallthrough */ case IPPROTO_UDP:
case IPPROTO_UDPLITE: /* fallthrough */ case IPPROTO_UDPLITE:
case IPPROTO_TCP: /* fallthrough */ case IPPROTO_TCP:
case IPPROTO_SCTP: /* fallthrough */ case IPPROTO_SCTP:
case IPPROTO_DCCP: /* fallthrough */ case IPPROTO_DCCP:
if (maniptype == NF_NAT_MANIP_SRC) if (maniptype == NF_NAT_MANIP_SRC)
keyptr = &tuple->src.u.all; keyptr = &tuple->src.u.all;
else else

Просмотреть файл

@ -704,8 +704,7 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,
nf_ct_seqadj_init(ct, ctinfo, 0); nf_ct_seqadj_init(ct, ctinfo, 0);
synproxy->tsoff = 0; synproxy->tsoff = 0;
this_cpu_inc(snet->stats->conn_reopened); this_cpu_inc(snet->stats->conn_reopened);
fallthrough;
/* fall through */
case TCP_CONNTRACK_SYN_SENT: case TCP_CONNTRACK_SYN_SENT:
if (!synproxy_parse_options(skb, thoff, th, &opts)) if (!synproxy_parse_options(skb, thoff, th, &opts))
return NF_DROP; return NF_DROP;
@ -1128,8 +1127,7 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,
nf_ct_seqadj_init(ct, ctinfo, 0); nf_ct_seqadj_init(ct, ctinfo, 0);
synproxy->tsoff = 0; synproxy->tsoff = 0;
this_cpu_inc(snet->stats->conn_reopened); this_cpu_inc(snet->stats->conn_reopened);
fallthrough;
/* fall through */
case TCP_CONNTRACK_SYN_SENT: case TCP_CONNTRACK_SYN_SENT:
if (!synproxy_parse_options(skb, thoff, th, &opts)) if (!synproxy_parse_options(skb, thoff, th, &opts))
return NF_DROP; return NF_DROP;

Просмотреть файл

@ -2084,7 +2084,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
if (nla[NFTA_CHAIN_HOOK]) { if (nla[NFTA_CHAIN_HOOK]) {
if (!nft_is_base_chain(chain)) if (!nft_is_base_chain(chain))
return -EBUSY; return -EEXIST;
err = nft_chain_parse_hook(ctx->net, nla, &hook, ctx->family, err = nft_chain_parse_hook(ctx->net, nla, &hook, ctx->family,
false); false);
@ -2094,21 +2094,21 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
basechain = nft_base_chain(chain); basechain = nft_base_chain(chain);
if (basechain->type != hook.type) { if (basechain->type != hook.type) {
nft_chain_release_hook(&hook); nft_chain_release_hook(&hook);
return -EBUSY; return -EEXIST;
} }
if (ctx->family == NFPROTO_NETDEV) { if (ctx->family == NFPROTO_NETDEV) {
if (!nft_hook_list_equal(&basechain->hook_list, if (!nft_hook_list_equal(&basechain->hook_list,
&hook.list)) { &hook.list)) {
nft_chain_release_hook(&hook); nft_chain_release_hook(&hook);
return -EBUSY; return -EEXIST;
} }
} else { } else {
ops = &basechain->ops; ops = &basechain->ops;
if (ops->hooknum != hook.num || if (ops->hooknum != hook.num ||
ops->priority != hook.priority) { ops->priority != hook.priority) {
nft_chain_release_hook(&hook); nft_chain_release_hook(&hook);
return -EBUSY; return -EEXIST;
} }
} }
nft_chain_release_hook(&hook); nft_chain_release_hook(&hook);
@ -2496,6 +2496,7 @@ nla_put_failure:
struct nft_expr_info { struct nft_expr_info {
const struct nft_expr_ops *ops; const struct nft_expr_ops *ops;
const struct nlattr *attr;
struct nlattr *tb[NFT_EXPR_MAXATTR + 1]; struct nlattr *tb[NFT_EXPR_MAXATTR + 1];
}; };
@ -2543,7 +2544,9 @@ static int nf_tables_expr_parse(const struct nft_ctx *ctx,
} else } else
ops = type->ops; ops = type->ops;
info->attr = nla;
info->ops = ops; info->ops = ops;
return 0; return 0;
err1: err1:
@ -3201,8 +3204,10 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
expr = nft_expr_first(rule); expr = nft_expr_first(rule);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
err = nf_tables_newexpr(&ctx, &info[i], expr); err = nf_tables_newexpr(&ctx, &info[i], expr);
if (err < 0) if (err < 0) {
NL_SET_BAD_ATTR(extack, info[i].attr);
goto err2; goto err2;
}
if (info[i].ops->validate) if (info[i].ops->validate)
nft_validate_state_update(net, NFT_VALIDATE_NEED); nft_validate_state_update(net, NFT_VALIDATE_NEED);
@ -4362,7 +4367,7 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,
case NFT_TRANS_ABORT: case NFT_TRANS_ABORT:
case NFT_TRANS_RELEASE: case NFT_TRANS_RELEASE:
set->use--; set->use--;
/* fall through */ fallthrough;
default: default:
nf_tables_unbind_set(ctx, set, binding, nf_tables_unbind_set(ctx, set, binding,
phase == NFT_TRANS_COMMIT); phase == NFT_TRANS_COMMIT);
@ -5244,10 +5249,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) ^ if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) ^
nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) || nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) ||
nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) ^ nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) ^
nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF)) { nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF))
err = -EBUSY;
goto err_element_clash; goto err_element_clash;
}
if ((nft_set_ext_exists(ext, NFT_SET_EXT_DATA) && if ((nft_set_ext_exists(ext, NFT_SET_EXT_DATA) &&
nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) && nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) &&
memcmp(nft_set_ext_data(ext), memcmp(nft_set_ext_data(ext),
@ -5255,7 +5258,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
(nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) && (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) &&
nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF) && nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF) &&
*nft_set_ext_obj(ext) != *nft_set_ext_obj(ext2))) *nft_set_ext_obj(ext) != *nft_set_ext_obj(ext2)))
err = -EBUSY; goto err_element_clash;
else if (!(nlmsg_flags & NLM_F_EXCL)) else if (!(nlmsg_flags & NLM_F_EXCL))
err = 0; err = 0;
} else if (err == -ENOTEMPTY) { } else if (err == -ENOTEMPTY) {
@ -6243,7 +6246,7 @@ void nf_tables_deactivate_flowtable(const struct nft_ctx *ctx,
case NFT_TRANS_ABORT: case NFT_TRANS_ABORT:
case NFT_TRANS_RELEASE: case NFT_TRANS_RELEASE:
flowtable->use--; flowtable->use--;
/* fall through */ fallthrough;
default: default:
return; return;
} }
@ -6405,7 +6408,7 @@ static int nft_register_flowtable_net_hooks(struct net *net,
list_for_each_entry(hook2, &ft->hook_list, list) { list_for_each_entry(hook2, &ft->hook_list, list) {
if (hook->ops.dev == hook2->ops.dev && if (hook->ops.dev == hook2->ops.dev &&
hook->ops.pf == hook2->ops.pf) { hook->ops.pf == hook2->ops.pf) {
err = -EBUSY; err = -EEXIST;
goto err_unregister_net_hooks; goto err_unregister_net_hooks;
} }
} }
@ -7249,7 +7252,7 @@ static int nf_tables_validate(struct net *net)
break; break;
case NFT_VALIDATE_NEED: case NFT_VALIDATE_NEED:
nft_validate_state_update(net, NFT_VALIDATE_DO); nft_validate_state_update(net, NFT_VALIDATE_DO);
/* fall through */ fallthrough;
case NFT_VALIDATE_DO: case NFT_VALIDATE_DO:
list_for_each_entry(table, &net->nft.tables, list) { list_for_each_entry(table, &net->nft.tables, list) {
if (nft_table_validate(net, table) < 0) if (nft_table_validate(net, table) < 0)
@ -8323,7 +8326,7 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
default: default:
return -EINVAL; return -EINVAL;
} }
/* fall through */ fallthrough;
case NFT_CONTINUE: case NFT_CONTINUE:
case NFT_BREAK: case NFT_BREAK:
case NFT_RETURN: case NFT_RETURN:

Просмотреть файл

@ -213,7 +213,7 @@ next_rule:
jumpstack[stackptr].chain = chain; jumpstack[stackptr].chain = chain;
jumpstack[stackptr].rules = rules + 1; jumpstack[stackptr].rules = rules + 1;
stackptr++; stackptr++;
/* fall through */ fallthrough;
case NFT_GOTO: case NFT_GOTO:
nft_trace_packet(&info, chain, rule, nft_trace_packet(&info, chain, rule,
NFT_TRACETYPE_RULE); NFT_TRACETYPE_RULE);

Просмотреть файл

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* (C) 2011 Pablo Neira Ayuso <pablo@netfilter.org> * (C) 2011 Pablo Neira Ayuso <pablo@netfilter.org>
* (C) 2011 Intra2net AG <http://www.intra2net.com> * (C) 2011 Intra2net AG <https://www.intra2net.com>
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>

Просмотреть файл

@ -451,7 +451,7 @@ static int cttimeout_default_get(struct net *net, struct sock *ctnl,
case IPPROTO_TCP: case IPPROTO_TCP:
timeouts = nf_tcp_pernet(net)->timeouts; timeouts = nf_tcp_pernet(net)->timeouts;
break; break;
case IPPROTO_UDP: /* fallthrough */ case IPPROTO_UDP:
case IPPROTO_UDPLITE: case IPPROTO_UDPLITE:
timeouts = nf_udp_pernet(net)->timeouts; timeouts = nf_udp_pernet(net)->timeouts;
break; break;

Просмотреть файл

@ -43,7 +43,7 @@ void nft_cmp_eval(const struct nft_expr *expr,
case NFT_CMP_LT: case NFT_CMP_LT:
if (d == 0) if (d == 0)
goto mismatch; goto mismatch;
/* fall through */ fallthrough;
case NFT_CMP_LTE: case NFT_CMP_LTE:
if (d > 0) if (d > 0)
goto mismatch; goto mismatch;
@ -51,7 +51,7 @@ void nft_cmp_eval(const struct nft_expr *expr,
case NFT_CMP_GT: case NFT_CMP_GT:
if (d == 0) if (d == 0)
goto mismatch; goto mismatch;
/* fall through */ fallthrough;
case NFT_CMP_GTE: case NFT_CMP_GTE:
if (d < 0) if (d < 0)
goto mismatch; goto mismatch;

Просмотреть файл

@ -129,7 +129,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
return; return;
} }
#endif #endif
case NFT_CT_BYTES: /* fallthrough */ case NFT_CT_BYTES:
case NFT_CT_PKTS: { case NFT_CT_PKTS: {
const struct nf_conn_acct *acct = nf_conn_acct_find(ct); const struct nf_conn_acct *acct = nf_conn_acct_find(ct);
u64 count = 0; u64 count = 0;
@ -1013,8 +1013,8 @@ static int nft_ct_helper_obj_init(const struct nft_ctx *ctx,
help6 = nf_conntrack_helper_try_module_get(name, family, help6 = nf_conntrack_helper_try_module_get(name, family,
priv->l4proto); priv->l4proto);
break; break;
case NFPROTO_NETDEV: /* fallthrough */ case NFPROTO_NETDEV:
case NFPROTO_BRIDGE: /* same */ case NFPROTO_BRIDGE:
case NFPROTO_INET: case NFPROTO_INET:
help4 = nf_conntrack_helper_try_module_get(name, NFPROTO_IPV4, help4 = nf_conntrack_helper_try_module_get(name, NFPROTO_IPV4,
priv->l4proto); priv->l4proto);

Просмотреть файл

@ -32,7 +32,7 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
unsigned int hooks; unsigned int hooks;
switch (priv->result) { switch (priv->result) {
case NFT_FIB_RESULT_OIF: /* fallthrough */ case NFT_FIB_RESULT_OIF:
case NFT_FIB_RESULT_OIFNAME: case NFT_FIB_RESULT_OIFNAME:
hooks = (1 << NF_INET_PRE_ROUTING); hooks = (1 << NF_INET_PRE_ROUTING);
break; break;

Просмотреть файл

@ -103,9 +103,9 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx,
{ {
const struct nft_immediate_expr *priv = nft_expr_priv(expr); const struct nft_immediate_expr *priv = nft_expr_priv(expr);
const struct nft_data *data = &priv->data; const struct nft_data *data = &priv->data;
struct nft_rule *rule, *n;
struct nft_ctx chain_ctx; struct nft_ctx chain_ctx;
struct nft_chain *chain; struct nft_chain *chain;
struct nft_rule *rule;
if (priv->dreg != NFT_REG_VERDICT) if (priv->dreg != NFT_REG_VERDICT)
return; return;
@ -121,7 +121,7 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx,
chain_ctx = *ctx; chain_ctx = *ctx;
chain_ctx.chain = chain; chain_ctx.chain = chain;
list_for_each_entry(rule, &chain->rules, list) list_for_each_entry_safe(rule, n, &chain->rules, list)
nf_tables_rule_release(&chain_ctx, rule); nf_tables_rule_release(&chain_ctx, rule);
nf_tables_chain_destroy(&chain_ctx); nf_tables_chain_destroy(&chain_ctx);

Просмотреть файл

@ -467,7 +467,7 @@ static int nft_payload_l4csum_offset(const struct nft_pktinfo *pkt,
case IPPROTO_UDP: case IPPROTO_UDP:
if (!nft_payload_udp_checksum(skb, pkt->xt.thoff)) if (!nft_payload_udp_checksum(skb, pkt->xt.thoff))
return -1; return -1;
/* Fall through. */ fallthrough;
case IPPROTO_UDPLITE: case IPPROTO_UDPLITE:
*l4csum_offset = offsetof(struct udphdr, check); *l4csum_offset = offsetof(struct udphdr, check);
break; break;

Просмотреть файл

@ -312,7 +312,7 @@
* Jay Ligatti, Josh Kuhn, and Chris Gage. * Jay Ligatti, Josh Kuhn, and Chris Gage.
* Proceedings of the IEEE International Conference on Computer * Proceedings of the IEEE International Conference on Computer
* Communication Networks (ICCCN), August 2010. * Communication Networks (ICCCN), August 2010.
* http://www.cse.usf.edu/~ligatti/papers/grouper-conf.pdf * https://www.cse.usf.edu/~ligatti/papers/grouper-conf.pdf
* *
* [Rottenstreich 2010] * [Rottenstreich 2010]
* Worst-Case TCAM Rule Expansion * Worst-Case TCAM Rule Expansion
@ -325,7 +325,7 @@
* Kirill Kogan, Sergey Nikolenko, Ori Rottenstreich, William Culhane, * Kirill Kogan, Sergey Nikolenko, Ori Rottenstreich, William Culhane,
* and Patrick Eugster. * and Patrick Eugster.
* Proceedings of the 2014 ACM conference on SIGCOMM, August 2014. * Proceedings of the 2014 ACM conference on SIGCOMM, August 2014.
* http://www.sigcomm.org/sites/default/files/ccr/papers/2014/August/2619239-2626294.pdf * https://www.sigcomm.org/sites/default/files/ccr/papers/2014/August/2619239-2626294.pdf
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>

Просмотреть файл

@ -25,7 +25,7 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
break; break;
} }
/* fall through */ fallthrough;
case CHECKSUM_NONE: case CHECKSUM_NONE:
if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP) if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP)
skb->csum = 0; skb->csum = 0;
@ -51,7 +51,7 @@ static __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook,
case CHECKSUM_COMPLETE: case CHECKSUM_COMPLETE:
if (len == skb->len - dataoff) if (len == skb->len - dataoff)
return nf_ip_checksum(skb, hook, dataoff, protocol); return nf_ip_checksum(skb, hook, dataoff, protocol);
/* fall through */ fallthrough;
case CHECKSUM_NONE: case CHECKSUM_NONE:
skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, protocol, skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, protocol,
skb->len - dataoff, 0); skb->len - dataoff, 0);
@ -79,7 +79,7 @@ __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
break; break;
} }
/* fall through */ fallthrough;
case CHECKSUM_NONE: case CHECKSUM_NONE:
skb->csum = ~csum_unfold( skb->csum = ~csum_unfold(
csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
@ -106,7 +106,7 @@ static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,
case CHECKSUM_COMPLETE: case CHECKSUM_COMPLETE:
if (len == skb->len - dataoff) if (len == skb->len - dataoff)
return nf_ip6_checksum(skb, hook, dataoff, protocol); return nf_ip6_checksum(skb, hook, dataoff, protocol);
/* fall through */ fallthrough;
case CHECKSUM_NONE: case CHECKSUM_NONE:
hsum = skb_checksum(skb, 0, dataoff, 0); hsum = skb_checksum(skb, 0, dataoff, 0);
skb->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr, skb->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr,

Просмотреть файл

@ -1571,7 +1571,7 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void *v, loff_t *ppos,
trav->curr = trav->curr->next; trav->curr = trav->curr->next;
if (trav->curr != trav->head) if (trav->curr != trav->head)
break; break;
/* fall through */ fallthrough;
default: default:
return NULL; return NULL;
} }

Просмотреть файл

@ -6,7 +6,7 @@
* with the SECMARK target and state match. * with the SECMARK target and state match.
* *
* Based somewhat on CONNMARK: * Based somewhat on CONNMARK:
* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> * Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com>
* by Henrik Nordstrom <hno@marasystems.com> * by Henrik Nordstrom <hno@marasystems.com>
* *
* (C) 2006,2008 Red Hat, Inc., James Morris <jmorris@redhat.com> * (C) 2006,2008 Red Hat, Inc., James Morris <jmorris@redhat.com>

Просмотреть файл

@ -2,7 +2,7 @@
/* /*
* xt_connmark - Netfilter module to operate on connection marks * xt_connmark - Netfilter module to operate on connection marks
* *
* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> * Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com>
* by Henrik Nordstrom <hno@marasystems.com> * by Henrik Nordstrom <hno@marasystems.com>
* Copyright © CC Computer Consultants GmbH, 2007 - 2008 * Copyright © CC Computer Consultants GmbH, 2007 - 2008
* Jan Engelhardt <jengelh@medozas.de> * Jan Engelhardt <jengelh@medozas.de>

Просмотреть файл

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* (C) 2011 Pablo Neira Ayuso <pablo@netfilter.org> * (C) 2011 Pablo Neira Ayuso <pablo@netfilter.org>
* (C) 2011 Intra2net AG <http://www.intra2net.com> * (C) 2011 Intra2net AG <https://www.intra2net.com>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Просмотреть файл

@ -5,7 +5,7 @@
* based on ipt_time by Fabrice MARIE <fabrice@netfilter.org> * based on ipt_time by Fabrice MARIE <fabrice@netfilter.org>
* This is a module which is used for time matching * This is a module which is used for time matching
* It is using some modified code from dietlibc (localtime() function) * It is using some modified code from dietlibc (localtime() function)
* that you can find at http://www.fefe.de/dietlibc/ * that you can find at https://www.fefe.de/dietlibc/
* This file is distributed under the terms of the GNU General Public * This file is distributed under the terms of the GNU General Public
* License (GPL). Copies of the GPL can be obtained from gnu.org/gpl. * License (GPL). Copies of the GPL can be obtained from gnu.org/gpl.
*/ */