You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller:
1) GRE now works over ipv6, from Dmitry Kozlov.
2) Make SCTP more network namespace aware, from Eric Biederman.
3) TEAM driver now works with non-ethernet devices, from Jiri Pirko.
4) Make openvswitch network namespace aware, from Pravin B Shelar.
5) IPV6 NAT implementation, from Patrick McHardy.
6) Server side support for TCP Fast Open, from Jerry Chu and others.
7) Packet BPF filter supports MOD and XOR, from Eric Dumazet and Daniel
Borkmann.
8) Increate the loopback default MTU to 64K, from Eric Dumazet.
9) Use a per-task rather than per-socket page fragment allocator for
outgoing networking traffic. This benefits processes that have very
many mostly idle sockets, which is quite common.
From Eric Dumazet.
10) Use up to 32K for page fragment allocations, with fallbacks to
smaller sizes when higher order page allocations fail. Benefits are
a) less segments for driver to process b) less calls to page
allocator c) less waste of space.
From Eric Dumazet.
11) Allow GRO to be used on GRE tunnels, from Eric Dumazet.
12) VXLAN device driver, one way to handle VLAN issues such as the
limitation of 4096 VLAN IDs yet still have some level of isolation.
From Stephen Hemminger.
13) As usual there is a large boatload of driver changes, with the scale
perhaps tilted towards the wireless side this time around.
Fix up various fairly trivial conflicts, mostly caused by the user
namespace changes.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1012 commits)
hyperv: Add buffer for extended info after the RNDIS response message.
hyperv: Report actual status in receive completion packet
hyperv: Remove extra allocated space for recv_pkt_list elements
hyperv: Fix page buffer handling in rndis_filter_send_request()
hyperv: Fix the missing return value in rndis_filter_set_packet_filter()
hyperv: Fix the max_xfer_size in RNDIS initialization
vxlan: put UDP socket in correct namespace
vxlan: Depend on CONFIG_INET
sfc: Fix the reported priorities of different filter types
sfc: Remove EFX_FILTER_FLAG_RX_OVERRIDE_IP
sfc: Fix loopback self-test with separate_tx_channels=1
sfc: Fix MCDI structure field lookup
sfc: Add parentheses around use of bitfield macro arguments
sfc: Fix null function pointer in efx_sriov_channel_type
vxlan: virtual extensible lan
igmp: export symbol ip_mc_leave_group
netlink: add attributes to fdb interface
tg3: unconditionally select HWMON support when tg3 is enabled.
Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT"
gre: fix sparse warning
...
This commit is contained in:
+70
-13
@@ -356,6 +356,55 @@ config NETFILTER_NETLINK_QUEUE_CT
|
||||
If this option is enabled, NFQUEUE can include Connection Tracking
|
||||
information together with the packet is the enqueued via NFNETLINK.
|
||||
|
||||
config NF_NAT
|
||||
tristate
|
||||
|
||||
config NF_NAT_NEEDED
|
||||
bool
|
||||
depends on NF_NAT
|
||||
default y
|
||||
|
||||
config NF_NAT_PROTO_DCCP
|
||||
tristate
|
||||
depends on NF_NAT && NF_CT_PROTO_DCCP
|
||||
default NF_NAT && NF_CT_PROTO_DCCP
|
||||
|
||||
config NF_NAT_PROTO_UDPLITE
|
||||
tristate
|
||||
depends on NF_NAT && NF_CT_PROTO_UDPLITE
|
||||
default NF_NAT && NF_CT_PROTO_UDPLITE
|
||||
|
||||
config NF_NAT_PROTO_SCTP
|
||||
tristate
|
||||
default NF_NAT && NF_CT_PROTO_SCTP
|
||||
depends on NF_NAT && NF_CT_PROTO_SCTP
|
||||
select LIBCRC32C
|
||||
|
||||
config NF_NAT_AMANDA
|
||||
tristate
|
||||
depends on NF_CONNTRACK && NF_NAT
|
||||
default NF_NAT && NF_CONNTRACK_AMANDA
|
||||
|
||||
config NF_NAT_FTP
|
||||
tristate
|
||||
depends on NF_CONNTRACK && NF_NAT
|
||||
default NF_NAT && NF_CONNTRACK_FTP
|
||||
|
||||
config NF_NAT_IRC
|
||||
tristate
|
||||
depends on NF_CONNTRACK && NF_NAT
|
||||
default NF_NAT && NF_CONNTRACK_IRC
|
||||
|
||||
config NF_NAT_SIP
|
||||
tristate
|
||||
depends on NF_CONNTRACK && NF_NAT
|
||||
default NF_NAT && NF_CONNTRACK_SIP
|
||||
|
||||
config NF_NAT_TFTP
|
||||
tristate
|
||||
depends on NF_CONNTRACK && NF_NAT
|
||||
default NF_NAT && NF_CONNTRACK_TFTP
|
||||
|
||||
endif # NF_CONNTRACK
|
||||
|
||||
# transparent proxy support
|
||||
@@ -599,6 +648,16 @@ config NETFILTER_XT_TARGET_MARK
|
||||
(e.g. when running oldconfig). It selects
|
||||
CONFIG_NETFILTER_XT_MARK (combined mark/MARK module).
|
||||
|
||||
config NETFILTER_XT_TARGET_NETMAP
|
||||
tristate '"NETMAP" target support'
|
||||
depends on NF_NAT
|
||||
---help---
|
||||
NETMAP is an implementation of static 1:1 NAT mapping of network
|
||||
addresses. It maps the network address part, while keeping the host
|
||||
address part intact.
|
||||
|
||||
To compile it as a module, choose M here. If unsure, say N.
|
||||
|
||||
config NETFILTER_XT_TARGET_NFLOG
|
||||
tristate '"NFLOG" target support'
|
||||
default m if NETFILTER_ADVANCED=n
|
||||
@@ -621,19 +680,6 @@ config NETFILTER_XT_TARGET_NFQUEUE
|
||||
|
||||
To compile it as a module, choose M here. If unsure, say N.
|
||||
|
||||
config NETFILTER_XT_TARGET_NOTRACK
|
||||
tristate '"NOTRACK" target support'
|
||||
depends on IP_NF_RAW || IP6_NF_RAW
|
||||
depends on NF_CONNTRACK
|
||||
help
|
||||
The NOTRACK target allows a select rule to specify
|
||||
which packets *not* to enter the conntrack/NAT
|
||||
subsystem with all the consequences (no ICMP error tracking,
|
||||
no protocol helpers for the selected packets).
|
||||
|
||||
If you want to compile it as a module, say M here and read
|
||||
<file:Documentation/kbuild/modules.txt>. If unsure, say `N'.
|
||||
|
||||
config NETFILTER_XT_TARGET_RATEEST
|
||||
tristate '"RATEEST" target support'
|
||||
depends on NETFILTER_ADVANCED
|
||||
@@ -644,6 +690,17 @@ config NETFILTER_XT_TARGET_RATEEST
|
||||
|
||||
To compile it as a module, choose M here. If unsure, say N.
|
||||
|
||||
config NETFILTER_XT_TARGET_REDIRECT
|
||||
tristate "REDIRECT target support"
|
||||
depends on NF_NAT
|
||||
---help---
|
||||
REDIRECT is a special case of NAT: all incoming connections are
|
||||
mapped onto the incoming interface's address, causing the packets to
|
||||
come to the local machine instead of passing through. This is
|
||||
useful for transparent proxies.
|
||||
|
||||
To compile it as a module, choose M here. If unsure, say N.
|
||||
|
||||
config NETFILTER_XT_TARGET_TEE
|
||||
tristate '"TEE" - packet cloning to alternate destination'
|
||||
depends on NETFILTER_ADVANCED
|
||||
|
||||
+20
-1
@@ -43,6 +43,23 @@ obj-$(CONFIG_NF_CONNTRACK_SANE) += nf_conntrack_sane.o
|
||||
obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o
|
||||
obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o
|
||||
|
||||
nf_nat-y := nf_nat_core.o nf_nat_proto_unknown.o nf_nat_proto_common.o \
|
||||
nf_nat_proto_udp.o nf_nat_proto_tcp.o nf_nat_helper.o
|
||||
|
||||
obj-$(CONFIG_NF_NAT) += nf_nat.o
|
||||
|
||||
# NAT protocols (nf_nat)
|
||||
obj-$(CONFIG_NF_NAT_PROTO_DCCP) += nf_nat_proto_dccp.o
|
||||
obj-$(CONFIG_NF_NAT_PROTO_UDPLITE) += nf_nat_proto_udplite.o
|
||||
obj-$(CONFIG_NF_NAT_PROTO_SCTP) += nf_nat_proto_sctp.o
|
||||
|
||||
# NAT helpers
|
||||
obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o
|
||||
obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o
|
||||
obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o
|
||||
obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
|
||||
obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o
|
||||
|
||||
# transparent proxy support
|
||||
obj-$(CONFIG_NETFILTER_TPROXY) += nf_tproxy_core.o
|
||||
|
||||
@@ -53,6 +70,7 @@ obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
|
||||
obj-$(CONFIG_NETFILTER_XT_MARK) += xt_mark.o
|
||||
obj-$(CONFIG_NETFILTER_XT_CONNMARK) += xt_connmark.o
|
||||
obj-$(CONFIG_NETFILTER_XT_SET) += xt_set.o
|
||||
obj-$(CONFIG_NF_NAT) += xt_nat.o
|
||||
|
||||
# targets
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_AUDIT) += xt_AUDIT.o
|
||||
@@ -65,10 +83,11 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_HL) += xt_HL.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_HMARK) += xt_HMARK.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_LOG) += xt_LOG.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_NETMAP) += xt_NETMAP.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_RATEEST) += xt_RATEEST.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_REDIRECT) += xt_REDIRECT.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_TPROXY) += xt_TPROXY.o
|
||||
obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o
|
||||
|
||||
+12
-9
@@ -126,7 +126,7 @@ unsigned int nf_iterate(struct list_head *head,
|
||||
unsigned int hook,
|
||||
const struct net_device *indev,
|
||||
const struct net_device *outdev,
|
||||
struct list_head **i,
|
||||
struct nf_hook_ops **elemp,
|
||||
int (*okfn)(struct sk_buff *),
|
||||
int hook_thresh)
|
||||
{
|
||||
@@ -136,22 +136,20 @@ unsigned int nf_iterate(struct list_head *head,
|
||||
* The caller must not block between calls to this
|
||||
* function because of risk of continuing from deleted element.
|
||||
*/
|
||||
list_for_each_continue_rcu(*i, head) {
|
||||
struct nf_hook_ops *elem = (struct nf_hook_ops *)*i;
|
||||
|
||||
if (hook_thresh > elem->priority)
|
||||
list_for_each_entry_continue_rcu((*elemp), head, list) {
|
||||
if (hook_thresh > (*elemp)->priority)
|
||||
continue;
|
||||
|
||||
/* Optimization: we don't need to hold module
|
||||
reference here, since function can't sleep. --RR */
|
||||
repeat:
|
||||
verdict = elem->hook(hook, skb, indev, outdev, okfn);
|
||||
verdict = (*elemp)->hook(hook, skb, indev, outdev, okfn);
|
||||
if (verdict != NF_ACCEPT) {
|
||||
#ifdef CONFIG_NETFILTER_DEBUG
|
||||
if (unlikely((verdict & NF_VERDICT_MASK)
|
||||
> NF_MAX_VERDICT)) {
|
||||
NFDEBUG("Evil return from %p(%u).\n",
|
||||
elem->hook, hook);
|
||||
(*elemp)->hook, hook);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@@ -172,14 +170,14 @@ int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
|
||||
int (*okfn)(struct sk_buff *),
|
||||
int hook_thresh)
|
||||
{
|
||||
struct list_head *elem;
|
||||
struct nf_hook_ops *elem;
|
||||
unsigned int verdict;
|
||||
int ret = 0;
|
||||
|
||||
/* We may already have this, but read-locks nest anyway */
|
||||
rcu_read_lock();
|
||||
|
||||
elem = &nf_hooks[pf][hook];
|
||||
elem = list_entry_rcu(&nf_hooks[pf][hook], struct nf_hook_ops, list);
|
||||
next_hook:
|
||||
verdict = nf_iterate(&nf_hooks[pf][hook], skb, hook, indev,
|
||||
outdev, &elem, okfn, hook_thresh);
|
||||
@@ -273,6 +271,11 @@ EXPORT_SYMBOL_GPL(nfq_ct_nat_hook);
|
||||
|
||||
#endif /* CONFIG_NF_CONNTRACK */
|
||||
|
||||
#ifdef CONFIG_NF_NAT_NEEDED
|
||||
void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *);
|
||||
EXPORT_SYMBOL(nf_nat_decode_session_hook);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_net_netfilter;
|
||||
EXPORT_SYMBOL(proc_net_netfilter);
|
||||
|
||||
@@ -27,9 +27,12 @@
|
||||
#define IP_SET_BITMAP_TIMEOUT
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 0
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("bitmap:ip type of IP sets");
|
||||
IP_SET_MODULE_DESC("bitmap:ip", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_bitmap:ip");
|
||||
|
||||
/* Type structure */
|
||||
@@ -284,7 +287,7 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
} else if (tb[IPSET_ATTR_CIDR]) {
|
||||
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
|
||||
if (cidr > 32)
|
||||
if (!cidr || cidr > 32)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
ip_set_mask_from_to(ip, ip_to, cidr);
|
||||
} else
|
||||
@@ -454,7 +457,8 @@ static int
|
||||
bitmap_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
{
|
||||
struct bitmap_ip *map;
|
||||
u32 first_ip, last_ip, hosts, elements;
|
||||
u32 first_ip, last_ip, hosts;
|
||||
u64 elements;
|
||||
u8 netmask = 32;
|
||||
int ret;
|
||||
|
||||
@@ -497,7 +501,7 @@ bitmap_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
|
||||
if (netmask == 32) {
|
||||
hosts = 1;
|
||||
elements = last_ip - first_ip + 1;
|
||||
elements = (u64)last_ip - first_ip + 1;
|
||||
} else {
|
||||
u8 mask_bits;
|
||||
u32 mask;
|
||||
@@ -515,7 +519,8 @@ bitmap_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
if (elements > IPSET_BITMAP_MAX_RANGE + 1)
|
||||
return -IPSET_ERR_BITMAP_RANGE_SIZE;
|
||||
|
||||
pr_debug("hosts %u, elements %u\n", hosts, elements);
|
||||
pr_debug("hosts %u, elements %llu\n",
|
||||
hosts, (unsigned long long)elements);
|
||||
|
||||
map = kzalloc(sizeof(*map), GFP_KERNEL);
|
||||
if (!map)
|
||||
@@ -554,8 +559,8 @@ static struct ip_set_type bitmap_ip_type __read_mostly = {
|
||||
.features = IPSET_TYPE_IP,
|
||||
.dimension = IPSET_DIM_ONE,
|
||||
.family = NFPROTO_IPV4,
|
||||
.revision_min = 0,
|
||||
.revision_max = 0,
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = bitmap_ip_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_IP] = { .type = NLA_NESTED },
|
||||
|
||||
@@ -26,9 +26,12 @@
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
#include <linux/netfilter/ipset/ip_set_bitmap.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 0
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("bitmap:ip,mac type of IP sets");
|
||||
IP_SET_MODULE_DESC("bitmap:ip,mac", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_bitmap:ip,mac");
|
||||
|
||||
enum {
|
||||
@@ -320,11 +323,11 @@ bitmap_ipmac_tlist(const struct ip_set *set,
|
||||
(elem->match == MAC_FILLED &&
|
||||
nla_put(skb, IPSET_ATTR_ETHER, ETH_ALEN,
|
||||
elem->ether)))
|
||||
goto nla_put_failure;
|
||||
goto nla_put_failure;
|
||||
timeout = elem->match == MAC_UNSET ? elem->timeout
|
||||
: ip_set_timeout_get(elem->timeout);
|
||||
if (nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(timeout)))
|
||||
goto nla_put_failure;
|
||||
goto nla_put_failure;
|
||||
ipset_nest_end(skb, nested);
|
||||
}
|
||||
ipset_nest_end(skb, atd);
|
||||
@@ -557,7 +560,8 @@ static int
|
||||
bitmap_ipmac_create(struct ip_set *set, struct nlattr *tb[],
|
||||
u32 flags)
|
||||
{
|
||||
u32 first_ip, last_ip, elements;
|
||||
u32 first_ip, last_ip;
|
||||
u64 elements;
|
||||
struct bitmap_ipmac *map;
|
||||
int ret;
|
||||
|
||||
@@ -588,7 +592,7 @@ bitmap_ipmac_create(struct ip_set *set, struct nlattr *tb[],
|
||||
} else
|
||||
return -IPSET_ERR_PROTOCOL;
|
||||
|
||||
elements = last_ip - first_ip + 1;
|
||||
elements = (u64)last_ip - first_ip + 1;
|
||||
|
||||
if (elements > IPSET_BITMAP_MAX_RANGE + 1)
|
||||
return -IPSET_ERR_BITMAP_RANGE_SIZE;
|
||||
@@ -629,8 +633,8 @@ static struct ip_set_type bitmap_ipmac_type = {
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_MAC,
|
||||
.dimension = IPSET_DIM_TWO,
|
||||
.family = NFPROTO_IPV4,
|
||||
.revision_min = 0,
|
||||
.revision_max = 0,
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = bitmap_ipmac_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_IP] = { .type = NLA_NESTED },
|
||||
|
||||
@@ -22,9 +22,12 @@
|
||||
#define IP_SET_BITMAP_TIMEOUT
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 0
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("bitmap:port type of IP sets");
|
||||
IP_SET_MODULE_DESC("bitmap:port", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_bitmap:port");
|
||||
|
||||
/* Type structure */
|
||||
@@ -487,8 +490,8 @@ static struct ip_set_type bitmap_port_type = {
|
||||
.features = IPSET_TYPE_PORT,
|
||||
.dimension = IPSET_DIM_ONE,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
.revision_max = 0,
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = bitmap_port_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_PORT] = { .type = NLA_U16 },
|
||||
|
||||
@@ -69,7 +69,8 @@ find_set_type(const char *name, u8 family, u8 revision)
|
||||
|
||||
list_for_each_entry_rcu(type, &ip_set_type_list, list)
|
||||
if (STREQ(type->name, name) &&
|
||||
(type->family == family || type->family == NFPROTO_UNSPEC) &&
|
||||
(type->family == family ||
|
||||
type->family == NFPROTO_UNSPEC) &&
|
||||
revision >= type->revision_min &&
|
||||
revision <= type->revision_max)
|
||||
return type;
|
||||
@@ -149,7 +150,8 @@ __find_set_type_minmax(const char *name, u8 family, u8 *min, u8 *max,
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(type, &ip_set_type_list, list)
|
||||
if (STREQ(type->name, name) &&
|
||||
(type->family == family || type->family == NFPROTO_UNSPEC)) {
|
||||
(type->family == family ||
|
||||
type->family == NFPROTO_UNSPEC)) {
|
||||
found = true;
|
||||
if (type->revision_min < *min)
|
||||
*min = type->revision_min;
|
||||
@@ -368,6 +370,12 @@ ip_set_test(ip_set_id_t index, const struct sk_buff *skb,
|
||||
set->variant->kadt(set, skb, par, IPSET_ADD, opt);
|
||||
write_unlock_bh(&set->lock);
|
||||
ret = 1;
|
||||
} else {
|
||||
/* --return-nomatch: invert matched element */
|
||||
if ((opt->flags & IPSET_RETURN_NOMATCH) &&
|
||||
(set->type->features & IPSET_TYPE_NOMATCH) &&
|
||||
(ret > 0 || ret == -ENOTEMPTY))
|
||||
ret = -ret;
|
||||
}
|
||||
|
||||
/* Convert error codes to nomatch */
|
||||
@@ -563,13 +571,13 @@ flag_exist(const struct nlmsghdr *nlh)
|
||||
}
|
||||
|
||||
static struct nlmsghdr *
|
||||
start_msg(struct sk_buff *skb, u32 pid, u32 seq, unsigned int flags,
|
||||
start_msg(struct sk_buff *skb, u32 portid, u32 seq, unsigned int flags,
|
||||
enum ipset_cmd cmd)
|
||||
{
|
||||
struct nlmsghdr *nlh;
|
||||
struct nfgenmsg *nfmsg;
|
||||
|
||||
nlh = nlmsg_put(skb, pid, seq, cmd | (NFNL_SUBSYS_IPSET << 8),
|
||||
nlh = nlmsg_put(skb, portid, seq, cmd | (NFNL_SUBSYS_IPSET << 8),
|
||||
sizeof(*nfmsg), flags);
|
||||
if (nlh == NULL)
|
||||
return NULL;
|
||||
@@ -721,7 +729,8 @@ ip_set_create(struct sock *ctnl, struct sk_buff *skb,
|
||||
* by the nfnl mutex. Find the first free index in ip_set_list
|
||||
* and check clashing.
|
||||
*/
|
||||
if ((ret = find_free_id(set->name, &index, &clash)) != 0) {
|
||||
ret = find_free_id(set->name, &index, &clash);
|
||||
if (ret != 0) {
|
||||
/* If this is the same set and requested, ignore error */
|
||||
if (ret == -EEXIST &&
|
||||
(flags & IPSET_FLAG_EXIST) &&
|
||||
@@ -1045,7 +1054,7 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
ip_set_id_t index = IPSET_INVALID_ID, max;
|
||||
struct ip_set *set = NULL;
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
unsigned int flags = NETLINK_CB(cb->skb).pid ? NLM_F_MULTI : 0;
|
||||
unsigned int flags = NETLINK_CB(cb->skb).portid ? NLM_F_MULTI : 0;
|
||||
u32 dump_type, dump_flags;
|
||||
int ret = 0;
|
||||
|
||||
@@ -1093,7 +1102,7 @@ dump_last:
|
||||
pr_debug("reference set\n");
|
||||
__ip_set_get(index);
|
||||
}
|
||||
nlh = start_msg(skb, NETLINK_CB(cb->skb).pid,
|
||||
nlh = start_msg(skb, NETLINK_CB(cb->skb).portid,
|
||||
cb->nlh->nlmsg_seq, flags,
|
||||
IPSET_CMD_LIST);
|
||||
if (!nlh) {
|
||||
@@ -1226,7 +1235,7 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
|
||||
skb2 = nlmsg_new(payload, GFP_KERNEL);
|
||||
if (skb2 == NULL)
|
||||
return -ENOMEM;
|
||||
rep = __nlmsg_put(skb2, NETLINK_CB(skb).pid,
|
||||
rep = __nlmsg_put(skb2, NETLINK_CB(skb).portid,
|
||||
nlh->nlmsg_seq, NLMSG_ERROR, payload, 0);
|
||||
errmsg = nlmsg_data(rep);
|
||||
errmsg->error = ret;
|
||||
@@ -1241,7 +1250,7 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
|
||||
|
||||
*errline = lineno;
|
||||
|
||||
netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
|
||||
netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
|
||||
/* Signal netlink not to send its ACK/errmsg. */
|
||||
return -EINTR;
|
||||
}
|
||||
@@ -1416,7 +1425,7 @@ ip_set_header(struct sock *ctnl, struct sk_buff *skb,
|
||||
if (skb2 == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
nlh2 = start_msg(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0,
|
||||
nlh2 = start_msg(skb2, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 0,
|
||||
IPSET_CMD_HEADER);
|
||||
if (!nlh2)
|
||||
goto nlmsg_failure;
|
||||
@@ -1428,7 +1437,7 @@ ip_set_header(struct sock *ctnl, struct sk_buff *skb,
|
||||
goto nla_put_failure;
|
||||
nlmsg_end(skb2, nlh2);
|
||||
|
||||
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
|
||||
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -1476,7 +1485,7 @@ ip_set_type(struct sock *ctnl, struct sk_buff *skb,
|
||||
if (skb2 == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
nlh2 = start_msg(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0,
|
||||
nlh2 = start_msg(skb2, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 0,
|
||||
IPSET_CMD_TYPE);
|
||||
if (!nlh2)
|
||||
goto nlmsg_failure;
|
||||
@@ -1489,7 +1498,7 @@ ip_set_type(struct sock *ctnl, struct sk_buff *skb,
|
||||
nlmsg_end(skb2, nlh2);
|
||||
|
||||
pr_debug("Send TYPE, nlmsg_len: %u\n", nlh2->nlmsg_len);
|
||||
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
|
||||
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -1525,7 +1534,7 @@ ip_set_protocol(struct sock *ctnl, struct sk_buff *skb,
|
||||
if (skb2 == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
nlh2 = start_msg(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0,
|
||||
nlh2 = start_msg(skb2, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 0,
|
||||
IPSET_CMD_PROTOCOL);
|
||||
if (!nlh2)
|
||||
goto nlmsg_failure;
|
||||
@@ -1533,7 +1542,7 @@ ip_set_protocol(struct sock *ctnl, struct sk_buff *skb,
|
||||
goto nla_put_failure;
|
||||
nlmsg_end(skb2, nlh2);
|
||||
|
||||
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
|
||||
ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 0
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:ip type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:ip", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:ip");
|
||||
|
||||
/* Type specific function prefix */
|
||||
@@ -114,7 +117,7 @@ nla_put_failure:
|
||||
static inline void
|
||||
hash_ip4_data_next(struct ip_set_hash *h, const struct hash_ip4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.ip = d->ip;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -179,7 +182,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
} else if (tb[IPSET_ATTR_CIDR]) {
|
||||
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
|
||||
if (cidr > 32)
|
||||
if (!cidr || cidr > 32)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
ip_set_mask_from_to(ip, ip_to, cidr);
|
||||
} else
|
||||
@@ -188,7 +191,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1);
|
||||
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
for (; !before(ip_to, ip); ip += hosts) {
|
||||
nip = htonl(ip);
|
||||
if (nip == 0)
|
||||
@@ -452,8 +455,8 @@ static struct ip_set_type hash_ip_type __read_mostly = {
|
||||
.features = IPSET_TYPE_IP,
|
||||
.dimension = IPSET_DIM_ONE,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
.revision_max = 0,
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_ip_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
#include <linux/netfilter/ipset/ip_set_getport.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 1 /* SCTP and UDPLITE support added */
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:ip,port type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:ip,port", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:ip,port");
|
||||
|
||||
/* Type specific function prefix */
|
||||
@@ -130,8 +133,8 @@ static inline void
|
||||
hash_ipport4_data_next(struct ip_set_hash *h,
|
||||
const struct hash_ipport4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.ip = d->ip;
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -217,7 +220,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
} else if (tb[IPSET_ATTR_CIDR]) {
|
||||
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
|
||||
if (cidr > 32)
|
||||
if (!cidr || cidr > 32)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
ip_set_mask_from_to(ip, ip_to, cidr);
|
||||
} else
|
||||
@@ -231,9 +234,10 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
for (; !before(ip_to, ip); ip++) {
|
||||
p = retried && ip == h->next.ip ? h->next.port : port;
|
||||
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
|
||||
: port;
|
||||
for (; p <= port_to; p++) {
|
||||
data.ip = htonl(ip);
|
||||
data.port = htons(p);
|
||||
@@ -349,7 +353,7 @@ static inline void
|
||||
hash_ipport6_data_next(struct ip_set_hash *h,
|
||||
const struct hash_ipport6_elem *d)
|
||||
{
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -431,7 +435,7 @@ hash_ipport6_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
swap(port, port_to);
|
||||
|
||||
if (retried)
|
||||
port = h->next.port;
|
||||
port = ntohs(h->next.port);
|
||||
for (; port <= port_to; port++) {
|
||||
data.port = htons(port);
|
||||
ret = adtfn(set, &data, timeout, flags);
|
||||
@@ -522,8 +526,8 @@ static struct ip_set_type hash_ipport_type __read_mostly = {
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_PORT,
|
||||
.dimension = IPSET_DIM_TWO,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
.revision_max = 1, /* SCTP and UDPLITE support added */
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_ipport_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
#include <linux/netfilter/ipset/ip_set_getport.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 1 /* SCTP and UDPLITE support added */
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:ip,port,ip type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:ip,port,ip", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:ip,port,ip");
|
||||
|
||||
/* Type specific function prefix */
|
||||
@@ -133,8 +136,8 @@ static inline void
|
||||
hash_ipportip4_data_next(struct ip_set_hash *h,
|
||||
const struct hash_ipportip4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.ip = d->ip;
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -225,7 +228,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
} else if (tb[IPSET_ATTR_CIDR]) {
|
||||
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
|
||||
if (cidr > 32)
|
||||
if (!cidr || cidr > 32)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
ip_set_mask_from_to(ip, ip_to, cidr);
|
||||
} else
|
||||
@@ -239,9 +242,10 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
for (; !before(ip_to, ip); ip++) {
|
||||
p = retried && ip == h->next.ip ? h->next.port : port;
|
||||
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
|
||||
: port;
|
||||
for (; p <= port_to; p++) {
|
||||
data.ip = htonl(ip);
|
||||
data.port = htons(p);
|
||||
@@ -362,7 +366,7 @@ static inline void
|
||||
hash_ipportip6_data_next(struct ip_set_hash *h,
|
||||
const struct hash_ipportip6_elem *d)
|
||||
{
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -449,7 +453,7 @@ hash_ipportip6_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
swap(port, port_to);
|
||||
|
||||
if (retried)
|
||||
port = h->next.port;
|
||||
port = ntohs(h->next.port);
|
||||
for (; port <= port_to; port++) {
|
||||
data.port = htons(port);
|
||||
ret = adtfn(set, &data, timeout, flags);
|
||||
@@ -540,8 +544,8 @@ static struct ip_set_type hash_ipportip_type __read_mostly = {
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2,
|
||||
.dimension = IPSET_DIM_THREE,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
.revision_max = 1, /* SCTP and UDPLITE support added */
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_ipportip_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -25,9 +25,14 @@
|
||||
#include <linux/netfilter/ipset/ip_set_getport.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
/* 1 SCTP and UDPLITE support added */
|
||||
/* 2 Range as input support for IPv4 added */
|
||||
#define REVISION_MAX 3 /* nomatch flag support added */
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:ip,port,net type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:ip,port,net", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:ip,port,net");
|
||||
|
||||
/* Type specific function prefix */
|
||||
@@ -99,10 +104,10 @@ hash_ipportnet4_data_flags(struct hash_ipportnet4_elem *dst, u32 flags)
|
||||
dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_ipportnet4_data_match(const struct hash_ipportnet4_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -173,9 +178,9 @@ static inline void
|
||||
hash_ipportnet4_data_next(struct ip_set_hash *h,
|
||||
const struct hash_ipportnet4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.ip2 = ntohl(d->ip2);
|
||||
h->next.ip = d->ip;
|
||||
h->next.port = d->port;
|
||||
h->next.ip2 = d->ip2;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -290,7 +295,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
} else if (tb[IPSET_ATTR_CIDR]) {
|
||||
u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
|
||||
if (cidr > 32)
|
||||
if (!cidr || cidr > 32)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
ip_set_mask_from_to(ip, ip_to, cidr);
|
||||
}
|
||||
@@ -314,14 +319,17 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
for (; !before(ip_to, ip); ip++) {
|
||||
data.ip = htonl(ip);
|
||||
p = retried && ip == h->next.ip ? h->next.port : port;
|
||||
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
|
||||
: port;
|
||||
for (; p <= port_to; p++) {
|
||||
data.port = htons(p);
|
||||
ip2 = retried && ip == h->next.ip && p == h->next.port
|
||||
? h->next.ip2 : ip2_from;
|
||||
ip2 = retried
|
||||
&& ip == ntohl(h->next.ip)
|
||||
&& p == ntohs(h->next.port)
|
||||
? ntohl(h->next.ip2) : ip2_from;
|
||||
while (!after(ip2, ip2_to)) {
|
||||
data.ip2 = htonl(ip2);
|
||||
ip2_last = ip_set_range_to_cidr(ip2, ip2_to,
|
||||
@@ -403,10 +411,10 @@ hash_ipportnet6_data_flags(struct hash_ipportnet6_elem *dst, u32 flags)
|
||||
dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_ipportnet6_data_match(const struct hash_ipportnet6_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -486,7 +494,7 @@ static inline void
|
||||
hash_ipportnet6_data_next(struct ip_set_hash *h,
|
||||
const struct hash_ipportnet6_elem *d)
|
||||
{
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -598,7 +606,7 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
swap(port, port_to);
|
||||
|
||||
if (retried)
|
||||
port = h->next.port;
|
||||
port = ntohs(h->next.port);
|
||||
for (; port <= port_to; port++) {
|
||||
data.port = htons(port);
|
||||
ret = adtfn(set, &data, timeout, flags);
|
||||
@@ -689,13 +697,12 @@ hash_ipportnet_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
static struct ip_set_type hash_ipportnet_type __read_mostly = {
|
||||
.name = "hash:ip,port,net",
|
||||
.protocol = IPSET_PROTOCOL,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2 |
|
||||
IPSET_TYPE_NOMATCH,
|
||||
.dimension = IPSET_DIM_THREE,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
/* 1 SCTP and UDPLITE support added */
|
||||
/* 2 Range as input support for IPv4 added */
|
||||
.revision_max = 3, /* nomatch flag support added */
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_ipportnet_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -23,9 +23,13 @@
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
/* 1 Range as input support for IPv4 added */
|
||||
#define REVISION_MAX 2 /* nomatch flag support added */
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:net type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:net", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:net");
|
||||
|
||||
/* Type specific function prefix */
|
||||
@@ -86,10 +90,10 @@ hash_net4_data_flags(struct hash_net4_elem *dst, u32 flags)
|
||||
dst->nomatch = flags & IPSET_FLAG_NOMATCH;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_net4_data_match(const struct hash_net4_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -152,7 +156,7 @@ static inline void
|
||||
hash_net4_data_next(struct ip_set_hash *h,
|
||||
const struct hash_net4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.ip = d->ip;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -235,7 +239,7 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
return -IPSET_ERR_HASH_RANGE;
|
||||
}
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
while (!after(ip, ip_to)) {
|
||||
data.ip = htonl(ip);
|
||||
last = ip_set_range_to_cidr(ip, ip_to, &data.cidr);
|
||||
@@ -307,10 +311,10 @@ hash_net6_data_flags(struct hash_net6_elem *dst, u32 flags)
|
||||
dst->nomatch = flags & IPSET_FLAG_NOMATCH;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_net6_data_match(const struct hash_net6_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -532,12 +536,11 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
static struct ip_set_type hash_net_type __read_mostly = {
|
||||
.name = "hash:net",
|
||||
.protocol = IPSET_PROTOCOL,
|
||||
.features = IPSET_TYPE_IP,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_NOMATCH,
|
||||
.dimension = IPSET_DIM_ONE,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
/* = 1 Range as input support for IPv4 added */
|
||||
.revision_max = 2, /* nomatch flag support added */
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_net_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -24,9 +24,13 @@
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
/* 1 nomatch flag support added */
|
||||
#define REVISION_MAX 2 /* /0 support added */
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:net,iface type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:net,iface", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:net,iface");
|
||||
|
||||
/* Interface name rbtree */
|
||||
@@ -140,7 +144,7 @@ struct hash_netiface4_elem_hashed {
|
||||
u8 physdev;
|
||||
u8 cidr;
|
||||
u8 nomatch;
|
||||
u8 padding;
|
||||
u8 elem;
|
||||
};
|
||||
|
||||
#define HKEY_DATALEN sizeof(struct hash_netiface4_elem_hashed)
|
||||
@@ -151,7 +155,7 @@ struct hash_netiface4_elem {
|
||||
u8 physdev;
|
||||
u8 cidr;
|
||||
u8 nomatch;
|
||||
u8 padding;
|
||||
u8 elem;
|
||||
const char *iface;
|
||||
};
|
||||
|
||||
@@ -161,7 +165,7 @@ struct hash_netiface4_telem {
|
||||
u8 physdev;
|
||||
u8 cidr;
|
||||
u8 nomatch;
|
||||
u8 padding;
|
||||
u8 elem;
|
||||
const char *iface;
|
||||
unsigned long timeout;
|
||||
};
|
||||
@@ -181,18 +185,14 @@ hash_netiface4_data_equal(const struct hash_netiface4_elem *ip1,
|
||||
static inline bool
|
||||
hash_netiface4_data_isnull(const struct hash_netiface4_elem *elem)
|
||||
{
|
||||
return elem->cidr == 0;
|
||||
return elem->elem == 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
hash_netiface4_data_copy(struct hash_netiface4_elem *dst,
|
||||
const struct hash_netiface4_elem *src)
|
||||
{
|
||||
dst->ip = src->ip;
|
||||
dst->cidr = src->cidr;
|
||||
dst->physdev = src->physdev;
|
||||
dst->iface = src->iface;
|
||||
dst->nomatch = src->nomatch;
|
||||
memcpy(dst, src, sizeof(*dst));
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -201,10 +201,10 @@ hash_netiface4_data_flags(struct hash_netiface4_elem *dst, u32 flags)
|
||||
dst->nomatch = flags & IPSET_FLAG_NOMATCH;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_netiface4_data_match(const struct hash_netiface4_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -217,7 +217,7 @@ hash_netiface4_data_netmask(struct hash_netiface4_elem *elem, u8 cidr)
|
||||
static inline void
|
||||
hash_netiface4_data_zero_out(struct hash_netiface4_elem *elem)
|
||||
{
|
||||
elem->cidr = 0;
|
||||
elem->elem = 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -277,7 +277,7 @@ static inline void
|
||||
hash_netiface4_data_next(struct ip_set_hash *h,
|
||||
const struct hash_netiface4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.ip = d->ip;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -288,7 +288,8 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
|
||||
struct ip_set_hash *h = set->data;
|
||||
ipset_adtfn adtfn = set->variant->adt[adt];
|
||||
struct hash_netiface4_elem data = {
|
||||
.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
|
||||
.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK,
|
||||
.elem = 1,
|
||||
};
|
||||
int ret;
|
||||
|
||||
@@ -339,7 +340,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
{
|
||||
struct ip_set_hash *h = set->data;
|
||||
ipset_adtfn adtfn = set->variant->adt[adt];
|
||||
struct hash_netiface4_elem data = { .cidr = HOST_MASK };
|
||||
struct hash_netiface4_elem data = { .cidr = HOST_MASK, .elem = 1 };
|
||||
u32 ip = 0, ip_to, last;
|
||||
u32 timeout = h->timeout;
|
||||
char iface[IFNAMSIZ];
|
||||
@@ -360,7 +361,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
|
||||
if (tb[IPSET_ATTR_CIDR]) {
|
||||
data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
if (!data.cidr || data.cidr > HOST_MASK)
|
||||
if (data.cidr > HOST_MASK)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
}
|
||||
|
||||
@@ -389,7 +390,6 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
if (adt == IPSET_ADD && (cadt_flags & IPSET_FLAG_NOMATCH))
|
||||
flags |= (cadt_flags << 16);
|
||||
}
|
||||
|
||||
if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) {
|
||||
data.ip = htonl(ip & ip_set_hostmask(data.cidr));
|
||||
ret = adtfn(set, &data, timeout, flags);
|
||||
@@ -409,7 +409,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
while (!after(ip, ip_to)) {
|
||||
data.ip = htonl(ip);
|
||||
last = ip_set_range_to_cidr(ip, ip_to, &data.cidr);
|
||||
@@ -442,7 +442,7 @@ struct hash_netiface6_elem_hashed {
|
||||
u8 physdev;
|
||||
u8 cidr;
|
||||
u8 nomatch;
|
||||
u8 padding;
|
||||
u8 elem;
|
||||
};
|
||||
|
||||
#define HKEY_DATALEN sizeof(struct hash_netiface6_elem_hashed)
|
||||
@@ -452,7 +452,7 @@ struct hash_netiface6_elem {
|
||||
u8 physdev;
|
||||
u8 cidr;
|
||||
u8 nomatch;
|
||||
u8 padding;
|
||||
u8 elem;
|
||||
const char *iface;
|
||||
};
|
||||
|
||||
@@ -461,7 +461,7 @@ struct hash_netiface6_telem {
|
||||
u8 physdev;
|
||||
u8 cidr;
|
||||
u8 nomatch;
|
||||
u8 padding;
|
||||
u8 elem;
|
||||
const char *iface;
|
||||
unsigned long timeout;
|
||||
};
|
||||
@@ -481,7 +481,7 @@ hash_netiface6_data_equal(const struct hash_netiface6_elem *ip1,
|
||||
static inline bool
|
||||
hash_netiface6_data_isnull(const struct hash_netiface6_elem *elem)
|
||||
{
|
||||
return elem->cidr == 0;
|
||||
return elem->elem == 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -497,16 +497,16 @@ hash_netiface6_data_flags(struct hash_netiface6_elem *dst, u32 flags)
|
||||
dst->nomatch = flags & IPSET_FLAG_NOMATCH;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_netiface6_data_match(const struct hash_netiface6_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
hash_netiface6_data_zero_out(struct hash_netiface6_elem *elem)
|
||||
{
|
||||
elem->cidr = 0;
|
||||
elem->elem = 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -590,7 +590,8 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb,
|
||||
struct ip_set_hash *h = set->data;
|
||||
ipset_adtfn adtfn = set->variant->adt[adt];
|
||||
struct hash_netiface6_elem data = {
|
||||
.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
|
||||
.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK,
|
||||
.elem = 1,
|
||||
};
|
||||
int ret;
|
||||
|
||||
@@ -637,7 +638,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
{
|
||||
struct ip_set_hash *h = set->data;
|
||||
ipset_adtfn adtfn = set->variant->adt[adt];
|
||||
struct hash_netiface6_elem data = { .cidr = HOST_MASK };
|
||||
struct hash_netiface6_elem data = { .cidr = HOST_MASK, .elem = 1 };
|
||||
u32 timeout = h->timeout;
|
||||
char iface[IFNAMSIZ];
|
||||
int ret;
|
||||
@@ -659,7 +660,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
|
||||
if (tb[IPSET_ATTR_CIDR])
|
||||
data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
|
||||
if (!data.cidr || data.cidr > HOST_MASK)
|
||||
if (data.cidr > HOST_MASK)
|
||||
return -IPSET_ERR_INVALID_CIDR;
|
||||
ip6_netmask(&data.ip, data.cidr);
|
||||
|
||||
@@ -773,11 +774,12 @@ hash_netiface_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
static struct ip_set_type hash_netiface_type __read_mostly = {
|
||||
.name = "hash:net,iface",
|
||||
.protocol = IPSET_PROTOCOL,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_IFACE,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_IFACE |
|
||||
IPSET_TYPE_NOMATCH,
|
||||
.dimension = IPSET_DIM_TWO,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
.revision_max = 1, /* nomatch flag support added */
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_netiface_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -24,9 +24,14 @@
|
||||
#include <linux/netfilter/ipset/ip_set_getport.h>
|
||||
#include <linux/netfilter/ipset/ip_set_hash.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
/* 1 SCTP and UDPLITE support added */
|
||||
/* 2 Range as input support for IPv4 added */
|
||||
#define REVISION_MAX 3 /* nomatch flag support added */
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("hash:net,port type of IP sets");
|
||||
IP_SET_MODULE_DESC("hash:net,port", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_hash:net,port");
|
||||
|
||||
/* Type specific function prefix */
|
||||
@@ -99,10 +104,10 @@ hash_netport4_data_flags(struct hash_netport4_elem *dst, u32 flags)
|
||||
dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_netport4_data_match(const struct hash_netport4_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -171,8 +176,8 @@ static inline void
|
||||
hash_netport4_data_next(struct ip_set_hash *h,
|
||||
const struct hash_netport4_elem *d)
|
||||
{
|
||||
h->next.ip = ntohl(d->ip);
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.ip = d->ip;
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -289,12 +294,13 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
if (retried)
|
||||
ip = h->next.ip;
|
||||
ip = ntohl(h->next.ip);
|
||||
while (!after(ip, ip_to)) {
|
||||
data.ip = htonl(ip);
|
||||
last = ip_set_range_to_cidr(ip, ip_to, &cidr);
|
||||
data.cidr = cidr - 1;
|
||||
p = retried && ip == h->next.ip ? h->next.port : port;
|
||||
p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
|
||||
: port;
|
||||
for (; p <= port_to; p++) {
|
||||
data.port = htons(p);
|
||||
ret = adtfn(set, &data, timeout, flags);
|
||||
@@ -369,10 +375,10 @@ hash_netport6_data_flags(struct hash_netport6_elem *dst, u32 flags)
|
||||
dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static inline int
|
||||
hash_netport6_data_match(const struct hash_netport6_elem *elem)
|
||||
{
|
||||
return !elem->nomatch;
|
||||
return elem->nomatch ? -ENOTEMPTY : 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -450,7 +456,7 @@ static inline void
|
||||
hash_netport6_data_next(struct ip_set_hash *h,
|
||||
const struct hash_netport6_elem *d)
|
||||
{
|
||||
h->next.port = ntohs(d->port);
|
||||
h->next.port = d->port;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -554,7 +560,7 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[],
|
||||
swap(port, port_to);
|
||||
|
||||
if (retried)
|
||||
port = h->next.port;
|
||||
port = ntohs(h->next.port);
|
||||
for (; port <= port_to; port++) {
|
||||
data.port = htons(port);
|
||||
ret = adtfn(set, &data, timeout, flags);
|
||||
@@ -644,13 +650,11 @@ hash_netport_create(struct ip_set *set, struct nlattr *tb[], u32 flags)
|
||||
static struct ip_set_type hash_netport_type __read_mostly = {
|
||||
.name = "hash:net,port",
|
||||
.protocol = IPSET_PROTOCOL,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_PORT,
|
||||
.features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_NOMATCH,
|
||||
.dimension = IPSET_DIM_TWO,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
/* 1 SCTP and UDPLITE support added */
|
||||
/* 2, Range as input support for IPv4 added */
|
||||
.revision_max = 3, /* nomatch flag support added */
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = hash_netport_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
#include <linux/netfilter/ipset/ip_set_timeout.h>
|
||||
#include <linux/netfilter/ipset/ip_set_list.h>
|
||||
|
||||
#define REVISION_MIN 0
|
||||
#define REVISION_MAX 0
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
|
||||
MODULE_DESCRIPTION("list:set type of IP sets");
|
||||
IP_SET_MODULE_DESC("list:set", REVISION_MIN, REVISION_MAX);
|
||||
MODULE_ALIAS("ip_set_list:set");
|
||||
|
||||
/* Member elements without and with timeout */
|
||||
@@ -579,8 +582,8 @@ static struct ip_set_type list_set_type __read_mostly = {
|
||||
.features = IPSET_TYPE_NAME | IPSET_DUMP_LAST,
|
||||
.dimension = IPSET_DIM_ONE,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.revision_min = 0,
|
||||
.revision_max = 0,
|
||||
.revision_min = REVISION_MIN,
|
||||
.revision_max = REVISION_MAX,
|
||||
.create = list_set_create,
|
||||
.create_policy = {
|
||||
[IPSET_ATTR_SIZE] = { .type = NLA_U32 },
|
||||
|
||||
@@ -250,7 +250,8 @@ comment 'IPVS application helper'
|
||||
|
||||
config IP_VS_FTP
|
||||
tristate "FTP protocol helper"
|
||||
depends on IP_VS_PROTO_TCP && NF_CONNTRACK && NF_NAT
|
||||
depends on IP_VS_PROTO_TCP && NF_CONNTRACK && NF_NAT && \
|
||||
NF_CONNTRACK_FTP
|
||||
select IP_VS_NFCT
|
||||
---help---
|
||||
FTP is a protocol that transfers IP address and/or port number in
|
||||
|
||||
@@ -180,22 +180,38 @@ register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ip_vs_app registration routine
|
||||
*/
|
||||
int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
|
||||
/* Register application for netns */
|
||||
struct ip_vs_app *register_ip_vs_app(struct net *net, struct ip_vs_app *app)
|
||||
{
|
||||
struct netns_ipvs *ipvs = net_ipvs(net);
|
||||
/* increase the module use count */
|
||||
ip_vs_use_count_inc();
|
||||
struct ip_vs_app *a;
|
||||
int err = 0;
|
||||
|
||||
if (!ipvs)
|
||||
return ERR_PTR(-ENOENT);
|
||||
|
||||
mutex_lock(&__ip_vs_app_mutex);
|
||||
|
||||
list_add(&app->a_list, &ipvs->app_list);
|
||||
list_for_each_entry(a, &ipvs->app_list, a_list) {
|
||||
if (!strcmp(app->name, a->name)) {
|
||||
err = -EEXIST;
|
||||
goto out_unlock;
|
||||
}
|
||||
}
|
||||
a = kmemdup(app, sizeof(*app), GFP_KERNEL);
|
||||
if (!a) {
|
||||
err = -ENOMEM;
|
||||
goto out_unlock;
|
||||
}
|
||||
INIT_LIST_HEAD(&a->incs_list);
|
||||
list_add(&a->a_list, &ipvs->app_list);
|
||||
/* increase the module use count */
|
||||
ip_vs_use_count_inc();
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&__ip_vs_app_mutex);
|
||||
|
||||
return 0;
|
||||
return err ? ERR_PTR(err) : a;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,20 +221,29 @@ int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
|
||||
*/
|
||||
void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app)
|
||||
{
|
||||
struct ip_vs_app *inc, *nxt;
|
||||
struct netns_ipvs *ipvs = net_ipvs(net);
|
||||
struct ip_vs_app *a, *anxt, *inc, *nxt;
|
||||
|
||||
if (!ipvs)
|
||||
return;
|
||||
|
||||
mutex_lock(&__ip_vs_app_mutex);
|
||||
|
||||
list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) {
|
||||
ip_vs_app_inc_release(net, inc);
|
||||
list_for_each_entry_safe(a, anxt, &ipvs->app_list, a_list) {
|
||||
if (app && strcmp(app->name, a->name))
|
||||
continue;
|
||||
list_for_each_entry_safe(inc, nxt, &a->incs_list, a_list) {
|
||||
ip_vs_app_inc_release(net, inc);
|
||||
}
|
||||
|
||||
list_del(&a->a_list);
|
||||
kfree(a);
|
||||
|
||||
/* decrease the module use count */
|
||||
ip_vs_use_count_dec();
|
||||
}
|
||||
|
||||
list_del(&app->a_list);
|
||||
|
||||
mutex_unlock(&__ip_vs_app_mutex);
|
||||
|
||||
/* decrease the module use count */
|
||||
ip_vs_use_count_dec();
|
||||
}
|
||||
|
||||
|
||||
@@ -586,5 +611,6 @@ int __net_init ip_vs_app_net_init(struct net *net)
|
||||
|
||||
void __net_exit ip_vs_app_net_cleanup(struct net *net)
|
||||
{
|
||||
unregister_ip_vs_app(net, NULL /* all */);
|
||||
proc_net_remove(net, "ip_vs_app");
|
||||
}
|
||||
|
||||
@@ -1303,7 +1303,8 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
|
||||
struct ip_vs_conn *cp;
|
||||
struct ip_vs_protocol *pp;
|
||||
struct ip_vs_proto_data *pd;
|
||||
unsigned int offset, ihl, verdict;
|
||||
unsigned int offset, offset2, ihl, verdict;
|
||||
bool ipip;
|
||||
|
||||
*related = 1;
|
||||
|
||||
@@ -1345,6 +1346,21 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
|
||||
|
||||
net = skb_net(skb);
|
||||
|
||||
/* Special case for errors for IPIP packets */
|
||||
ipip = false;
|
||||
if (cih->protocol == IPPROTO_IPIP) {
|
||||
if (unlikely(cih->frag_off & htons(IP_OFFSET)))
|
||||
return NF_ACCEPT;
|
||||
/* Error for our IPIP must arrive at LOCAL_IN */
|
||||
if (!(skb_rtable(skb)->rt_flags & RTCF_LOCAL))
|
||||
return NF_ACCEPT;
|
||||
offset += cih->ihl * 4;
|
||||
cih = skb_header_pointer(skb, offset, sizeof(_ciph), &_ciph);
|
||||
if (cih == NULL)
|
||||
return NF_ACCEPT; /* The packet looks wrong, ignore */
|
||||
ipip = true;
|
||||
}
|
||||
|
||||
pd = ip_vs_proto_data_get(net, cih->protocol);
|
||||
if (!pd)
|
||||
return NF_ACCEPT;
|
||||
@@ -1358,11 +1374,14 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
|
||||
IP_VS_DBG_PKT(11, AF_INET, pp, skb, offset,
|
||||
"Checking incoming ICMP for");
|
||||
|
||||
offset2 = offset;
|
||||
offset += cih->ihl * 4;
|
||||
|
||||
ip_vs_fill_iphdr(AF_INET, cih, &ciph);
|
||||
/* The embedded headers contain source and dest in reverse order */
|
||||
cp = pp->conn_in_get(AF_INET, skb, &ciph, offset, 1);
|
||||
/* The embedded headers contain source and dest in reverse order.
|
||||
* For IPIP this is error for request, not for reply.
|
||||
*/
|
||||
cp = pp->conn_in_get(AF_INET, skb, &ciph, offset, ipip ? 0 : 1);
|
||||
if (!cp)
|
||||
return NF_ACCEPT;
|
||||
|
||||
@@ -1376,6 +1395,57 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (ipip) {
|
||||
__be32 info = ic->un.gateway;
|
||||
|
||||
/* Update the MTU */
|
||||
if (ic->type == ICMP_DEST_UNREACH &&
|
||||
ic->code == ICMP_FRAG_NEEDED) {
|
||||
struct ip_vs_dest *dest = cp->dest;
|
||||
u32 mtu = ntohs(ic->un.frag.mtu);
|
||||
|
||||
/* Strip outer IP and ICMP, go to IPIP header */
|
||||
__skb_pull(skb, ihl + sizeof(_icmph));
|
||||
offset2 -= ihl + sizeof(_icmph);
|
||||
skb_reset_network_header(skb);
|
||||
IP_VS_DBG(12, "ICMP for IPIP %pI4->%pI4: mtu=%u\n",
|
||||
&ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr, mtu);
|
||||
rcu_read_lock();
|
||||
ipv4_update_pmtu(skb, dev_net(skb->dev),
|
||||
mtu, 0, 0, 0, 0);
|
||||
rcu_read_unlock();
|
||||
/* Client uses PMTUD? */
|
||||
if (!(cih->frag_off & htons(IP_DF)))
|
||||
goto ignore_ipip;
|
||||
/* Prefer the resulting PMTU */
|
||||
if (dest) {
|
||||
spin_lock(&dest->dst_lock);
|
||||
if (dest->dst_cache)
|
||||
mtu = dst_mtu(dest->dst_cache);
|
||||
spin_unlock(&dest->dst_lock);
|
||||
}
|
||||
if (mtu > 68 + sizeof(struct iphdr))
|
||||
mtu -= sizeof(struct iphdr);
|
||||
info = htonl(mtu);
|
||||
}
|
||||
/* Strip outer IP, ICMP and IPIP, go to IP header of
|
||||
* original request.
|
||||
*/
|
||||
__skb_pull(skb, offset2);
|
||||
skb_reset_network_header(skb);
|
||||
IP_VS_DBG(12, "Sending ICMP for %pI4->%pI4: t=%u, c=%u, i=%u\n",
|
||||
&ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
|
||||
ic->type, ic->code, ntohl(info));
|
||||
icmp_send(skb, ic->type, ic->code, info);
|
||||
/* ICMP can be shorter but anyways, account it */
|
||||
ip_vs_out_stats(cp, skb);
|
||||
|
||||
ignore_ipip:
|
||||
consume_skb(skb);
|
||||
verdict = NF_STOLEN;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* do the statistics and put it back */
|
||||
ip_vs_in_stats(cp, skb);
|
||||
if (IPPROTO_TCP == cih->protocol || IPPROTO_UDP == cih->protocol)
|
||||
|
||||
@@ -539,8 +539,7 @@ static int ip_vs_rs_unhash(struct ip_vs_dest *dest)
|
||||
* Remove it from the rs_table table.
|
||||
*/
|
||||
if (!list_empty(&dest->d_list)) {
|
||||
list_del(&dest->d_list);
|
||||
INIT_LIST_HEAD(&dest->d_list);
|
||||
list_del_init(&dest->d_list);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1803,6 +1802,12 @@ static struct ctl_table vs_vars[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{
|
||||
.procname = "pmtu_disc",
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
#ifdef CONFIG_IP_VS_DEBUG
|
||||
{
|
||||
.procname = "debug_level",
|
||||
@@ -2933,7 +2938,7 @@ static int ip_vs_genl_dump_service(struct sk_buff *skb,
|
||||
{
|
||||
void *hdr;
|
||||
|
||||
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
|
||||
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
|
||||
&ip_vs_genl_family, NLM_F_MULTI,
|
||||
IPVS_CMD_NEW_SERVICE);
|
||||
if (!hdr)
|
||||
@@ -3122,7 +3127,7 @@ static int ip_vs_genl_dump_dest(struct sk_buff *skb, struct ip_vs_dest *dest,
|
||||
{
|
||||
void *hdr;
|
||||
|
||||
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
|
||||
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
|
||||
&ip_vs_genl_family, NLM_F_MULTI,
|
||||
IPVS_CMD_NEW_DEST);
|
||||
if (!hdr)
|
||||
@@ -3251,7 +3256,7 @@ static int ip_vs_genl_dump_daemon(struct sk_buff *skb, __be32 state,
|
||||
struct netlink_callback *cb)
|
||||
{
|
||||
void *hdr;
|
||||
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
|
||||
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
|
||||
&ip_vs_genl_family, NLM_F_MULTI,
|
||||
IPVS_CMD_NEW_DAEMON);
|
||||
if (!hdr)
|
||||
@@ -3678,7 +3683,7 @@ static void ip_vs_genl_unregister(void)
|
||||
* per netns intit/exit func.
|
||||
*/
|
||||
#ifdef CONFIG_SYSCTL
|
||||
int __net_init ip_vs_control_net_init_sysctl(struct net *net)
|
||||
static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
|
||||
{
|
||||
int idx;
|
||||
struct netns_ipvs *ipvs = net_ipvs(net);
|
||||
@@ -3729,6 +3734,8 @@ int __net_init ip_vs_control_net_init_sysctl(struct net *net)
|
||||
ipvs->sysctl_sync_retries = clamp_t(int, DEFAULT_SYNC_RETRIES, 0, 3);
|
||||
tbl[idx++].data = &ipvs->sysctl_sync_retries;
|
||||
tbl[idx++].data = &ipvs->sysctl_nat_icmp_send;
|
||||
ipvs->sysctl_pmtu_disc = 1;
|
||||
tbl[idx++].data = &ipvs->sysctl_pmtu_disc;
|
||||
|
||||
|
||||
ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl);
|
||||
@@ -3746,7 +3753,7 @@ int __net_init ip_vs_control_net_init_sysctl(struct net *net)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net)
|
||||
static void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net)
|
||||
{
|
||||
struct netns_ipvs *ipvs = net_ipvs(net);
|
||||
|
||||
@@ -3757,8 +3764,8 @@ void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net)
|
||||
|
||||
#else
|
||||
|
||||
int __net_init ip_vs_control_net_init_sysctl(struct net *net) { return 0; }
|
||||
void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { }
|
||||
static int __net_init ip_vs_control_net_init_sysctl(struct net *net) { return 0; }
|
||||
static void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -268,6 +268,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
|
||||
* packet.
|
||||
*/
|
||||
ret = nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
|
||||
iph->ihl * 4,
|
||||
start-data, end-start,
|
||||
buf, buf_len);
|
||||
if (ret) {
|
||||
@@ -441,16 +442,10 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
|
||||
|
||||
if (!ipvs)
|
||||
return -ENOENT;
|
||||
app = kmemdup(&ip_vs_ftp, sizeof(struct ip_vs_app), GFP_KERNEL);
|
||||
if (!app)
|
||||
return -ENOMEM;
|
||||
INIT_LIST_HEAD(&app->a_list);
|
||||
INIT_LIST_HEAD(&app->incs_list);
|
||||
ipvs->ftp_app = app;
|
||||
|
||||
ret = register_ip_vs_app(net, app);
|
||||
if (ret)
|
||||
goto err_exit;
|
||||
app = register_ip_vs_app(net, &ip_vs_ftp);
|
||||
if (IS_ERR(app))
|
||||
return PTR_ERR(app);
|
||||
|
||||
for (i = 0; i < ports_count; i++) {
|
||||
if (!ports[i])
|
||||
@@ -464,9 +459,7 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
|
||||
return 0;
|
||||
|
||||
err_unreg:
|
||||
unregister_ip_vs_app(net, app);
|
||||
err_exit:
|
||||
kfree(ipvs->ftp_app);
|
||||
unregister_ip_vs_app(net, &ip_vs_ftp);
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
@@ -474,10 +467,7 @@ err_exit:
|
||||
*/
|
||||
static void __ip_vs_ftp_exit(struct net *net)
|
||||
{
|
||||
struct netns_ipvs *ipvs = net_ipvs(net);
|
||||
|
||||
unregister_ip_vs_app(net, ipvs->ftp_app);
|
||||
kfree(ipvs->ftp_app);
|
||||
unregister_ip_vs_app(net, &ip_vs_ftp);
|
||||
}
|
||||
|
||||
static struct pernet_operations ip_vs_ftp_ops = {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user