2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
/* (C) 1999-2001 Paul `Rusty' Russell
|
|
|
|
* (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
|
2013-04-06 13:24:29 +00:00
|
|
|
* (C) 2006-2012 Patrick McHardy <kaber@trash.net>
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/udp.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/ipv6.h>
|
|
|
|
#include <net/ip6_checksum.h>
|
|
|
|
#include <net/checksum.h>
|
2006-11-29 01:35:01 +00:00
|
|
|
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
#include <linux/netfilter.h>
|
|
|
|
#include <linux/netfilter_ipv4.h>
|
|
|
|
#include <linux/netfilter_ipv6.h>
|
2006-11-29 01:35:06 +00:00
|
|
|
#include <net/netfilter/nf_conntrack_l4proto.h>
|
2006-11-29 01:35:01 +00:00
|
|
|
#include <net/netfilter/nf_conntrack_ecache.h>
|
2018-06-29 05:46:50 +00:00
|
|
|
#include <net/netfilter/nf_conntrack_timeout.h>
|
2007-12-18 06:38:49 +00:00
|
|
|
#include <net/netfilter/nf_log.h>
|
2009-03-16 14:15:35 +00:00
|
|
|
#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
|
|
|
|
#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
|
2017-11-12 19:42:01 +00:00
|
|
|
static const unsigned int udp_timeouts[UDP_CT_MAX] = {
|
2012-02-28 01:23:28 +00:00
|
|
|
[UDP_CT_UNREPLIED] = 30*HZ,
|
2018-12-17 23:05:29 +00:00
|
|
|
[UDP_CT_REPLIED] = 120*HZ,
|
2012-02-28 01:23:28 +00:00
|
|
|
};
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
|
2012-02-28 17:23:31 +00:00
|
|
|
static unsigned int *udp_get_timeouts(struct net *net)
|
|
|
|
{
|
2018-11-01 23:11:34 +00:00
|
|
|
return nf_udp_pernet(net)->timeouts;
|
2012-02-28 17:23:31 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
static void udp_error_log(const struct sk_buff *skb,
|
|
|
|
const struct nf_hook_state *state,
|
|
|
|
const char *msg)
|
|
|
|
{
|
2021-06-16 20:06:19 +00:00
|
|
|
nf_l4proto_log_invalid(skb, state, IPPROTO_UDP, "%s", msg);
|
2018-09-12 13:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool udp_error(struct sk_buff *skb,
|
|
|
|
unsigned int dataoff,
|
|
|
|
const struct nf_hook_state *state)
|
|
|
|
{
|
|
|
|
unsigned int udplen = skb->len - dataoff;
|
|
|
|
const struct udphdr *hdr;
|
|
|
|
struct udphdr _hdr;
|
|
|
|
|
|
|
|
/* Header is too small? */
|
|
|
|
hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
|
|
|
|
if (!hdr) {
|
|
|
|
udp_error_log(skb, state, "short packet");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Truncated/malformed packets */
|
|
|
|
if (ntohs(hdr->len) > udplen || ntohs(hdr->len) < sizeof(*hdr)) {
|
|
|
|
udp_error_log(skb, state, "truncated/malformed packet");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Packet with no checksum */
|
|
|
|
if (!hdr->check)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Checksum invalid? Ignore.
|
|
|
|
* We skip checking packets on the outgoing path
|
|
|
|
* because the checksum is assumed to be correct.
|
|
|
|
* FIXME: Source route IP option packets --RR */
|
|
|
|
if (state->hook == NF_INET_PRE_ROUTING &&
|
|
|
|
state->net->ct.sysctl_checksum &&
|
|
|
|
nf_checksum(skb, state->hook, dataoff, IPPROTO_UDP, state->pf)) {
|
|
|
|
udp_error_log(skb, state, "bad checksum");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
/* Returns verdict for packet, and may modify conntracktype */
|
2019-01-15 21:03:32 +00:00
|
|
|
int nf_conntrack_udp_packet(struct nf_conn *ct,
|
|
|
|
struct sk_buff *skb,
|
|
|
|
unsigned int dataoff,
|
|
|
|
enum ip_conntrack_info ctinfo,
|
|
|
|
const struct nf_hook_state *state)
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
{
|
2018-06-29 05:46:50 +00:00
|
|
|
unsigned int *timeouts;
|
2023-01-02 11:46:12 +00:00
|
|
|
unsigned long status;
|
2018-06-29 05:46:50 +00:00
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
if (udp_error(skb, dataoff, state))
|
|
|
|
return -NF_ACCEPT;
|
|
|
|
|
2018-06-29 05:46:50 +00:00
|
|
|
timeouts = nf_ct_timeout_lookup(ct);
|
|
|
|
if (!timeouts)
|
|
|
|
timeouts = udp_get_timeouts(nf_ct_net(ct));
|
|
|
|
|
2023-01-02 11:46:12 +00:00
|
|
|
status = READ_ONCE(ct->status);
|
|
|
|
if ((status & IPS_CONFIRMED) == 0)
|
2018-12-06 10:50:49 +00:00
|
|
|
ct->proto.udp.stream_ts = 2 * HZ + jiffies;
|
|
|
|
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
/* If we've seen traffic both ways, this is some kind of UDP
|
2018-12-06 10:50:49 +00:00
|
|
|
* stream. Set Assured.
|
|
|
|
*/
|
2023-01-23 12:04:33 +00:00
|
|
|
if (status & IPS_SEEN_REPLY) {
|
2018-12-06 10:50:49 +00:00
|
|
|
unsigned long extra = timeouts[UDP_CT_UNREPLIED];
|
2021-10-25 09:26:49 +00:00
|
|
|
bool stream = false;
|
2018-12-06 10:50:49 +00:00
|
|
|
|
|
|
|
/* Still active after two seconds? Extend timeout. */
|
2021-10-25 09:26:49 +00:00
|
|
|
if (time_after(jiffies, ct->proto.udp.stream_ts)) {
|
2018-12-06 10:50:49 +00:00
|
|
|
extra = timeouts[UDP_CT_REPLIED];
|
2023-01-02 11:46:12 +00:00
|
|
|
stream = (status & IPS_ASSURED) == 0;
|
2021-10-25 09:26:49 +00:00
|
|
|
}
|
2018-12-06 10:50:49 +00:00
|
|
|
|
|
|
|
nf_ct_refresh_acct(ct, ctinfo, skb, extra);
|
|
|
|
|
2020-08-25 22:07:18 +00:00
|
|
|
/* never set ASSURED for IPS_NAT_CLASH, they time out soon */
|
2023-01-02 11:46:12 +00:00
|
|
|
if (unlikely((status & IPS_NAT_CLASH)))
|
2020-08-25 22:07:18 +00:00
|
|
|
return NF_ACCEPT;
|
|
|
|
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
/* Also, more likely to be important, and not a probe */
|
2021-10-25 09:26:49 +00:00
|
|
|
if (stream && !test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
|
2010-02-03 12:48:53 +00:00
|
|
|
nf_conntrack_event_cache(IPCT_ASSURED, ct);
|
2012-02-28 01:23:28 +00:00
|
|
|
} else {
|
2020-08-25 22:07:18 +00:00
|
|
|
nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED]);
|
2012-02-28 01:23:28 +00:00
|
|
|
}
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
return NF_ACCEPT;
|
|
|
|
}
|
|
|
|
|
2016-12-20 20:57:02 +00:00
|
|
|
#ifdef CONFIG_NF_CT_PROTO_UDPLITE
|
2018-09-12 13:19:07 +00:00
|
|
|
static void udplite_error_log(const struct sk_buff *skb,
|
|
|
|
const struct nf_hook_state *state,
|
|
|
|
const char *msg)
|
2017-10-11 08:47:40 +00:00
|
|
|
{
|
2021-06-16 20:06:19 +00:00
|
|
|
nf_l4proto_log_invalid(skb, state, IPPROTO_UDPLITE, "%s", msg);
|
2017-10-11 08:47:40 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
static bool udplite_error(struct sk_buff *skb,
|
|
|
|
unsigned int dataoff,
|
|
|
|
const struct nf_hook_state *state)
|
2016-12-20 20:57:02 +00:00
|
|
|
{
|
|
|
|
unsigned int udplen = skb->len - dataoff;
|
|
|
|
const struct udphdr *hdr;
|
|
|
|
struct udphdr _hdr;
|
|
|
|
unsigned int cscov;
|
|
|
|
|
|
|
|
/* Header is too small? */
|
|
|
|
hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
|
|
|
|
if (!hdr) {
|
2018-09-12 13:19:07 +00:00
|
|
|
udplite_error_log(skb, state, "short packet");
|
2018-09-12 13:19:09 +00:00
|
|
|
return true;
|
2016-12-20 20:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cscov = ntohs(hdr->len);
|
|
|
|
if (cscov == 0) {
|
|
|
|
cscov = udplen;
|
|
|
|
} else if (cscov < sizeof(*hdr) || cscov > udplen) {
|
2018-09-12 13:19:07 +00:00
|
|
|
udplite_error_log(skb, state, "invalid checksum coverage");
|
2018-09-12 13:19:09 +00:00
|
|
|
return true;
|
2016-12-20 20:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* UDPLITE mandates checksums */
|
|
|
|
if (!hdr->check) {
|
2018-09-12 13:19:07 +00:00
|
|
|
udplite_error_log(skb, state, "checksum missing");
|
2018-09-12 13:19:09 +00:00
|
|
|
return true;
|
2016-12-20 20:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Checksum invalid? Ignore. */
|
2018-09-12 13:19:07 +00:00
|
|
|
if (state->hook == NF_INET_PRE_ROUTING &&
|
|
|
|
state->net->ct.sysctl_checksum &&
|
|
|
|
nf_checksum_partial(skb, state->hook, dataoff, cscov, IPPROTO_UDP,
|
|
|
|
state->pf)) {
|
|
|
|
udplite_error_log(skb, state, "bad checksum");
|
2018-09-12 13:19:09 +00:00
|
|
|
return true;
|
2016-12-20 20:57:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
return false;
|
2016-12-20 20:57:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
/* Returns verdict for packet, and may modify conntracktype */
|
2019-01-15 21:03:32 +00:00
|
|
|
int nf_conntrack_udplite_packet(struct nf_conn *ct,
|
|
|
|
struct sk_buff *skb,
|
|
|
|
unsigned int dataoff,
|
|
|
|
enum ip_conntrack_info ctinfo,
|
|
|
|
const struct nf_hook_state *state)
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
{
|
2018-09-12 13:19:09 +00:00
|
|
|
unsigned int *timeouts;
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
if (udplite_error(skb, dataoff, state))
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
return -NF_ACCEPT;
|
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
timeouts = nf_ct_timeout_lookup(ct);
|
|
|
|
if (!timeouts)
|
|
|
|
timeouts = udp_get_timeouts(nf_ct_net(ct));
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
/* If we've seen traffic both ways, this is some kind of UDP
|
|
|
|
stream. Extend timeout. */
|
|
|
|
if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
|
|
|
|
nf_ct_refresh_acct(ct, ctinfo, skb,
|
|
|
|
timeouts[UDP_CT_REPLIED]);
|
2020-08-25 22:07:18 +00:00
|
|
|
|
|
|
|
if (unlikely((ct->status & IPS_NAT_CLASH)))
|
|
|
|
return NF_ACCEPT;
|
|
|
|
|
2018-09-12 13:19:09 +00:00
|
|
|
/* Also, more likely to be important, and not a probe */
|
|
|
|
if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
|
|
|
|
nf_conntrack_event_cache(IPCT_ASSURED, ct);
|
|
|
|
} else {
|
2020-08-25 22:07:18 +00:00
|
|
|
nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED]);
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
}
|
|
|
|
return NF_ACCEPT;
|
|
|
|
}
|
2018-09-12 13:19:09 +00:00
|
|
|
#endif
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
|
2018-08-31 10:36:01 +00:00
|
|
|
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
|
2012-02-28 18:13:48 +00:00
|
|
|
|
|
|
|
#include <linux/netfilter/nfnetlink.h>
|
|
|
|
#include <linux/netfilter/nfnetlink_cttimeout.h>
|
|
|
|
|
2012-05-28 21:04:23 +00:00
|
|
|
static int udp_timeout_nlattr_to_obj(struct nlattr *tb[],
|
|
|
|
struct net *net, void *data)
|
2012-02-28 18:13:48 +00:00
|
|
|
{
|
|
|
|
unsigned int *timeouts = data;
|
2018-11-01 23:11:34 +00:00
|
|
|
struct nf_udp_net *un = nf_udp_pernet(net);
|
2012-02-28 18:13:48 +00:00
|
|
|
|
2018-06-29 05:46:50 +00:00
|
|
|
if (!timeouts)
|
|
|
|
timeouts = un->timeouts;
|
|
|
|
|
2012-02-28 18:13:48 +00:00
|
|
|
/* set default timeouts for UDP. */
|
2012-05-28 21:04:23 +00:00
|
|
|
timeouts[UDP_CT_UNREPLIED] = un->timeouts[UDP_CT_UNREPLIED];
|
|
|
|
timeouts[UDP_CT_REPLIED] = un->timeouts[UDP_CT_REPLIED];
|
2012-02-28 18:13:48 +00:00
|
|
|
|
|
|
|
if (tb[CTA_TIMEOUT_UDP_UNREPLIED]) {
|
|
|
|
timeouts[UDP_CT_UNREPLIED] =
|
|
|
|
ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDP_UNREPLIED])) * HZ;
|
|
|
|
}
|
|
|
|
if (tb[CTA_TIMEOUT_UDP_REPLIED]) {
|
|
|
|
timeouts[UDP_CT_REPLIED] =
|
|
|
|
ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDP_REPLIED])) * HZ;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
udp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
|
|
|
|
{
|
|
|
|
const unsigned int *timeouts = data;
|
|
|
|
|
2012-04-01 22:48:06 +00:00
|
|
|
if (nla_put_be32(skb, CTA_TIMEOUT_UDP_UNREPLIED,
|
|
|
|
htonl(timeouts[UDP_CT_UNREPLIED] / HZ)) ||
|
|
|
|
nla_put_be32(skb, CTA_TIMEOUT_UDP_REPLIED,
|
|
|
|
htonl(timeouts[UDP_CT_REPLIED] / HZ)))
|
|
|
|
goto nla_put_failure;
|
2012-02-28 18:13:48 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
return -ENOSPC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct nla_policy
|
|
|
|
udp_timeout_nla_policy[CTA_TIMEOUT_UDP_MAX+1] = {
|
|
|
|
[CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 },
|
|
|
|
[CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 },
|
|
|
|
};
|
2018-08-31 10:36:01 +00:00
|
|
|
#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
|
2012-02-28 18:13:48 +00:00
|
|
|
|
2019-01-15 21:03:45 +00:00
|
|
|
void nf_conntrack_udp_init_net(struct net *net)
|
2012-05-28 21:04:13 +00:00
|
|
|
{
|
2018-11-01 23:11:34 +00:00
|
|
|
struct nf_udp_net *un = nf_udp_pernet(net);
|
2019-01-15 21:03:45 +00:00
|
|
|
int i;
|
2012-05-28 21:04:13 +00:00
|
|
|
|
2019-01-15 21:03:45 +00:00
|
|
|
for (i = 0; i < UDP_CT_MAX; i++)
|
|
|
|
un->timeouts[i] = udp_timeouts[i];
|
2021-06-03 12:12:34 +00:00
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
|
|
|
|
un->offload_timeout = 30 * HZ;
|
|
|
|
#endif
|
2012-06-29 05:23:24 +00:00
|
|
|
}
|
|
|
|
|
2018-09-17 10:02:54 +00:00
|
|
|
const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp =
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
{
|
2006-11-29 01:35:06 +00:00
|
|
|
.l4proto = IPPROTO_UDP,
|
2016-04-30 22:28:40 +00:00
|
|
|
.allow_clash = true,
|
2011-12-12 02:58:24 +00:00
|
|
|
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
|
2007-09-28 21:37:41 +00:00
|
|
|
.tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
|
|
|
|
.nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
|
2009-03-25 20:53:39 +00:00
|
|
|
.nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
|
2007-09-28 21:39:55 +00:00
|
|
|
.nla_policy = nf_ct_port_nla_policy,
|
2006-01-05 20:19:05 +00:00
|
|
|
#endif
|
2018-08-31 10:36:01 +00:00
|
|
|
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
|
2012-02-28 18:13:48 +00:00
|
|
|
.ctnl_timeout = {
|
|
|
|
.nlattr_to_obj = udp_timeout_nlattr_to_obj,
|
|
|
|
.obj_to_nlattr = udp_timeout_obj_to_nlattr,
|
|
|
|
.nlattr_max = CTA_TIMEOUT_UDP_MAX,
|
|
|
|
.obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
|
|
|
|
.nla_policy = udp_timeout_nla_policy,
|
|
|
|
},
|
2018-08-31 10:36:01 +00:00
|
|
|
#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
|
[NETFILTER]: Add nf_conntrack subsystem.
The existing connection tracking subsystem in netfilter can only
handle ipv4. There were basically two choices present to add
connection tracking support for ipv6. We could either duplicate all
of the ipv4 connection tracking code into an ipv6 counterpart, or (the
choice taken by these patches) we could design a generic layer that
could handle both ipv4 and ipv6 and thus requiring only one sub-protocol
(TCP, UDP, etc.) connection tracking helper module to be written.
In fact nf_conntrack is capable of working with any layer 3
protocol.
The existing ipv4 specific conntrack code could also not deal
with the pecularities of doing connection tracking on ipv6,
which is also cured here. For example, these issues include:
1) ICMPv6 handling, which is used for neighbour discovery in
ipv6 thus some messages such as these should not participate
in connection tracking since effectively they are like ARP
messages
2) fragmentation must be handled differently in ipv6, because
the simplistic "defrag, connection track and NAT, refrag"
(which the existing ipv4 connection tracking does) approach simply
isn't feasible in ipv6
3) ipv6 extension header parsing must occur at the correct spots
before and after connection tracking decisions, and there were
no provisions for this in the existing connection tracking
design
4) ipv6 has no need for stateful NAT
The ipv4 specific conntrack layer is kept around, until all of
the ipv4 specific conntrack helpers are ported over to nf_conntrack
and it is feature complete. Once that occurs, the old conntrack
stuff will get placed into the feature-removal-schedule and we will
fully kill it off 6 months later.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2005-11-10 00:38:16 +00:00
|
|
|
};
|
|
|
|
|
2016-12-20 20:57:02 +00:00
|
|
|
#ifdef CONFIG_NF_CT_PROTO_UDPLITE
|
2018-09-17 10:02:54 +00:00
|
|
|
const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite =
|
2016-12-20 20:57:02 +00:00
|
|
|
{
|
|
|
|
.l4proto = IPPROTO_UDPLITE,
|
|
|
|
.allow_clash = true,
|
|
|
|
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
|
|
|
|
.tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
|
|
|
|
.nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
|
|
|
|
.nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
|
|
|
|
.nla_policy = nf_ct_port_nla_policy,
|
|
|
|
#endif
|
2018-08-31 10:36:01 +00:00
|
|
|
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
|
2016-12-20 20:57:02 +00:00
|
|
|
.ctnl_timeout = {
|
|
|
|
.nlattr_to_obj = udp_timeout_nlattr_to_obj,
|
|
|
|
.obj_to_nlattr = udp_timeout_obj_to_nlattr,
|
|
|
|
.nlattr_max = CTA_TIMEOUT_UDP_MAX,
|
|
|
|
.obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
|
|
|
|
.nla_policy = udp_timeout_nla_policy,
|
|
|
|
},
|
2018-08-31 10:36:01 +00:00
|
|
|
#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
|
2016-12-20 20:57:02 +00:00
|
|
|
};
|
|
|
|
#endif
|