@@ -86,6 +86,7 @@ $(eval $(call add_command,translate,y))
$(eval $(call add_command,translocal,y))
$(eval $(call add_command,transtable_global_json,y))
$(eval $(call add_command,transtable_local_json,y))
+$(eval $(call add_command,vlan_dyn_max,y))
$(eval $(call add_command,vlan_json,y))
MANPAGE = man/batctl.8
@@ -481,6 +481,12 @@ enum batadv_nl_attrs {
*/
BATADV_ATTR_MULTICAST_FANOUT,
+ /**
+ * @BATADV_ATTR_VLAN_DYN_MAX: defines the maximum number of allowed
+ * learned VLANs from bridged-in clients.
+ */
+ BATADV_ATTR_VLAN_DYN_MAX,
+
/* add attributes above here, update the policy in netlink.c */
/**
@@ -231,6 +231,9 @@ struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
[BATADV_ATTR_MULTICAST_FANOUT] = {
.type = NLA_U32,
},
+ [BATADV_ATTR_VLAN_DYN_MAX] = {
+ .type = NLA_U16,
+ },
};
int netlink_create(struct state *state)
new file mode 100644
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) B.A.T.M.A.N. contributors:
+ *
+ * Linus Lüssing <linus.luessing@c0d3.blue>
+ *
+ * License-Filename: LICENSES/preferred/GPL-2.0
+ */
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "main.h"
+#include "sys.h"
+
+static struct vlan_dyn_max_data {
+ uint16_t vlan_dyn_max;
+} vlan_dyn_max;
+
+static int parse_vlan_dyn_max(struct state *state, int argc, char *argv[])
+{
+ struct settings_data *settings = state->cmd->arg;
+ struct vlan_dyn_max_data *data = settings->data;
+ char *endptr;
+
+ if (argc != 2) {
+ fprintf(stderr, "Error - incorrect number of arguments (expected 1)\n");
+ return -EINVAL;
+ }
+
+ data->vlan_dyn_max = strtoul(argv[1], &endptr, 0);
+ if (!endptr || *endptr != '\0') {
+ fprintf(stderr, "Error - the supplied argument is invalid: %s\n", argv[1]);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int print_vlan_dyn_max(struct nl_msg *msg, void *arg)
+{
+ struct nlattr *attrs[BATADV_ATTR_MAX + 1];
+ struct nlmsghdr *nlh = nlmsg_hdr(msg);
+ struct genlmsghdr *ghdr;
+ int *result = arg;
+
+ if (!genlmsg_valid_hdr(nlh, 0))
+ return NL_OK;
+
+ ghdr = nlmsg_data(nlh);
+
+ if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
+ genlmsg_len(ghdr), batadv_netlink_policy)) {
+ return NL_OK;
+ }
+
+ if (!attrs[BATADV_ATTR_VLAN_DYN_MAX])
+ return NL_OK;
+
+ printf("%u\n", nla_get_u16(attrs[BATADV_ATTR_VLAN_DYN_MAX]));
+
+ *result = 0;
+ return NL_STOP;
+}
+
+static int get_vlan_dyn_max(struct state *state)
+{
+ return sys_simple_nlquery(state, BATADV_CMD_GET_MESH,
+ NULL, print_vlan_dyn_max);
+}
+
+static int set_attrs_vlan_dyn_max(struct nl_msg *msg, void *arg)
+{
+ struct state *state = arg;
+ struct settings_data *settings = state->cmd->arg;
+ struct vlan_dyn_max_data *data = settings->data;
+
+ nla_put_u16(msg, BATADV_ATTR_VLAN_DYN_MAX, data->vlan_dyn_max);
+
+ return 0;
+}
+
+static int set_vlan_dyn_max(struct state *state)
+{
+ return sys_simple_nlquery(state, BATADV_CMD_SET_MESH,
+ set_attrs_vlan_dyn_max, NULL);
+}
+
+static struct settings_data batctl_settings_vlan_dyn_max = {
+ .data = &vlan_dyn_max,
+ .parse = parse_vlan_dyn_max,
+ .netlink_get = get_vlan_dyn_max,
+ .netlink_set = set_vlan_dyn_max,
+};
+
+COMMAND_NAMED(SUBCOMMAND_MIF, vlan_dyn_max, "vdm", handle_sys_setting,
+ COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
+ &batctl_settings_vlan_dyn_max,
+ "[0..4096] \tdisplay or modify vlan_dyn_max setting");