Skip to content

Commit

Permalink
lib/route: add initial support for br_vlan module (WIP)
Browse files Browse the repository at this point in the history
Add br_vlan module that initially supports setting global vlan options.
  • Loading branch information
ronand-atl committed Oct 1, 2024
1 parent 83f29cf commit f556d1e
Show file tree
Hide file tree
Showing 5 changed files with 1,171 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ libnlinclude_netlink_routedir = $(libnlincludedir)/netlink/route
libnlinclude_netlink_route_HEADERS = \
include/netlink/route/action.h \
include/netlink/route/addr.h \
include/netlink/route/br_vlan.h \
include/netlink/route/class.h \
include/netlink/route/classifier.h \
include/netlink/route/link.h \
Expand Down Expand Up @@ -442,6 +443,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.c \
lib/route/class.c \
lib/route/classid.c \
lib/route/cls.c \
Expand Down
116 changes: 116 additions & 0 deletions include/netlink/route/br_vlan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/* SPDX-License-Identifier: LGPL-2.1-only */

#ifndef NETLINK_BR_VLAN_H_
#define NETLINK_BR_VLAN_H_

#include <netlink/netlink.h>
#include <netlink/cache.h>
#include <netlink/route/link.h>

#ifdef __cplusplus
extern "C" {
#endif

struct rtnl_br_vlan;
struct rtnl_br_vlan_gopts_entry;
// struct rtnl_br_vlan_entry;

struct rtnl_br_vlan *rtnl_br_vlan_alloc(void);
void rtnl_br_vlan_put(struct rtnl_br_vlan *br_vlan);

struct rtnl_br_vlan_gopts_entry *rtnl_br_vlan_gopts_alloc(void);
void rtnl_br_vlan_gopts_put(struct rtnl_br_vlan_gopts_entry *opts);

void rtnl_br_vlan_gopts_append(struct rtnl_br_vlan *br_vlan,
struct rtnl_br_vlan_gopts_entry *opts);

// int rtnl_br_vlan_global_opts_build_change_request(
// struct rtnl_br_vlan_gopts_entry *old,
// struct rtnl_br_vlan_gopts_entry *tmpl, struct nl_msg **result);
// int rtnl_br_vlan_global_opts_change(struct nl_sock *sk,
// struct rtnl_br_vlan_gopts_entry *old,
// struct rtnl_br_vlan_gopts_entry *tmpl);
int rtnl_br_vlan_gopts_list_build_set_request(struct rtnl_br_vlan *opts_list,
struct nl_msg **result);
int rtnl_br_vlan_gopts_list_set(struct nl_sock *sk,
struct rtnl_br_vlan *opts_list);

//////

int rtnl_br_vlan_set_ifindex(struct rtnl_br_vlan *br_vlan, uint32_t value);
int rtnl_br_vlan_get_ifindex(struct rtnl_br_vlan *br_vlan, uint32_t *out);

void rtnl_br_vlan_add_gopts_entry(struct rtnl_br_vlan *br_vlan,
struct rtnl_br_vlan_gopts_entry *entry);
void rtnl_br_vlan_foreach_gopts_entry(
struct rtnl_br_vlan *br_vlan,
void (*cb)(struct rtnl_br_vlan_gopts_entry *, void *), void *arg);

int rtnl_br_vlan_gopts_entry_set_id(struct rtnl_br_vlan_gopts_entry *opts,
uint16_t value);
int rtnl_br_vlan_gopts_entry_get_id(struct rtnl_br_vlan_gopts_entry *opts,
uint16_t *out);
int rtnl_br_vlan_gopts_entry_set_range(struct rtnl_br_vlan_gopts_entry *opts,
uint16_t value);
int rtnl_br_vlan_gopts_entry_get_range(struct rtnl_br_vlan_gopts_entry *opts,
uint16_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_snooping(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_snooping(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_igmp_version(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_igmp_version(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_mld_version(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_mld_version(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_last_member_cnt(
struct rtnl_br_vlan_gopts_entry *opts, uint32_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_last_member_cnt(
struct rtnl_br_vlan_gopts_entry *opts, uint32_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_startup_query_cnt(
struct rtnl_br_vlan_gopts_entry *opts, uint32_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_startup_query_cnt(
struct rtnl_br_vlan_gopts_entry *opts, uint32_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_last_member_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_last_member_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_membership_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_membership_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_querier_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_querier_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_query_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_query_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_query_response_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_query_response_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_startup_query_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_startup_query_intvl(
struct rtnl_br_vlan_gopts_entry *opts, uint64_t *out);
int rtnl_br_vlan_gopts_entry_set_mcast_querier(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t value);
int rtnl_br_vlan_gopts_entry_get_mcast_querier(
struct rtnl_br_vlan_gopts_entry *opts, uint8_t *out);
int rtnl_br_vlan_gopts_entry_set_msti(struct rtnl_br_vlan_gopts_entry *opts,
uint16_t value);
int rtnl_br_vlan_gopts_entry_get_msti(struct rtnl_br_vlan_gopts_entry *opts,
uint16_t *out);

// TODO: add getters

#ifdef __cplusplus
}
#endif

#endif /* NETLINK_BR_VLAN_H_ */
6 changes: 6 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,12 @@ 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;
void rtnl_br_vlan_put(struct rtnl_br_vlan *);
#define _nl_auto_rtnl_br_vlan _nl_auto(_nl_auto_rtnl_br_vlan_fcn)
_NL_AUTO_DEFINE_FCN_TYPED0(struct rtnl_br_vlan *, _nl_auto_rtnl_br_vlan_fcn,
rtnl_br_vlan_put);

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

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

0 comments on commit f556d1e

Please sign in to comment.