struct {
/* EXPR_OSF */
uint8_t ttl;
+ uint32_t flags;
} osf;
};
};
*
* @NFTA_OSF_DREG: destination register (NLA_U32: nft_registers)
* @NFTA_OSF_TTL: Value of the TTL osf option (NLA_U8)
+ * @NFTA_OSF_FLAGS: flags (NLA_U32)
*/
enum nft_osf_attributes {
NFTA_OSF_UNSPEC,
NFTA_OSF_DREG,
NFTA_OSF_TTL,
+ NFTA_OSF_FLAGS,
__NFTA_OSF_MAX
};
#define NFT_OSF_MAX (__NFTA_OSF_MAX - 1)
+enum nft_osf_flags {
+ NFT_OSF_F_VERSION = 1 << 0, /* check fingerprint version */
+};
+
/**
* enum nft_ct_keys - nf_tables ct expression keys
*
#ifndef NFTABLES_OSF_H
#define NFTABLES_OSF_H
-struct expr *osf_expr_alloc(const struct location *loc, const uint8_t ttl);
+struct expr *osf_expr_alloc(const struct location *loc, const uint8_t ttl,
+ const uint32_t flags);
extern int nfnl_osf_load_fingerprints(struct netlink_ctx *ctx, int del);
{
enum nft_registers dreg;
struct expr *expr;
+ uint32_t flags;
uint8_t ttl;
ttl = nftnl_expr_get_u8(nle, NFTNL_EXPR_OSF_TTL);
- expr = osf_expr_alloc(loc, ttl);
+ flags = nftnl_expr_get_u32(nle, NFTNL_EXPR_OSF_FLAGS);
+ expr = osf_expr_alloc(loc, ttl, flags);
dreg = netlink_parse_register(nle, NFTNL_EXPR_OSF_DREG);
netlink_set_register(ctx, dreg, expr);
nle = alloc_nft_expr("osf");
netlink_put_register(nle, NFTNL_EXPR_OSF_DREG, dreg);
nftnl_expr_set_u8(nle, NFTNL_EXPR_OSF_TTL, expr->osf.ttl);
+ nftnl_expr_set_u32(nle, NFTNL_EXPR_OSF_FLAGS, expr->osf.flags);
nftnl_rule_add_expr(ctx->nlr, nle);
}
{
const char *ttl_str = osf_ttl_int_to_str(expr->osf.ttl);
- nft_print(octx, "osf %sname", ttl_str);
+ if (expr->osf.flags & NFT_OSF_F_VERSION)
+ nft_print(octx, "osf %sversion", ttl_str);
+ else
+ nft_print(octx, "osf %sname", ttl_str);
}
static void osf_expr_clone(struct expr *new, const struct expr *expr)
{
new->osf.ttl = expr->osf.ttl;
+ new->osf.flags = expr->osf.flags;
}
static bool osf_expr_cmp(const struct expr *e1, const struct expr *e2)
{
- return e1->osf.ttl == e2->osf.ttl;
+ return (e1->osf.ttl == e2->osf.ttl) &&
+ (e1->osf.flags == e2->osf.flags);
}
const struct expr_ops osf_expr_ops = {
.json = osf_expr_json,
};
-struct expr *osf_expr_alloc(const struct location *loc, const uint8_t ttl)
+struct expr *osf_expr_alloc(const struct location *loc, const uint8_t ttl,
+ const uint32_t flags)
{
unsigned int len = NFT_OSF_MAXGENRELEN * BITS_PER_BYTE;
const struct datatype *type = &string_type;
expr = expr_alloc(loc, EXPR_OSF, type,
BYTEORDER_HOST_ENDIAN, len);
expr->osf.ttl = ttl;
+ expr->osf.flags = flags;
return expr;
}
| fib_flag
;
-osf_expr : OSF osf_ttl NAME
+osf_expr : OSF osf_ttl HDRVERSION
{
- $$ = osf_expr_alloc(&@$, $2);
+ $$ = osf_expr_alloc(&@$, $2, NFT_OSF_F_VERSION);
+ }
+ | OSF osf_ttl NAME
+ {
+ $$ = osf_expr_alloc(&@$, $2, 0);
}
;