netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next 0/5] netfilter: nft: introduce routing expression
@ 2016-10-16 13:40 Anders K. Pedersen | Cohaesio
  2016-10-16 13:41 ` [PATCH nf-next 1/5] netfilter: nft: UAPI headers for " Anders K. Pedersen | Cohaesio
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Anders K. Pedersen | Cohaesio @ 2016-10-16 13:40 UTC (permalink / raw)
  To: netfilter-devel@vger.kernel.org, pablo@netfilter.org

This patch series introduces an nftables rt expression for routing related
data with support for nexthop (i.e. the directly connected IP address that
an outgoing packet is sent to), which can be used either for matching or
accounting, eg.

 # nft add rule filter postrouting \
        ip daddr 192.168.1.0/24 rt ip nexthop != 192.168.0.1 drop

This will drop any traffic to 192.168.1.0/24 that is not routed via
192.168.0.1.

 # nft add rule filter postrouting \
        flow table acct { rt ip nexthop timeout 600s counter }
 # nft add rule ip6 filter postrouting \
        flow table acct { rt ip6 nexthop6 timeout 600s counter }

These rules count outgoing traffic per nexthop. Note that the timeout
releases an entry if no traffic is seen for this nexthop within 10 minutes.

 # nft add rule inet filter postrouting \
        ether type ip \
        flow table acct { rt ip nexthop timeout 600s counter }
 # nft add rule inet filter postrouting \
        ether type ip6 \
        flow table acct { rt ip6 nexthop6 timeout 600s counter }

Same as above, but via the inet family, where the ether type must be
specified explicitly.

"rt classid" is also implemented identical to "meta rtclassid", since it
is more logical to have this match in the routing expression going forward.

Regards,
Anders K. Pedersen
---
 include/net/netfilter/nft_rt.h           |  23 +++++
 include/uapi/linux/netfilter/nf_tables.h |  26 ++++++
 net/ipv4/netfilter/Kconfig               |   4 +
 net/ipv4/netfilter/Makefile              |   1 +
 net/ipv4/netfilter/nft_rt_ipv4.c         | 117 ++++++++++++++++++++++++
 net/ipv6/netfilter/Kconfig               |   4 +
 net/ipv6/netfilter/Makefile              |   1 +
 net/ipv6/netfilter/nft_rt_ipv6.c         | 118 ++++++++++++++++++++++++
 net/netfilter/Kconfig                    |  11 +++
 net/netfilter/Makefile                   |   2 +
 net/netfilter/nft_rt.c                   | 145 ++++++++++++++++++++++++++++++
 net/netfilter/nft_rt_inet.c              | 150 +++++++++++++++++++++++++++++++
 12 files changed, 602 insertions(+)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-17 12:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-16 13:40 [PATCH nf-next 0/5] netfilter: nft: introduce routing expression Anders K. Pedersen | Cohaesio
2016-10-16 13:41 ` [PATCH nf-next 1/5] netfilter: nft: UAPI headers for " Anders K. Pedersen | Cohaesio
2016-10-17  7:32   ` Arturo Borrero Gonzalez
2016-10-16 13:42 ` [PATCH nf-next 2/5] netfilter: nft: basic " Anders K. Pedersen | Cohaesio
2016-10-17  7:41   ` Arturo Borrero Gonzalez
2016-10-17 12:30     ` Anders K. Pedersen | Cohaesio
2016-10-16 13:44 ` [PATCH nf-next 3/5] netfilter: nft: rt nexthop for IPv4 family Anders K. Pedersen | Cohaesio
2016-10-16 13:45 ` [PATCH nf-next 4/5] netfilter: nft: rt nexthop for IPv6 family Anders K. Pedersen | Cohaesio
2016-10-16 13:46 ` [PATCH nf-next 5/5] netfilter: nft: rt nexthop for inet family Anders K. Pedersen | Cohaesio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).