Skip to content

Commit c162610

Browse files
author
Jakub Kicinski
committed
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 Netfilter/IPVS updates for net-next: 1) Rename mss field to mss_option field in synproxy, from Fernando Mancera. 2) Use SYSCTL_{ZERO,ONE} definitions in conntrack, from Matteo Croce. 3) More strict validation of IPVS sysctl values, from Junwei Hu. 4) Remove unnecessary spaces after on the right hand side of assignments, from yangxingwu. 5) Add offload support for bitwise operation. 6) Extend the nft_offload_reg structure to store immediate date. 7) Collapse several ip_set header files into ip_set.h, from Jeremy Sowden. 8) Make netfilter headers compile with CONFIG_KERNEL_HEADER_TEST=y, from Jeremy Sowden. 9) Fix several sparse warnings due to missing prototypes, from Valdis Kletnieks. 10) Use static lock initialiser to ensure connlabel spinlock is initialized on boot time to fix sched/act_ct.c, patch from Florian Westphal. ==================== Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
2 parents b753c5a + 1053334 commit c162610

76 files changed

Lines changed: 527 additions & 480 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎include/Kbuild‎

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -386,31 +386,6 @@ header-test- += linux/mvebu-pmsu.h
386386
header-test- += linux/mxm-wmi.h
387387
header-test- += linux/n_r3964.h
388388
header-test- += linux/ndctl.h
389-
header-test- += linux/netfilter/ipset/ip_set.h
390-
header-test- += linux/netfilter/ipset/ip_set_bitmap.h
391-
header-test- += linux/netfilter/ipset/ip_set_comment.h
392-
header-test- += linux/netfilter/ipset/ip_set_counter.h
393-
header-test- += linux/netfilter/ipset/ip_set_getport.h
394-
header-test- += linux/netfilter/ipset/ip_set_hash.h
395-
header-test- += linux/netfilter/ipset/ip_set_list.h
396-
header-test- += linux/netfilter/ipset/ip_set_skbinfo.h
397-
header-test- += linux/netfilter/ipset/ip_set_timeout.h
398-
header-test- += linux/netfilter/nf_conntrack_amanda.h
399-
header-test- += linux/netfilter/nf_conntrack_ftp.h
400-
header-test- += linux/netfilter/nf_conntrack_h323.h
401-
header-test- += linux/netfilter/nf_conntrack_h323_asn1.h
402-
header-test- += linux/netfilter/nf_conntrack_irc.h
403-
header-test- += linux/netfilter/nf_conntrack_pptp.h
404-
header-test- += linux/netfilter/nf_conntrack_proto_gre.h
405-
header-test- += linux/netfilter/nf_conntrack_sip.h
406-
header-test- += linux/netfilter/nf_conntrack_snmp.h
407-
header-test- += linux/netfilter/nf_conntrack_tftp.h
408-
header-test- += linux/netfilter/x_tables.h
409-
header-test- += linux/netfilter_arp/arp_tables.h
410-
header-test- += linux/netfilter_bridge/ebtables.h
411-
header-test- += linux/netfilter_ipv4/ip4_tables.h
412-
header-test- += linux/netfilter_ipv4/ip_tables.h
413-
header-test- += linux/netfilter_ipv6/ip6_tables.h
414389
header-test- += linux/nfs.h
415390
header-test- += linux/nfs_fs_i.h
416391
header-test- += linux/nfs_fs_sb.h
@@ -874,43 +849,6 @@ header-test- += net/mpls_iptunnel.h
874849
header-test- += net/mrp.h
875850
header-test- += net/ncsi.h
876851
header-test- += net/netevent.h
877-
header-test- += net/netfilter/br_netfilter.h
878-
header-test- += net/netfilter/ipv4/nf_dup_ipv4.h
879-
header-test- += net/netfilter/ipv6/nf_defrag_ipv6.h
880-
header-test- += net/netfilter/ipv6/nf_dup_ipv6.h
881-
header-test- += net/netfilter/nf_conntrack.h
882-
header-test- += net/netfilter/nf_conntrack_acct.h
883-
header-test- += net/netfilter/nf_conntrack_bridge.h
884-
header-test- += net/netfilter/nf_conntrack_core.h
885-
header-test- += net/netfilter/nf_conntrack_count.h
886-
header-test- += net/netfilter/nf_conntrack_ecache.h
887-
header-test- += net/netfilter/nf_conntrack_expect.h
888-
header-test- += net/netfilter/nf_conntrack_extend.h
889-
header-test- += net/netfilter/nf_conntrack_helper.h
890-
header-test- += net/netfilter/nf_conntrack_l4proto.h
891-
header-test- += net/netfilter/nf_conntrack_labels.h
892-
header-test- += net/netfilter/nf_conntrack_seqadj.h
893-
header-test- += net/netfilter/nf_conntrack_synproxy.h
894-
header-test- += net/netfilter/nf_conntrack_timeout.h
895-
header-test- += net/netfilter/nf_conntrack_timestamp.h
896-
header-test- += net/netfilter/nf_conntrack_tuple.h
897-
header-test- += net/netfilter/nf_dup_netdev.h
898-
header-test- += net/netfilter/nf_flow_table.h
899-
header-test- += net/netfilter/nf_nat.h
900-
header-test- += net/netfilter/nf_nat_helper.h
901-
header-test- += net/netfilter/nf_nat_masquerade.h
902-
header-test- += net/netfilter/nf_nat_redirect.h
903-
header-test- += net/netfilter/nf_queue.h
904-
header-test- += net/netfilter/nf_reject.h
905-
header-test- += net/netfilter/nf_synproxy.h
906-
header-test-$(CONFIG_NF_TABLES) += net/netfilter/nf_tables.h
907-
header-test-$(CONFIG_NF_TABLES) += net/netfilter/nf_tables_core.h
908-
header-test-$(CONFIG_NF_TABLES) += net/netfilter/nf_tables_ipv4.h
909-
header-test- += net/netfilter/nf_tables_ipv6.h
910-
header-test-$(CONFIG_NF_TABLES) += net/netfilter/nf_tables_offload.h
911-
header-test- += net/netfilter/nft_fib.h
912-
header-test- += net/netfilter/nft_meta.h
913-
header-test- += net/netfilter/nft_reject.h
914852
header-test- += net/netns/can.h
915853
header-test- += net/netns/generic.h
916854
header-test- += net/netns/ieee802154_6lowpan.h
@@ -1140,18 +1078,6 @@ header-test- += uapi/linux/kvm_para.h
11401078
header-test- += uapi/linux/lightnvm.h
11411079
header-test- += uapi/linux/mic_common.h
11421080
header-test- += uapi/linux/mman.h
1143-
header-test- += uapi/linux/netfilter/ipset/ip_set_bitmap.h
1144-
header-test- += uapi/linux/netfilter/ipset/ip_set_hash.h
1145-
header-test- += uapi/linux/netfilter/ipset/ip_set_list.h
1146-
header-test- += uapi/linux/netfilter/nf_synproxy.h
1147-
header-test- += uapi/linux/netfilter/xt_policy.h
1148-
header-test- += uapi/linux/netfilter/xt_set.h
1149-
header-test- += uapi/linux/netfilter_arp/arp_tables.h
1150-
header-test- += uapi/linux/netfilter_arp/arpt_mangle.h
1151-
header-test- += uapi/linux/netfilter_ipv4/ip_tables.h
1152-
header-test- += uapi/linux/netfilter_ipv4/ipt_LOG.h
1153-
header-test- += uapi/linux/netfilter_ipv6/ip6_tables.h
1154-
header-test- += uapi/linux/netfilter_ipv6/ip6t_LOG.h
11551081
header-test- += uapi/linux/nilfs2_ondisk.h
11561082
header-test- += uapi/linux/patchkey.h
11571083
header-test- += uapi/linux/ptrace.h

‎include/linux/netfilter/ipset/ip_set.h‎

Lines changed: 234 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,240 @@ bitmap_bytes(u32 a, u32 b)
452452
return 4 * ((((b - a + 8) / 8) + 3) / 4);
453453
}
454454

455-
#include <linux/netfilter/ipset/ip_set_timeout.h>
456-
#include <linux/netfilter/ipset/ip_set_comment.h>
457-
#include <linux/netfilter/ipset/ip_set_counter.h>
458-
#include <linux/netfilter/ipset/ip_set_skbinfo.h>
455+
/* How often should the gc be run by default */
456+
#define IPSET_GC_TIME (3 * 60)
457+
458+
/* Timeout period depending on the timeout value of the given set */
459+
#define IPSET_GC_PERIOD(timeout) \
460+
((timeout/3) ? min_t(u32, (timeout)/3, IPSET_GC_TIME) : 1)
461+
462+
/* Entry is set with no timeout value */
463+
#define IPSET_ELEM_PERMANENT 0
464+
465+
/* Set is defined with timeout support: timeout value may be 0 */
466+
#define IPSET_NO_TIMEOUT UINT_MAX
467+
468+
/* Max timeout value, see msecs_to_jiffies() in jiffies.h */
469+
#define IPSET_MAX_TIMEOUT (UINT_MAX >> 1)/MSEC_PER_SEC
470+
471+
#define ip_set_adt_opt_timeout(opt, set) \
472+
((opt)->ext.timeout != IPSET_NO_TIMEOUT ? (opt)->ext.timeout : (set)->timeout)
473+
474+
static inline unsigned int
475+
ip_set_timeout_uget(struct nlattr *tb)
476+
{
477+
unsigned int timeout = ip_set_get_h32(tb);
478+
479+
/* Normalize to fit into jiffies */
480+
if (timeout > IPSET_MAX_TIMEOUT)
481+
timeout = IPSET_MAX_TIMEOUT;
482+
483+
return timeout;
484+
}
485+
486+
static inline bool
487+
ip_set_timeout_expired(const unsigned long *t)
488+
{
489+
return *t != IPSET_ELEM_PERMANENT && time_is_before_jiffies(*t);
490+
}
491+
492+
static inline void
493+
ip_set_timeout_set(unsigned long *timeout, u32 value)
494+
{
495+
unsigned long t;
496+
497+
if (!value) {
498+
*timeout = IPSET_ELEM_PERMANENT;
499+
return;
500+
}
501+
502+
t = msecs_to_jiffies(value * MSEC_PER_SEC) + jiffies;
503+
if (t == IPSET_ELEM_PERMANENT)
504+
/* Bingo! :-) */
505+
t--;
506+
*timeout = t;
507+
}
508+
509+
static inline u32
510+
ip_set_timeout_get(const unsigned long *timeout)
511+
{
512+
u32 t;
513+
514+
if (*timeout == IPSET_ELEM_PERMANENT)
515+
return 0;
516+
517+
t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
518+
/* Zero value in userspace means no timeout */
519+
return t == 0 ? 1 : t;
520+
}
521+
522+
static inline char*
523+
ip_set_comment_uget(struct nlattr *tb)
524+
{
525+
return nla_data(tb);
526+
}
527+
528+
/* Called from uadd only, protected by the set spinlock.
529+
* The kadt functions don't use the comment extensions in any way.
530+
*/
531+
static inline void
532+
ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment,
533+
const struct ip_set_ext *ext)
534+
{
535+
struct ip_set_comment_rcu *c = rcu_dereference_protected(comment->c, 1);
536+
size_t len = ext->comment ? strlen(ext->comment) : 0;
537+
538+
if (unlikely(c)) {
539+
set->ext_size -= sizeof(*c) + strlen(c->str) + 1;
540+
kfree_rcu(c, rcu);
541+
rcu_assign_pointer(comment->c, NULL);
542+
}
543+
if (!len)
544+
return;
545+
if (unlikely(len > IPSET_MAX_COMMENT_SIZE))
546+
len = IPSET_MAX_COMMENT_SIZE;
547+
c = kmalloc(sizeof(*c) + len + 1, GFP_ATOMIC);
548+
if (unlikely(!c))
549+
return;
550+
strlcpy(c->str, ext->comment, len + 1);
551+
set->ext_size += sizeof(*c) + strlen(c->str) + 1;
552+
rcu_assign_pointer(comment->c, c);
553+
}
554+
555+
/* Used only when dumping a set, protected by rcu_read_lock() */
556+
static inline int
557+
ip_set_put_comment(struct sk_buff *skb, const struct ip_set_comment *comment)
558+
{
559+
struct ip_set_comment_rcu *c = rcu_dereference(comment->c);
560+
561+
if (!c)
562+
return 0;
563+
return nla_put_string(skb, IPSET_ATTR_COMMENT, c->str);
564+
}
565+
566+
/* Called from uadd/udel, flush or the garbage collectors protected
567+
* by the set spinlock.
568+
* Called when the set is destroyed and when there can't be any user
569+
* of the set data anymore.
570+
*/
571+
static inline void
572+
ip_set_comment_free(struct ip_set *set, struct ip_set_comment *comment)
573+
{
574+
struct ip_set_comment_rcu *c;
575+
576+
c = rcu_dereference_protected(comment->c, 1);
577+
if (unlikely(!c))
578+
return;
579+
set->ext_size -= sizeof(*c) + strlen(c->str) + 1;
580+
kfree_rcu(c, rcu);
581+
rcu_assign_pointer(comment->c, NULL);
582+
}
583+
584+
static inline void
585+
ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
586+
{
587+
atomic64_add((long long)bytes, &(counter)->bytes);
588+
}
589+
590+
static inline void
591+
ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
592+
{
593+
atomic64_add((long long)packets, &(counter)->packets);
594+
}
595+
596+
static inline u64
597+
ip_set_get_bytes(const struct ip_set_counter *counter)
598+
{
599+
return (u64)atomic64_read(&(counter)->bytes);
600+
}
601+
602+
static inline u64
603+
ip_set_get_packets(const struct ip_set_counter *counter)
604+
{
605+
return (u64)atomic64_read(&(counter)->packets);
606+
}
607+
608+
static inline bool
609+
ip_set_match_counter(u64 counter, u64 match, u8 op)
610+
{
611+
switch (op) {
612+
case IPSET_COUNTER_NONE:
613+
return true;
614+
case IPSET_COUNTER_EQ:
615+
return counter == match;
616+
case IPSET_COUNTER_NE:
617+
return counter != match;
618+
case IPSET_COUNTER_LT:
619+
return counter < match;
620+
case IPSET_COUNTER_GT:
621+
return counter > match;
622+
}
623+
return false;
624+
}
625+
626+
static inline void
627+
ip_set_update_counter(struct ip_set_counter *counter,
628+
const struct ip_set_ext *ext, u32 flags)
629+
{
630+
if (ext->packets != ULLONG_MAX &&
631+
!(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
632+
ip_set_add_bytes(ext->bytes, counter);
633+
ip_set_add_packets(ext->packets, counter);
634+
}
635+
}
636+
637+
static inline bool
638+
ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter)
639+
{
640+
return nla_put_net64(skb, IPSET_ATTR_BYTES,
641+
cpu_to_be64(ip_set_get_bytes(counter)),
642+
IPSET_ATTR_PAD) ||
643+
nla_put_net64(skb, IPSET_ATTR_PACKETS,
644+
cpu_to_be64(ip_set_get_packets(counter)),
645+
IPSET_ATTR_PAD);
646+
}
647+
648+
static inline void
649+
ip_set_init_counter(struct ip_set_counter *counter,
650+
const struct ip_set_ext *ext)
651+
{
652+
if (ext->bytes != ULLONG_MAX)
653+
atomic64_set(&(counter)->bytes, (long long)(ext->bytes));
654+
if (ext->packets != ULLONG_MAX)
655+
atomic64_set(&(counter)->packets, (long long)(ext->packets));
656+
}
657+
658+
static inline void
659+
ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo,
660+
const struct ip_set_ext *ext,
661+
struct ip_set_ext *mext, u32 flags)
662+
{
663+
mext->skbinfo = *skbinfo;
664+
}
665+
666+
static inline bool
667+
ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo)
668+
{
669+
/* Send nonzero parameters only */
670+
return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
671+
nla_put_net64(skb, IPSET_ATTR_SKBMARK,
672+
cpu_to_be64((u64)skbinfo->skbmark << 32 |
673+
skbinfo->skbmarkmask),
674+
IPSET_ATTR_PAD)) ||
675+
(skbinfo->skbprio &&
676+
nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
677+
cpu_to_be32(skbinfo->skbprio))) ||
678+
(skbinfo->skbqueue &&
679+
nla_put_net16(skb, IPSET_ATTR_SKBQUEUE,
680+
cpu_to_be16(skbinfo->skbqueue)));
681+
}
682+
683+
static inline void
684+
ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo,
685+
const struct ip_set_ext *ext)
686+
{
687+
*skbinfo = ext->skbinfo;
688+
}
459689

460690
#define IP_SET_INIT_KEXT(skb, opt, set) \
461691
{ .bytes = (skb)->len, .packets = 1, \

0 commit comments

Comments
 (0)