summaryrefslogtreecommitdiffstats
path: root/lib/route/cls/flower.c
Commit message (Collapse)AuthorAgeFilesLines
* route/cls: add get/take wrappers for rtnl_act_append()Thomas Haller2023-12-011-4/+3
| | | | | | | | | | | | rtnl_act_append() either takes ownership of the argument, or does nothing (on error). This pattern is hard to get right. In the past, there were various bugs at this place. Add two wrappers _rtnl_act_append_get() and _rtnl_act_append_take() which consistently don't take ownership of the pointer or take it. Also, in functions like rtnl_flower_append_action() only set the mask after successfully modifying the data.
* route/cls: fix leak in error handling of rtnl_flower_append_action()Thomas Haller2023-12-011-1/+5
| | | | | | Using rtnl_act_append() correctly is hard. Fixes: ef46de143206 ('route/cls: add flower classifier')
* include: drop "netlink-private/netlink.h" and move declarationsThomas Haller2023-08-021-2/+2
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-021-1/+4
|
* include: split and drop "netlink-private/types.h"Thomas Haller2023-08-021-0/+20
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* route: merge "include/netlink-private/tc.h" to lib/route/tc-api.hThomas Haller2023-08-011-1/+0
| | | | | It's a private header only for lib/route (libnl-route-3). We already have a similar header. Move the content to "lib/route/tc-api.h".
* route: move "include/netlink-private/route/tc-api.h" to lib/routeThomas Haller2023-08-011-1/+1
| | | | | | | | This header is entirely private to lib/route (libnl-route-3). Move the header there, it should not be used by anybody else. Note that libnl-route-3 exports symbols from this private header. That is ugly, make that clearer by adding comments.
* lib: use _nl_{init,exit} instead of __{init,exit}Thomas Haller2023-07-281-2/+2
| | | | | We should have things with "nl" prefix in our headers. Also, netlink-private/netlink.h is not header-only, preferably header-only stuff is in netlink-private/utils.h
* route: format recently added code with clang-formatThomas Haller2022-05-271-7/+13
|
* cls: flower: extend flower APIVolodymyr Bendiuga2022-05-271-0/+174
| | | | | | | | | | | | | The following API has been added: rtnl_flower_set_ipv4_src rtnl_flower_get_ipv4_src rtnl_flower_set_ipv4_dst rtnl_flower_get_ipv4_dst Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.com> https://github.com/thom311/libnl/pull/309
* flower: use correct attribute when filling out flagsVolodymyr Bendiuga2022-05-191-1/+1
| | | | | | | | Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.com> Fixes: ef46de143206 ('route/cls: add flower classifier') https://github.com/thom311/libnl/pull/316
* route/cls: add TCA_FLOWER_KEY_VLAN_ETH_TYPE to "flower_policy" policyThomas Haller2022-03-151-10/+11
|
* route/cls: return -NLE_INVAL in case rtnl_tc_data_peek() failsThomas Haller2022-03-151-6/+6
| | | | | | The problem here is not really NOMEM (because rtnl_tc_data_peek() wouldn't allocate new memory. The problem is, that the cls instance has no such data field. Return -NLE_INVAL instead.
* route/cls: no need to copy simple fields in flower_clone()Thomas Haller2022-03-151-12/+0
| | | | | | nl_object_clone() already does a shallow clone using memcpy(). So all simple fields are already initialized. We only need the oo_clone() implementation to get the deep-copy right.
* route/cls: make output pointers in rtnl_flower_get_{src,dst}_mac() optionalThomas Haller2022-03-151-5/+7
| | | | | | | | | | | | | | | We often require that a valid output pointer is passed to the getters. But here, let's be forgiving. Being more forgiving may be inconsistent, but on the safe side: the user is still welcome to assume they must provide a valid output pointer. Also, we always need to initialize the output mask, not only with `f->cf_mask & FLOWER_ATTR_DST_MAC_MASK`. The reason is that the caller cannot know whether the mask is present, so conditionally initializing the output is error prone (it requires the caller to NUL initialize first). Also, "f->cf_dst_mac_mask" really should be zero initialized, if the mask indicates that it's unset. This means, we can just always memcpy the mask.
* route/cls: adjust whitspace/indentationThomas Haller2022-03-151-142/+142
|
* route/cls: use SPDX-License-IdentifierThomas Haller2022-03-151-7/+1
|
* route/cls: add flower classifierVolodymyr Bendiuga2022-03-151-0/+731
This patch adds a subset of functions. Implemented api: rtnl_flower_set_proto; rtnl_flower_get_proto; rtnl_flower_set_vlan_id; rtnl_flower_get_vlan_id; rtnl_flower_set_vlan_prio; rtnl_flower_get_vlan_prio; rtnl_flower_set_vlan_ethtype; rtnl_flower_set_dst_mac; rtnl_flower_get_dst_mac; rtnl_flower_set_src_mac; rtnl_flower_get_src_mac; rtnl_flower_set_ip_dscp; rtnl_flower_get_ip_dscp; rtnl_flower_set_flags; rtnl_flower_append_action; rtnl_flower_del_action; rtnl_flower_get_action; [thaller@redhat.com: squashed commit "route:cls:flower: use parentheses in macro definitions"] [thaller@redhat.com: squashed commit "cls:flower: add TCA_FLOWER_FLAGS to flower_policy"] [thaller@redhat.com: squashed commit "cls:flower: vlan priority is uint8_t, not uint16_t"] [thaller@redhat.com: squashed commit "route:cls:flower: substitute nl_data* with uint8_t mac[ETH_ALEN]"] [thaller@redhat.com: drop non-existing TCA_FLOWER_POLICE. That was never merged to upstream kernel. While at it, use decimal numbers for the bitshift.] [thaller@redhat.com: fix build by including <linux/if_ether.h> in "types.h".] Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>