Skip to content

Commit 95337b9

Browse files
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 updates for net-next: 1) Remove the broute pseudo hook, implement this from the bridge prerouting hook instead. Now broute becomes real table in ebtables, from Florian Westphal. This also includes a size reduction patch for the bridge control buffer area via squashing boolean into bitfields and a selftest. 2) Add OS passive fingerprint version matching, from Fernando Fernandez. 3) Support for gue encapsulation for IPVS, from Jacky Hu. 4) Add support for NAT to the inet family, from Florian Westphal. This includes support for masquerade, redirect and nat extensions. 5) Skip interface lookup in flowtable, use device in the dst object. 6) Add jiffies64_to_msecs() and use it, from Li RongQing. 7) Remove unused parameter in nf_tables_set_desc_parse(), from Colin Ian King. 8) Statify several functions, patches from YueHaibing and Florian Westphal. 9) Add an optimized version of nf_inet_addr_cmp(), from Li RongQing. 10) Merge route extension to core, also from Florian. 11) Use IS_ENABLED(CONFIG_NF_NAT) instead of NF_NAT_NEEDED, from Florian. 12) Merge ip/ip6 masquerade extensions, from Florian. This includes netdevice notifier unification. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e62b2fd + dc2f418 commit 95337b9

Some content is hidden

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

57 files changed

+1187
-638
lines changed

include/linux/if_bridge.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ struct br_ip_list {
5656

5757
extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
5858

59-
typedef int br_should_route_hook_t(struct sk_buff *skb);
60-
extern br_should_route_hook_t __rcu *br_should_route_hook;
61-
6259
#if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)
6360
int br_multicast_list_adjacent(struct net_device *dev,
6461
struct list_head *br_ip_list);

include/linux/jiffies.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ static inline u64 jiffies_to_nsecs(const unsigned long j)
297297
}
298298

299299
extern u64 jiffies64_to_nsecs(u64 j);
300+
extern u64 jiffies64_to_msecs(u64 j);
300301

301302
extern unsigned long __msecs_to_jiffies(const unsigned int m);
302303
#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)

include/linux/netfilter.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ static inline int NF_DROP_GETERR(int verdict)
2424
static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
2525
const union nf_inet_addr *a2)
2626
{
27+
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
28+
const unsigned long *ul1 = (const unsigned long *)a1;
29+
const unsigned long *ul2 = (const unsigned long *)a2;
30+
31+
return ((ul1[0] ^ ul2[0]) | (ul1[1] ^ ul2[1])) == 0UL;
32+
#else
2733
return a1->all[0] == a2->all[0] &&
2834
a1->all[1] == a2->all[1] &&
2935
a1->all[2] == a2->all[2] &&
3036
a1->all[3] == a2->all[3];
37+
#endif
3138
}
3239

3340
static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
@@ -360,7 +367,7 @@ extern struct nf_nat_hook __rcu *nf_nat_hook;
360367
static inline void
361368
nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
362369
{
363-
#ifdef CONFIG_NF_NAT_NEEDED
370+
#if IS_ENABLED(CONFIG_NF_NAT)
364371
struct nf_nat_hook *nat_hook;
365372

366373
rcu_read_lock();

include/linux/netfilter/nfnetlink_osf.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ struct nf_osf_finger {
2121
struct nf_osf_user_finger finger;
2222
};
2323

24+
struct nf_osf_data {
25+
const char *genre;
26+
const char *version;
27+
};
28+
2429
bool nf_osf_match(const struct sk_buff *skb, u_int8_t family,
2530
int hooknum, struct net_device *in, struct net_device *out,
2631
const struct nf_osf_info *info, struct net *net,
2732
const struct list_head *nf_osf_fingers);
2833

29-
const char *nf_osf_find(const struct sk_buff *skb,
30-
const struct list_head *nf_osf_fingers,
31-
const int ttl_check);
34+
bool nf_osf_find(const struct sk_buff *skb,
35+
const struct list_head *nf_osf_fingers,
36+
const int ttl_check, struct nf_osf_data *data);
3237

3338
#endif /* _NFOSF_H */

include/linux/netfilter/x_tables.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ struct xt_table_info *xt_replace_table(struct xt_table *table,
317317
int *error);
318318

319319
struct xt_match *xt_find_match(u8 af, const char *name, u8 revision);
320-
struct xt_target *xt_find_target(u8 af, const char *name, u8 revision);
321320
struct xt_match *xt_request_find_match(u8 af, const char *name, u8 revision);
322321
struct xt_target *xt_request_find_target(u8 af, const char *name, u8 revision);
323322
int xt_find_revision(u8 af, const char *name, u8 revision, int target,

include/linux/netfilter_ipv6.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ static inline int nf_ip6_route(struct net *net, struct dst_entry **dst,
8787
}
8888

8989
int ip6_route_me_harder(struct net *net, struct sk_buff *skb);
90+
91+
static inline int nf_ip6_route_me_harder(struct net *net, struct sk_buff *skb)
92+
{
93+
#if IS_MODULE(CONFIG_IPV6)
94+
const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
95+
96+
if (!v6_ops)
97+
return -EHOSTUNREACH;
98+
99+
return v6_ops->route_me_harder(net, skb);
100+
#else
101+
return ip6_route_me_harder(net, skb);
102+
#endif
103+
}
104+
90105
__sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
91106
unsigned int dataoff, u_int8_t protocol);
92107

include/net/ip_vs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ struct ip_vs_dest_user_kern {
600600

601601
/* Address family of addr */
602602
u16 af;
603+
604+
u16 tun_type; /* tunnel type */
605+
__be16 tun_port; /* tunnel port */
603606
};
604607

605608

@@ -660,6 +663,8 @@ struct ip_vs_dest {
660663
atomic_t conn_flags; /* flags to copy to conn */
661664
atomic_t weight; /* server weight */
662665
atomic_t last_weight; /* server latest weight */
666+
__u16 tun_type; /* tunnel type */
667+
__be16 tun_port; /* tunnel port */
663668

664669
refcount_t refcnt; /* reference counter */
665670
struct ip_vs_stats stats; /* statistics */

include/net/netfilter/ipv4/nf_nat_masquerade.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

include/net/netfilter/ipv6/nf_nat_masquerade.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

include/net/netfilter/nf_conntrack_expect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct nf_conntrack_expect {
4848
/* Expectation class */
4949
unsigned int class;
5050

51-
#ifdef CONFIG_NF_NAT_NEEDED
51+
#if IS_ENABLED(CONFIG_NF_NAT)
5252
union nf_inet_addr saved_addr;
5353
/* This is the original per-proto part, used to map the
5454
* expected connection the way the recipient expects. */

include/net/netfilter/nf_nat.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ static inline bool nf_nat_oif_changed(unsigned int hooknum,
6969
#endif
7070
}
7171

72-
int nf_nat_register_fn(struct net *net, const struct nf_hook_ops *ops,
72+
int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops,
7373
const struct nf_hook_ops *nat_ops, unsigned int ops_count);
74-
void nf_nat_unregister_fn(struct net *net, const struct nf_hook_ops *ops,
74+
void nf_nat_unregister_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops,
7575
unsigned int ops_count);
7676

7777
unsigned int nf_nat_packet(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
@@ -98,6 +98,9 @@ void nf_nat_ipv4_unregister_fn(struct net *net, const struct nf_hook_ops *ops);
9898
int nf_nat_ipv6_register_fn(struct net *net, const struct nf_hook_ops *ops);
9999
void nf_nat_ipv6_unregister_fn(struct net *net, const struct nf_hook_ops *ops);
100100

101+
int nf_nat_inet_register_fn(struct net *net, const struct nf_hook_ops *ops);
102+
void nf_nat_inet_unregister_fn(struct net *net, const struct nf_hook_ops *ops);
103+
101104
unsigned int
102105
nf_nat_inet_fn(void *priv, struct sk_buff *skb,
103106
const struct nf_hook_state *state);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _NF_NAT_MASQUERADE_H_
3+
#define _NF_NAT_MASQUERADE_H_
4+
5+
#include <net/netfilter/nf_nat.h>
6+
7+
unsigned int
8+
nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum,
9+
const struct nf_nat_range2 *range,
10+
const struct net_device *out);
11+
12+
int nf_nat_masquerade_inet_register_notifiers(void);
13+
void nf_nat_masquerade_inet_unregister_notifiers(void);
14+
15+
unsigned int
16+
nf_nat_masquerade_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
17+
const struct net_device *out);
18+
19+
#endif /*_NF_NAT_MASQUERADE_H_ */

include/net/netfilter/nf_queue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,7 @@ nfqueue_hash(const struct sk_buff *skb, u16 queue, u16 queues_total, u8 family,
119119
return queue;
120120
}
121121

122+
int nf_queue(struct sk_buff *skb, struct nf_hook_state *state,
123+
const struct nf_hook_entries *entries, unsigned int index,
124+
unsigned int verdict);
122125
#endif /* _NF_QUEUE_H */

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,
475475
enum nft_trans_phase phase);
476476
int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,
477477
struct nft_set_binding *binding);
478-
void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set,
479-
struct nft_set_binding *binding, bool commit);
480478
void nf_tables_destroy_set(const struct nft_ctx *ctx, struct nft_set *set);
481479

482480
/**
@@ -1411,4 +1409,6 @@ struct nft_trans_flowtable {
14111409
int __init nft_chain_filter_init(void);
14121410
void nft_chain_filter_fini(void);
14131411

1412+
void __init nft_chain_route_init(void);
1413+
void nft_chain_route_fini(void);
14141414
#endif /* _NET_NF_TABLES_H */

include/uapi/linux/ip_vs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@
124124

125125
#define IP_VS_PEDATA_MAXLEN 255
126126

127+
/* Tunnel types */
128+
enum {
129+
IP_VS_CONN_F_TUNNEL_TYPE_IPIP = 0, /* IPIP */
130+
IP_VS_CONN_F_TUNNEL_TYPE_GUE, /* GUE */
131+
IP_VS_CONN_F_TUNNEL_TYPE_MAX,
132+
};
133+
127134
/*
128135
* The struct ip_vs_service_user and struct ip_vs_dest_user are
129136
* used to set IPVS rules through setsockopt.
@@ -392,6 +399,10 @@ enum {
392399

393400
IPVS_DEST_ATTR_STATS64, /* nested attribute for dest stats */
394401

402+
IPVS_DEST_ATTR_TUN_TYPE, /* tunnel type */
403+
404+
IPVS_DEST_ATTR_TUN_PORT, /* tunnel port */
405+
395406
__IPVS_DEST_ATTR_MAX,
396407
};
397408

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,15 +1522,21 @@ enum nft_flowtable_hook_attributes {
15221522
*
15231523
* @NFTA_OSF_DREG: destination register (NLA_U32: nft_registers)
15241524
* @NFTA_OSF_TTL: Value of the TTL osf option (NLA_U8)
1525+
* @NFTA_OSF_FLAGS: flags (NLA_U32)
15251526
*/
15261527
enum nft_osf_attributes {
15271528
NFTA_OSF_UNSPEC,
15281529
NFTA_OSF_DREG,
15291530
NFTA_OSF_TTL,
1531+
NFTA_OSF_FLAGS,
15301532
__NFTA_OSF_MAX,
15311533
};
15321534
#define NFTA_OSF_MAX (__NFTA_OSF_MAX - 1)
15331535

1536+
enum nft_osf_flags {
1537+
NFT_OSF_F_VERSION = (1 << 0),
1538+
};
1539+
15341540
/**
15351541
* enum nft_device_attributes - nf_tables device netlink attributes
15361542
*

kernel/time/time.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,16 @@ u64 jiffies64_to_nsecs(u64 j)
783783
}
784784
EXPORT_SYMBOL(jiffies64_to_nsecs);
785785

786+
u64 jiffies64_to_msecs(const u64 j)
787+
{
788+
#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
789+
return (MSEC_PER_SEC / HZ) * j;
790+
#else
791+
return div_u64(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
792+
#endif
793+
}
794+
EXPORT_SYMBOL(jiffies64_to_msecs);
795+
786796
/**
787797
* nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64
788798
*

net/bridge/br_arp_nd_proxy.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
131131
u8 *arpptr, *sha;
132132
__be32 sip, tip;
133133

134-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = false;
134+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
135135

136136
if ((dev->flags & IFF_NOARP) ||
137137
!pskb_may_pull(skb, arp_hdr_len(dev)))
@@ -161,7 +161,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
161161
return;
162162
if (ipv4_is_zeronet(sip) || sip == tip) {
163163
/* prevent flooding to neigh suppress ports */
164-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
164+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
165165
return;
166166
}
167167
}
@@ -181,7 +181,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
181181
/* its our local ip, so don't proxy reply
182182
* and don't forward to neigh suppress ports
183183
*/
184-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
184+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
185185
return;
186186
}
187187

@@ -217,7 +217,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
217217
*/
218218
if (replied ||
219219
br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED))
220-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
220+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
221221
}
222222

223223
neigh_release(n);
@@ -393,15 +393,15 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
393393
struct ipv6hdr *iphdr;
394394
struct neighbour *n;
395395

396-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = false;
396+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
397397

398398
if (p && (p->flags & BR_NEIGH_SUPPRESS))
399399
return;
400400

401401
if (msg->icmph.icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT &&
402402
!msg->icmph.icmp6_solicited) {
403403
/* prevent flooding to neigh suppress ports */
404-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
404+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
405405
return;
406406
}
407407

@@ -414,7 +414,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
414414

415415
if (ipv6_addr_any(saddr) || !ipv6_addr_cmp(saddr, daddr)) {
416416
/* prevent flooding to neigh suppress ports */
417-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
417+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
418418
return;
419419
}
420420

@@ -432,7 +432,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
432432
/* its our own ip, so don't proxy reply
433433
* and don't forward to arp suppress ports
434434
*/
435-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
435+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
436436
return;
437437
}
438438

@@ -465,7 +465,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
465465
*/
466466
if (replied ||
467467
br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED))
468-
BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
468+
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
469469
}
470470
neigh_release(n);
471471
}

0 commit comments

Comments
 (0)