expr: meta: Add pkttype support
Subsystems (2)
PATCH 1/1 expr: meta: Add pkttype support
Add pkttype support in meta. The pkttype option does not set.
Before, If we want to declare a pktype, It has used a syntax like this:
nft add rule ip filter input meta pkttype broadcast
Joint work with Alvaro Neira Ayuso <[email protected]>
--- include/linux/netfilter/nf_tables.h | 2 ++ src/expr/meta.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/netfilter/nf_tables.h +2 -0
@@ -571,6 +571,7 @@ enum nft_exthdr_attributes {* @NFT_META_L4PROTO: layer 4 protocol number * @NFT_META_BRI_IIFNAME: packet input bridge interface name * @NFT_META_BRI_OIFNAME: packet output bridge interface name +* @NFT_META_PKTTYPE: Packet class */ enum nft_meta_keys {NFT_META_LEN ,
@@ -592,6 +593,7 @@ enum nft_meta_keys {NFT_META_L4PROTO ,NFT_META_BRI_IIFNAME ,NFT_META_BRI_OIFNAME , + NFT_META_PKTTYPE, };/**
src/expr/meta.c +2 -1
@@ -23,7 +23,7 @@#include "expr_ops.h" #ifndef NFT_META_MAX -#define NFT_META_MAX (NFT_META_BRI_OIFNAME + 1) +#define NFT_META_MAX (NFT_META_PKTTYPE + 1)#endif struct nft_expr_meta {
@@ -155,6 +155,7 @@ static const char *meta_key2str_array[NFT_META_MAX] = { [NFT_META_SECMARK] = "secmark", [NFT_META_BRI_IIFNAME] = "bri_iifname", [NFT_META_BRI_OIFNAME] = "bri_oifname", + [NFT_META_PKTTYPE] = "pkttype" };static const char *meta_key2str (uint8_t key)
Signature · 1 line
2.0.0
PATCH 1/1 netfilter: nf_tables: add pktype support to meta expression
Joint work with Álvaro Neira Ayuso <[email protected]>
--- include/uapi/linux/netfilter/nf_tables.h | 2 ++ net/netfilter/nft_meta.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
include/uapi/linux/netfilter/nf_tables.h +2 -0
@@ -571,6 +571,7 @@ enum nft_exthdr_attributes {* @NFT_META_L4PROTO: layer 4 protocol number * @NFT_META_BRI_IIFNAME: packet input bridge interface name * @NFT_META_BRI_OIFNAME: packet output bridge interface name +* @NFT_META_PKTTYPE: Packet class */ enum nft_meta_keys {NFT_META_LEN ,
@@ -592,6 +593,7 @@ enum nft_meta_keys {NFT_META_L4PROTO ,NFT_META_BRI_IIFNAME ,NFT_META_BRI_OIFNAME , + NFT_META_PKTTYPE, };/**
net/netfilter/nft_meta.c +17 -0
@@ -14,6 +14,9 @@#include <linux/netlink.h> #include <linux/netfilter.h> #include <linux/netfilter/nf_tables.h> +#include <linux/in.h> +#include <linux/ip.h> +#include <linux/ipv6.h> #include <net/dst.h> #include <net/sock.h> #include <net/tcp_states.h> /* for TCP_TIME_WAIT */
@@ -124,6 +127,19 @@ void nft_meta_get_eval(const struct nft_expr *expr, dest->data[0 ] = skb->secmark;break ;#endif +case NFT_META_PKTTYPE : + dest->data[0 ] = skb->pkt_type; +if (skb->pkt_type !=PACKET_LOOPBACK ) + dest->data[0 ] = skb->pkt_type; +else if (expr->ops->type->family ==NFPROTO_IPV4 && +ipv4_is_multicast (ip_hdr (skb)->daddr)) + dest->data[0 ] =PACKET_MULTICAST ; +else if (expr->ops->type->family ==NFPROTO_IPV6 && +ipv6_hdr (skb)->daddr.s6_addr[0 ] ==0xFF ) + dest->data[0 ] =PACKET_MULTICAST ; +else + dest->data[0 ] =PACKET_BROADCAST ; +break ;default :WARN_ON (1 ); goto err;
@@ -194,6 +210,7 @@ int nft_meta_get_init(const struct nft_ctx *ctx,#endif #ifdef CONFIG_NETWORK_SECMARK case NFT_META_SECMARK : +case NFT_META_PKTTYPE :#endif break ;default :
Signature · 6 lines
2.0.0 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 src: Add support for pkttype in meta
In reply to Ana ReyJoint work with Alvaro Neira Ayuso <[email protected]>
--- include/datatype.h | 1 + include/linux/netfilter/nf_tables.h | 2 ++ src/meta.c | 55 +++++++++++++++++++++++++++++++++++++ src/parser.y | 2 ++ src/scanner.l | 1 + 5 files changed, 61 insertions(+)
include/datatype.h +1 -0
@@ -70,6 +70,7 @@ enum datatypes {TYPE_CT_STATUS ,TYPE_ICMP6_TYPE ,TYPE_CT_LABEL , +TYPE_PKTTYPE , __TYPE_MAX };#define TYPE_MAX (__TYPE_MAX - 1)
include/linux/netfilter/nf_tables.h +2 -0
@@ -535,6 +535,7 @@ enum nft_exthdr_attributes {* @NFT_META_L4PROTO: layer 4 protocol number * @NFT_META_BRI_IIFNAME: packet input bridge interface name * @NFT_META_BRI_OIFNAME: packet output bridge interface name +* @@NFT_META_PKTTYPE: packet class */ enum nft_meta_keys {NFT_META_LEN ,
@@ -556,6 +557,7 @@ enum nft_meta_keys {NFT_META_L4PROTO ,NFT_META_BRI_IIFNAME ,NFT_META_BRI_OIFNAME , + NFT_META_PKTTYPE, };/**
src/meta.c +55 -0
73 lines not on this page · raw message
src/parser.y +2 -0
@@ -324,6 +324,7 @@ static int monitor_lookup_event(const char *event) %token RTCLASSID "rtclassid" %token IBRIPORT "ibriport" %token OBRIPORT "obriport" +%token PKTTYPE "pkttype" %token CT "ct" %token DIRECTION "direction"
@@ -1784,6 +1785,7 @@ meta_key_unqualified : MARK { $$ = NFT_META_MARK; } | RTCLASSID { $$ = NFT_META_RTCLASSID; } | IBRIPORT { $$ = NFT_META_BRI_IIFNAME; } | OBRIPORT { $$ = NFT_META_BRI_OIFNAME; } + | PKTTYPE { $$ = NFT_META_PKTTYPE; } ; meta_stmt : META meta_key SET expr
src/scanner.l +1 -0
@@ -406,6 +406,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "rtclassid" { return RTCLASSID; } "ibriport" { return IBRIPORT; } "obriport" { return OBRIPORT; } +"pkttype" { return PKTTYPE; } "ct" { return CT; } "direction" { return DIRECTION; }
Signature · 1 line
2.0.0
Re: [PATCH] netfilter: nf_tables: add pktype support to meta expression
In reply to Ana ReyOn 12 June 2014 19:17, Ana Rey <[email protected]> wrote:
[...]
net/netfilter/nft_meta.c int nft_meta_get_init(const struct nft_ctx *ctx, · line 214
Quoted 6 lines
net/netfilter/nft_meta.c +1
-0@@ -194,6 +210,7 @@ int nft_meta_get_init(const struct nft_ctx *ctx,#endif #ifdef CONFIG_NETWORK_SECMARK case NFT_META_SECMARK : +case NFT_META_PKTTYPE :#endif
Why to enclose this in the #ifdef CONFIG_NETWORK_SECMARK?
regards
Signature · 5 lines
Arturo Borrero González -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 expr: meta: Add pkttype support
In reply to Ana ReyAdd pkttype support in meta. The pkttype option does not set.
---
[Changes in v2:]
Fix the description of @NFT_META_PKTTYPE expression keys
include/linux/netfilter/nf_tables.h | 2 ++ src/expr/meta.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/netfilter/nf_tables.h +2 -0
@@ -571,6 +571,7 @@ enum nft_exthdr_attributes {* @NFT_META_L4PROTO: layer 4 protocol number * @NFT_META_BRI_IIFNAME: packet input bridge interface name * @NFT_META_BRI_OIFNAME: packet output bridge interface name +* @NFT_META_PKTTYPE: Packet type */ enum nft_meta_keys {NFT_META_LEN ,
@@ -592,6 +593,7 @@ enum nft_meta_keys {NFT_META_L4PROTO ,NFT_META_BRI_IIFNAME ,NFT_META_BRI_OIFNAME , + NFT_META_PKTTYPE, };/**
src/expr/meta.c +2 -1
@@ -23,7 +23,7 @@#include "expr_ops.h" #ifndef NFT_META_MAX -#define NFT_META_MAX (NFT_META_BRI_OIFNAME + 1) +#define NFT_META_MAX (NFT_META_PKTTYPE + 1)#endif struct nft_expr_meta {
@@ -153,6 +153,7 @@ static const char *meta_key2str_array[NFT_META_MAX] = { [NFT_META_SECMARK] = "secmark", [NFT_META_BRI_IIFNAME] = "bri_iifname", [NFT_META_BRI_OIFNAME] = "bri_oifname", + [NFT_META_PKTTYPE] = "pkttype" };static const char *meta_key2str (uint8_t key)
Signature · 1 line
1.7.10.4