Commit d34f0550 authored by Matthias Schiffer's avatar Matthias Schiffer Committed by Simon Wunderlich

batman-adv: netlink: add translation table query

This adds the commands BATADV_CMD_GET_TRANSTABLE_LOCAL and
BATADV_CMD_GET_TRANSTABLE_GLOBAL, which correspond to the transtable_local
and transtable_global debugfs files.

The batadv_tt_client_flags enum is moved to the UAPI to expose it as part
of the netlink API.
Signed-off-by: default avatarMatthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
[sven.eckelmann@open-mesh.com: add policy for attributes, fix includes]
Signed-off-by: default avatarSven Eckelmann <sven.eckelmann@open-mesh.com>
[sw@simonwunderlich.de: fix VID attributes content]
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
parent b60620cf
......@@ -22,6 +22,42 @@
#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter"
/**
* enum batadv_tt_client_flags - TT client specific flags
* @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table
* @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and the new
* update telling its new real location has not been received/sent yet
* @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi interface.
* This information is used by the "AP Isolation" feature
* @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This
* information is used by the Extended Isolation feature
* @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from the table
* @BATADV_TT_CLIENT_NEW: this client has been added to the local table but has
* not been announced yet
* @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it is kept
* in the table for one more originator interval for consistency purposes
* @BATADV_TT_CLIENT_TEMP: this global client has been detected to be part of
* the network but no nnode has already announced it
*
* Bits from 0 to 7 are called _remote flags_ because they are sent on the wire.
* Bits from 8 to 15 are called _local flags_ because they are used for local
* computations only.
*
* Bits from 4 to 7 - a subset of remote flags - are ensured to be in sync with
* the other nodes in the network. To achieve this goal these flags are included
* in the TT CRC computation.
*/
enum batadv_tt_client_flags {
BATADV_TT_CLIENT_DEL = (1 << 0),
BATADV_TT_CLIENT_ROAM = (1 << 1),
BATADV_TT_CLIENT_WIFI = (1 << 4),
BATADV_TT_CLIENT_ISOLA = (1 << 5),
BATADV_TT_CLIENT_NOPURGE = (1 << 8),
BATADV_TT_CLIENT_NEW = (1 << 9),
BATADV_TT_CLIENT_PENDING = (1 << 10),
BATADV_TT_CLIENT_TEMP = (1 << 11),
};
/**
* enum batadv_nl_attrs - batman-adv netlink attributes
*
......@@ -41,6 +77,14 @@
* @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session
* @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment
* @BATADV_ATTR_ACTIVE: Flag indicating if the hard interface is active
* @BATADV_ATTR_TT_ADDRESS: Client MAC address
* @BATADV_ATTR_TT_TTVN: Translation table version
* @BATADV_ATTR_TT_LAST_TTVN: Previous translation table version
* @BATADV_ATTR_TT_CRC32: CRC32 over translation table
* @BATADV_ATTR_TT_VID: VLAN ID
* @BATADV_ATTR_TT_FLAGS: Translation table client flags
* @BATADV_ATTR_FLAG_BEST: Flags indicating entry is the best
* @BATADV_ATTR_LAST_SEEN_MSECS: Time in milliseconds since last seen
* @__BATADV_ATTR_AFTER_LAST: internal use
* @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
* @BATADV_ATTR_MAX: highest attribute number currently defined
......@@ -62,6 +106,14 @@ enum batadv_nl_attrs {
BATADV_ATTR_TPMETER_COOKIE,
BATADV_ATTR_PAD,
BATADV_ATTR_ACTIVE,
BATADV_ATTR_TT_ADDRESS,
BATADV_ATTR_TT_TTVN,
BATADV_ATTR_TT_LAST_TTVN,
BATADV_ATTR_TT_CRC32,
BATADV_ATTR_TT_VID,
BATADV_ATTR_TT_FLAGS,
BATADV_ATTR_FLAG_BEST,
BATADV_ATTR_LAST_SEEN_MSECS,
/* add attributes above here, update the policy in netlink.c */
__BATADV_ATTR_AFTER_LAST,
NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
......@@ -77,6 +129,8 @@ enum batadv_nl_attrs {
* @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session
* @BATADV_CMD_GET_ROUTING_ALGOS: Query the list of routing algorithms.
* @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces
* @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations
* @BATADV_CMD_GET_TRANSTABLE_GLOBAL Query list of global translations
* @__BATADV_CMD_AFTER_LAST: internal use
* @BATADV_CMD_MAX: highest used command number
*/
......@@ -87,6 +141,8 @@ enum batadv_nl_commands {
BATADV_CMD_TP_METER_CANCEL,
BATADV_CMD_GET_ROUTING_ALGOS,
BATADV_CMD_GET_HARDIFS,
BATADV_CMD_GET_TRANSTABLE_LOCAL,
BATADV_CMD_GET_TRANSTABLE_GLOBAL,
/* add new commands above here */
__BATADV_CMD_AFTER_LAST,
BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
......
......@@ -40,6 +40,7 @@
#include "hard-interface.h"
#include "soft-interface.h"
#include "tp_meter.h"
#include "translation-table.h"
struct genl_family batadv_netlink_family = {
.id = GENL_ID_GENERATE,
......@@ -73,6 +74,14 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
[BATADV_ATTR_TPMETER_BYTES] = { .type = NLA_U64 },
[BATADV_ATTR_TPMETER_COOKIE] = { .type = NLA_U32 },
[BATADV_ATTR_ACTIVE] = { .type = NLA_FLAG },
[BATADV_ATTR_TT_ADDRESS] = { .len = ETH_ALEN },
[BATADV_ATTR_TT_TTVN] = { .type = NLA_U8 },
[BATADV_ATTR_TT_LAST_TTVN] = { .type = NLA_U8 },
[BATADV_ATTR_TT_CRC32] = { .type = NLA_U32 },
[BATADV_ATTR_TT_VID] = { .type = NLA_U16 },
[BATADV_ATTR_TT_FLAGS] = { .type = NLA_U32 },
[BATADV_ATTR_FLAG_BEST] = { .type = NLA_FLAG },
[BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NLA_U32 },
};
/**
......@@ -82,7 +91,7 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
*
* Return: interface index, or 0.
*/
static int
int
batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype)
{
struct nlattr *attr = nlmsg_find_attr(nlh, GENL_HDRLEN, attrtype);
......@@ -530,6 +539,18 @@ static struct genl_ops batadv_netlink_ops[] = {
.policy = batadv_netlink_policy,
.dumpit = batadv_netlink_dump_hardifs,
},
{
.cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_tt_local_dump,
},
{
.cmd = BATADV_CMD_GET_TRANSTABLE_GLOBAL,
.flags = GENL_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_tt_global_dump,
},
};
/**
......
......@@ -23,8 +23,11 @@
#include <linux/types.h>
#include <net/genetlink.h>
struct nlmsghdr;
void batadv_netlink_register(void);
void batadv_netlink_unregister(void);
int batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype);
int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst,
u8 result, u32 test_time, u64 total_bytes,
......
......@@ -128,42 +128,6 @@ enum batadv_tt_data_flags {
BATADV_TT_FULL_TABLE = BIT(4),
};
/**
* enum batadv_tt_client_flags - TT client specific flags
* @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table
* @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and the new
* update telling its new real location has not been received/sent yet
* @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi interface.
* This information is used by the "AP Isolation" feature
* @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This
* information is used by the Extended Isolation feature
* @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from the table
* @BATADV_TT_CLIENT_NEW: this client has been added to the local table but has
* not been announced yet
* @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it is kept
* in the table for one more originator interval for consistency purposes
* @BATADV_TT_CLIENT_TEMP: this global client has been detected to be part of
* the network but no nnode has already announced it
*
* Bits from 0 to 7 are called _remote flags_ because they are sent on the wire.
* Bits from 8 to 15 are called _local flags_ because they are used for local
* computations only.
*
* Bits from 4 to 7 - a subset of remote flags - are ensured to be in sync with
* the other nodes in the network. To achieve this goal these flags are included
* in the TT CRC computation.
*/
enum batadv_tt_client_flags {
BATADV_TT_CLIENT_DEL = BIT(0),
BATADV_TT_CLIENT_ROAM = BIT(1),
BATADV_TT_CLIENT_WIFI = BIT(4),
BATADV_TT_CLIENT_ISOLA = BIT(5),
BATADV_TT_CLIENT_NOPURGE = BIT(8),
BATADV_TT_CLIENT_NEW = BIT(9),
BATADV_TT_CLIENT_PENDING = BIT(10),
BATADV_TT_CLIENT_TEMP = BIT(11),
};
/**
* enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
* @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
......
This diff is collapsed.
......@@ -22,8 +22,10 @@
#include <linux/types.h>
struct netlink_callback;
struct net_device;
struct seq_file;
struct sk_buff;
int batadv_tt_init(struct batadv_priv *bat_priv);
bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
......@@ -33,6 +35,8 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv,
const char *message, bool roaming);
int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb);
int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb);
void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
s32 match_vid, const char *message);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment