[PATCH] route/cls: Support setting of selector fields

Jef Oliver jef at eljef.me
Fri Oct 21 14:08:30 PDT 2016


This patch is replaced by v2:
http://lists.infradead.org/pipermail/libnl/2016-October/002231.html

On Wed, Sep 28, 2016 at 11:59 AM, Sushma Sitaram
<sushma.sitaram at intel.com> wrote:
> Enables to set the shift, offset, mask and flags of the position to next header
>
> Signed-off-by Sushma Sitaram: Sushma Sitaram <sushma.sitaram at intel.com>
> ---
>  include/netlink/route/cls/u32.h |    1 +
>  lib/route/cls/u32.c             |   30 ++++++++++++++++++++++++++++++
>  libnl-route-3.sym               |    1 +
>  3 files changed, 32 insertions(+)
>
> diff --git a/include/netlink/route/cls/u32.h b/include/netlink/route/cls/u32.h
> index 151c818..7475443 100644
> --- a/include/netlink/route/cls/u32.h
> +++ b/include/netlink/route/cls/u32.h
> @@ -28,6 +28,7 @@ extern int    rtnl_u32_set_divisor(struct rtnl_cls *, uint32_t);
>  extern int     rtnl_u32_set_link(struct rtnl_cls *, uint32_t);
>  extern int     rtnl_u32_set_hashtable(struct rtnl_cls *, uint32_t);
>  extern int     rtnl_u32_set_hashmask(struct rtnl_cls *, uint32_t, uint32_t);
> +extern int     rtnl_u32_set_selector(struct rtnl_cls *, int, uint32_t, char, uint16_t, char);
>  extern int     rtnl_u32_set_cls_terminal(struct rtnl_cls *);
>
>  extern int     rtnl_u32_set_flags(struct rtnl_cls *, int);
> diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c
> index 8ffca07..765a6d1 100644
> --- a/lib/route/cls/u32.c
> +++ b/lib/route/cls/u32.c
> @@ -491,6 +491,36 @@ int rtnl_u32_set_hashmask(struct rtnl_cls *cls, uint32_t hashmask, uint32_t offs
>         return 0;
>  }
>
> +int rtnl_u32_set_selector(struct rtnl_cls *cls, int offoff, uint32_t offmask, char offshift, uint16_t off, char flags)
> +{
> +       struct rtnl_u32 *u;
> +       struct tc_u32_sel *sel;
> +       int err;
> +
> +       offmask = ntohs(offmask);
> +
> +       if (!(u = (struct rtnl_u32 *) rtnl_tc_data(TC_CAST(cls))))
> +               return -NLE_NOMEM;
> +
> +       sel = u32_selector_alloc(u);
> +       if (!sel)
> +               return -NLE_NOMEM;
> +
> +       err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key));
> +       if(err < 0)
> +       return err;
> +
> +       sel = u32_selector(u);
> +
> +       sel->offoff = offoff;
> +       sel->offmask = offmask;
> +       sel->offshift = offshift;
> +       sel->flags |= TC_U32_VAROFFSET;
> +       sel->off = off;
> +       sel->flags |= flags;
> +       return 0;
> +}
> +
>  int rtnl_u32_set_cls_terminal(struct rtnl_cls *cls)
>  {
>         struct rtnl_u32 *u;
> diff --git a/libnl-route-3.sym b/libnl-route-3.sym
> index 448a617..2fc0dfa 100644
> --- a/libnl-route-3.sym
> +++ b/libnl-route-3.sym
> @@ -830,6 +830,7 @@ global:
>         rtnl_u32_set_flags;
>         rtnl_u32_set_handle;
>         rtnl_u32_set_hashmask;
> +       rtnl_u32_set_selector;
>         rtnl_u32_set_hashtable;
>         rtnl_u32_set_link;
>
>
>
> _______________________________________________
> libnl mailing list
> libnl at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libnl



More information about the libnl mailing list