[PATCH] act: fix the logic of parsing actions

Thomas Haller thaller at redhat.com
Tue Apr 15 04:01:58 PDT 2014


On Mon, 2014-04-14 at 18:39 -0700, Cong Wang wrote:
> It is proved that actions are not always put from 0,
> they could be discontinuous.
> 
> Signed-off-by: Cong Wang <xiyou.wangcong at gmail.com>
> ---
>  lib/route/act.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/route/act.c b/lib/route/act.c
> index 3141866..a2ca335 100644
> --- a/lib/route/act.c
> +++ b/lib/route/act.c
> @@ -390,10 +390,13 @@ int rtnl_act_parse(struct rtnl_act **head, struct nlattr *tb)
>  	if (err < 0)
>  		return err;
>  
> -	for (i = 0; i < TCA_ACT_MAX_PRIO && nla[i]; i++) {
> +	for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
>  		struct rtnl_act *act;
>  		struct rtnl_tc *tc;
>  
> +		if (nla[i] == NULL)
> +			continue;
> +
>  		act = rtnl_act_alloc();
>  		if (!act) {
>  			err = -NLE_NOMEM;

Hi Cong,


The parsed rtnl_act instances are put in the linked list @head. Up to
now, the index of the items in the list correspond to the netlink
attribute (@i) as they were provided by the netlink message.

With this patch (by skipping over wholes), the index does no longer
correspond to the attribute. See also rtnl_act_fill() which seems to
care about the index too.

Is this really correct? Maybe we would have to insert a dummy-object
instead of skipping over with continue? 


Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20140415/9c096345/attachment.sig>


More information about the libnl mailing list