Re: [libnftnl PATCH 1/2] src/rule: Removed mandatory attribute printing in rules

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

 



Hi Alvaro,

I found a small issue in your patch, see below.

Except for this, the patch looks good to me.

On 9 March 2014 13:59, Alvaro Neira Ayuso <alvaroneay@xxxxxxxxx> wrote:
> @@ -865,15 +904,42 @@ static int nft_rule_snprintf_xml(char *buf, size_t size, struct nft_rule *r,
>         return offset;
>  }
>
> -static int nft_rule_snprintf_default(char *buf, size_t size, struct nft_rule *r,
> +static int nft_rule_snprintf_default(char *buf, size_t size, struct nft_rule *r,
>                                      uint32_t type, uint32_t flags)
>  {
>         struct nft_rule_expr *expr;
>         int ret, len = size, offset = 0, i;
>
> -       ret = snprintf(buf, len, "%s %s %s %"PRIu64" %"PRIu64"\n",
> -                       nft_family2str(r->family), r->table, r->chain,
> -                       r->handle, r->position);
> +       if (r->flags & (1 << NFT_RULE_ATTR_FAMILY)) {
> +               ret = snprintf(buf+offset, len, "%s ",
> +                              nft_family2str(r->family));
> +               SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
> +       }
> +
> +       if (r->flags & (1 << NFT_RULE_ATTR_TABLE)) {
> +               ret = snprintf(buf+offset, len, "%s ",
> +                              r->table);
> +               SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
> +       }
> +
> +       if (r->flags & (1 << NFT_RULE_ATTR_CHAIN)) {
> +               ret = snprintf(buf+offset, len, "%s ",
> +                              r->chain);
> +               SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
> +       }
> +       if (r->flags & (1 << NFT_RULE_ATTR_TABLE)) {
> +               ret = snprintf(buf+offset, len, "%llu ",
> +                              (unsigned long long)r->handle);
> +               SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
> +       }

Here you check the table attr but print handle.

Regards.
-- 
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux