Skip to content

Commit

Permalink
lib/route: add initial support for br_vlan module
Browse files Browse the repository at this point in the history
Add br_vlan global_opts module to support setting global VLAN options on
bridge master interfaces.

There is currently no support for cache operations and the non-global
options counterpart is not implemented.
  • Loading branch information
ronand-atl committed Oct 30, 2024
1 parent b3a0896 commit e33b8bc
Show file tree
Hide file tree
Showing 5 changed files with 2,481 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ libnlinclude_netlink_route_act_HEADERS = \
include/netlink/route/act/skbedit.h \
include/netlink/route/act/vlan.h \
$(NULL)
libnlinclude_netlink_route_br_vlandir = $(libnlincludedir)/netlink/route/br_vlan
libnlinclude_netlink_route_br_vlan_HEADERS = \
include/netlink/route/br_vlan/global_opts.h \
$(NULL)
libnlinclude_netlink_route_clsdir = $(libnlincludedir)/netlink/route/cls
libnlinclude_netlink_route_cls_HEADERS = \
include/netlink/route/cls/basic.h \
Expand Down Expand Up @@ -239,6 +243,7 @@ public_headers = \
$(libnlinclude_netlink_netfilter_HEADERS) \
$(libnlinclude_netlink_route_HEADERS) \
$(libnlinclude_netlink_route_act_HEADERS) \
$(libnlinclude_netlink_route_br_vlan_HEADERS) \
$(libnlinclude_netlink_route_cls_HEADERS) \
$(libnlinclude_netlink_route_cls_ematch_HEADERS) \
$(libnlinclude_netlink_route_link_HEADERS) \
Expand Down Expand Up @@ -442,6 +447,7 @@ lib_libnl_route_3_la_SOURCES = \
lib/route/act/skbedit.c \
lib/route/act/vlan.c \
lib/route/addr.c \
lib/route/br_vlan/global_opts.c \
lib/route/class.c \
lib/route/classid.c \
lib/route/cls.c \
Expand Down
159 changes: 159 additions & 0 deletions include/netlink/route/br_vlan/global_opts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/* SPDX-License-Identifier: LGPL-2.1-only */

#ifndef NETLINK_BR_VLAN_GLOBAL_OPTS_H_
#define NETLINK_BR_VLAN_GLOBAL_OPTS_H_

#include <netlink/netlink.h>

#ifdef __cplusplus
extern "C" {
#endif

struct rtnl_br_vlan_gopts;
struct rtnl_br_vlan_gopts_entry;

struct rtnl_br_vlan_gopts *rtnl_br_vlan_gopts_alloc(void);
void rtnl_br_vlan_gopts_put(struct rtnl_br_vlan_gopts *gopts);

struct rtnl_br_vlan_gopts_entry *rtnl_br_vlan_gopts_entry_alloc(void);
void rtnl_br_vlan_gopts_entry_free(struct rtnl_br_vlan_gopts_entry *entry);
struct rtnl_br_vlan_gopts_entry *
rtnl_br_vlan_gopts_entry_clone(const struct rtnl_br_vlan_gopts_entry *entry);

int rtnl_br_vlan_gopts_build_modify_request(
const struct rtnl_br_vlan_gopts *gopts, struct nl_msg **result);

int rtnl_br_vlan_gopts_modify(struct nl_sock *sk,
const struct rtnl_br_vlan_gopts *gopts);

int rtnl_br_vlan_gopts_build_get_request(uint32_t ifindex,
struct nl_msg **result);

int rtnl_br_vlan_gopts_get_kernel(struct nl_sock *sk, uint32_t ifindex,
struct rtnl_br_vlan_gopts **result);

int rtnl_br_vlan_gopts_set_ifindex(struct rtnl_br_vlan_gopts *gopts,
uint32_t value);
int rtnl_br_vlan_gopts_get_ifindex(const struct rtnl_br_vlan_gopts *gopts,
uint32_t *out);

int rtnl_br_vlan_gopts_set_entry(struct rtnl_br_vlan_gopts *gopts,
const struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_set_entry_range(
struct rtnl_br_vlan_gopts *gopts,
const struct rtnl_br_vlan_gopts_entry *entry, uint16_t vid_end);

int rtnl_br_vlan_gopts_unset_entry(struct rtnl_br_vlan_gopts *gopts,
uint16_t vid);
int rtnl_br_vlan_gopts_unset_entry_range(struct rtnl_br_vlan_gopts *gopts,
uint16_t vid_start, uint16_t vid_end);

int rtnl_br_vlan_gopts_get_entry(const struct rtnl_br_vlan_gopts *gopts,
uint16_t vid,
struct rtnl_br_vlan_gopts_entry **out);

int rtnl_br_vlan_gopts_foreach_gopts_entry(
const struct rtnl_br_vlan_gopts *gopts,
void (*cb)(struct rtnl_br_vlan_gopts_entry *entry, void *arg),
void *arg);

int rtnl_br_vlan_gopts_entry_set_vid(struct rtnl_br_vlan_gopts_entry *entry,
uint16_t value);
int rtnl_br_vlan_gopts_entry_get_vid(
const struct rtnl_br_vlan_gopts_entry *entry, uint16_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_snooping(
struct rtnl_br_vlan_gopts_entry *entry, uint8_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_snooping(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_snooping(
const struct rtnl_br_vlan_gopts_entry *entry, uint8_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_igmp_version(
struct rtnl_br_vlan_gopts_entry *entry, uint8_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_igmp_version(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_igmp_version(
const struct rtnl_br_vlan_gopts_entry *entry, uint8_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_mld_version(
struct rtnl_br_vlan_gopts_entry *entry, uint8_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_mld_version(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_mld_version(
const struct rtnl_br_vlan_gopts_entry *entry, uint8_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_last_member_cnt(
struct rtnl_br_vlan_gopts_entry *entry, uint32_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_last_member_cnt(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_last_member_cnt(
const struct rtnl_br_vlan_gopts_entry *entry, uint32_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_startup_query_cnt(
struct rtnl_br_vlan_gopts_entry *entry, uint32_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_startup_query_cnt(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_startup_query_cnt(
const struct rtnl_br_vlan_gopts_entry *entry, uint32_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_last_member_intvl(
struct rtnl_br_vlan_gopts_entry *entry, uint64_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_last_member_intvl(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_last_member_intvl(
const struct rtnl_br_vlan_gopts_entry *entry, uint64_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_membership_intvl(
struct rtnl_br_vlan_gopts_entry *entry, uint64_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_membership_intvl(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_membership_intvl(
const struct rtnl_br_vlan_gopts_entry *entry, uint64_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_querier_intvl(
struct rtnl_br_vlan_gopts_entry *entry, uint64_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_querier_intvl(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_querier_intvl(
const struct rtnl_br_vlan_gopts_entry *entry, uint64_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_query_intvl(
struct rtnl_br_vlan_gopts_entry *entry, uint64_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_query_intvl(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_query_intvl(
const struct rtnl_br_vlan_gopts_entry *entry, uint64_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_query_response_intvl(
struct rtnl_br_vlan_gopts_entry *entry, uint64_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_query_response_intvl(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_query_response_intvl(
const struct rtnl_br_vlan_gopts_entry *entry, uint64_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_startup_query_intvl(
struct rtnl_br_vlan_gopts_entry *entry, uint64_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_startup_query_intvl(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_startup_query_intvl(
const struct rtnl_br_vlan_gopts_entry *entry, uint64_t *out);

int rtnl_br_vlan_gopts_entry_set_mcast_querier(
struct rtnl_br_vlan_gopts_entry *entry, uint8_t value);
int rtnl_br_vlan_gopts_entry_unset_mcast_querier(
struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_mcast_querier(
const struct rtnl_br_vlan_gopts_entry *entry, uint8_t *out);

int rtnl_br_vlan_gopts_entry_set_msti(struct rtnl_br_vlan_gopts_entry *entry,
uint16_t value);
int rtnl_br_vlan_gopts_entry_unset_msti(struct rtnl_br_vlan_gopts_entry *entry);
int rtnl_br_vlan_gopts_entry_get_msti(
const struct rtnl_br_vlan_gopts_entry *entry, uint16_t *out);

#ifdef __cplusplus
}
#endif

#endif /* NETLINK_BR_VLAN_GLOBAL_OPTS_H_ */
15 changes: 15 additions & 0 deletions include/nl-aux-route/nl-route.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ void rtnl_cls_put(struct rtnl_cls *);
_NL_AUTO_DEFINE_FCN_TYPED0(struct rtnl_cls *, _nl_auto_rtnl_cls_fcn,
rtnl_cls_put);

struct rtnl_br_vlan_gopts;
void rtnl_br_vlan_gopts_put(struct rtnl_br_vlan_gopts *);
#define _nl_auto_rtnl_br_vlan_gopts _nl_auto(_nl_auto_rtnl_br_vlan_gopts_fcn)
_NL_AUTO_DEFINE_FCN_TYPED0(struct rtnl_br_vlan_gopts *,
_nl_auto_rtnl_br_vlan_gopts_fcn,
rtnl_br_vlan_gopts_put);

struct rtnl_br_vlan_gopts_entry;
void rtnl_br_vlan_gopts_entry_free(struct rtnl_br_vlan_gopts_entry *);
#define _nl_auto_rtnl_br_vlan_gopts_entry \
_nl_auto(_nl_auto_rtnl_br_vlan_gopts_entry_fcn)
_NL_AUTO_DEFINE_FCN_TYPED0(struct rtnl_br_vlan_gopts_entry *,
_nl_auto_rtnl_br_vlan_gopts_entry_fcn,
rtnl_br_vlan_gopts_entry_free);

/*****************************************************************************/

static inline int _rtnl_act_append_get(struct rtnl_act **head,
Expand Down
Loading

0 comments on commit e33b8bc

Please sign in to comment.