Re: [PATCH v3 nf-next 2/5] netfilter: nft: basic routing expression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Liping,

On fre, 2016-10-21 at 10:17 +0800, Liping Zhang wrote:
> 2016-10-21 3:09 GMT+08:00 Anders K. Pedersen | Cohaesio <akp@cohaesio
> .com>:
> +int nft_rt_get_init(const struct nft_ctx *ctx,
> > +                   const struct nft_expr *expr,
> > +                   const struct nlattr * const tb[])
> > +{
> > +       struct nft_rt *priv = nft_expr_priv(expr);
> > +       unsigned int len;
> > +
> > +       if (tb[NFTA_RT_KEY] == NULL ||
> > +           tb[NFTA_RT_DREG] == NULL ||
> > +           tb[NFTA_RT_FAMILY] == NULL)
> 
> The judgement here is also confusing to me, we do not use family
> in NFT_RT_CLASSID key, so why we force the user that they
> must specify the NFTA_RT_FAMILY attribute?

I will change this to

--- nft_rt.c~   2016-10-19 20:22:42.000000000 +0200
+++ nft_rt.c    2016-10-21 06:22:27.752000000 +0200
@@ -62,8 +62,7 @@
        unsigned int len;

 	if (tb[NFTA_RT_KEY] == NULL ||
-	    tb[NFTA_RT_DREG] == NULL ||
-	    tb[NFTA_RT_FAMILY] == NULL)
+	    tb[NFTA_RT_DREG] == NULL)
 		return -EINVAL;
 
 	priv->key = ntohl(nla_get_be32(tb[NFTA_RT_KEY]));
@@ -77,7 +76,11 @@
 		return -EOPNOTSUPP;
 	}
 
-	priv->family = ntohl(nla_get_be32(tb[NFTA_RT_FAMILY]));
+	if (tb[NFTA_RT_FAMILY] == NULL)
+		priv->family = NFPROTO_UNSPEC;
+	else
+		priv->family = ntohl(nla_get_be32(tb[NFTA_RT_FAMILY]));
+
 	priv->dreg = nft_parse_register(tb[NFTA_RT_DREG]);
 	return nft_validate_register_store(ctx, priv->dreg, NULL,
 					   NFT_DATA_VALUE, len);

> As I mentioned in another reply, I think the NFTA_RT_FAMILY attr
> is redundant.

I answered that in the other thread.

Regards,
Anders
��.n��������+%������w��{.n����z��׫���n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux