@@ -697,6 +697,7 @@ enum {
IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */
IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */
IFLA_VF_BROADCAST, /* VF broadcast */
+ IFLA_VF_VLAN_MODE, /* vlan tagging mode */
__IFLA_VF_MAX,
};
@@ -711,6 +712,19 @@ struct ifla_vf_broadcast {
__u8 broadcast[32];
};
+enum {
+ IFLA_VF_VLAN_MODE_UNSPEC,
+ IFLA_VF_VLAN_MODE_VGT,
+ IFLA_VF_VLAN_MODE_VST,
+ IFLA_VF_VLAN_MODE_TRUNK,
+ __IFLA_VF_VLAN_MODE_MAX,
+};
+
+struct ifla_vf_vlan_mode {
+ __u32 vf;
+ __u32 mode; /* The VLAN tagging mode */
+};
+
struct ifla_vf_vlan {
__u32 vf;
__u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
@@ -351,13 +351,19 @@ static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
static void print_vf_stats64(FILE *fp, struct rtattr *vfstats);
+static const char *vlan_modes[] = {
+ [IFLA_VF_VLAN_MODE_UNSPEC] = "n/a",
+ [IFLA_VF_VLAN_MODE_VGT] = "vgt",
+ [IFLA_VF_VLAN_MODE_VST] = "vst",
+ [IFLA_VF_VLAN_MODE_TRUNK] = "trunk",
+};
+
static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
{
struct ifla_vf_mac *vf_mac;
struct ifla_vf_broadcast *vf_broadcast;
struct ifla_vf_tx_rate *vf_tx_rate;
struct rtattr *vf[IFLA_VF_MAX + 1] = {};
-
SPRINT_BUF(b1);
if (vfinfo->rta_type != IFLA_VF_INFO) {
@@ -404,6 +410,16 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
b1, sizeof(b1)));
}
+ if (vf[IFLA_VF_VLAN_MODE]) {
+ struct ifla_vf_vlan_mode *vlan_mode = RTA_DATA(vf[IFLA_VF_VLAN_MODE]);
+
+ if (vlan_mode->mode >= ARRAY_SIZE(vlan_modes))
+ print_int(PRINT_ANY, "vlan_mode", ", vlan_mode %d ", vlan_mode->mode);
+ else
+ print_string(PRINT_ANY, "vlan_mode", ", vlan_mode %s",
+ vlan_modes[vlan_mode->mode]);
+ }
+
if (vf[IFLA_VF_VLAN_LIST]) {
struct rtattr *i, *vfvlanlist = vf[IFLA_VF_VLAN_LIST];
int rem = RTA_PAYLOAD(vfvlanlist);
The change prints the VLAN tagging mode per VF on link query. The possible modes are: 1) VGT - Virtual Guest tagging mode. 2) VST - Virtual Switch tagging mode. 3) Trunk - Guest tagging mode with specific allowed VLAN access list. For the full VLAN ids list in Trunk mode, it is required to query the specific VF. Signed-off-by: Ariel Levkovich <lariel@mellanox.com> --- include/uapi/linux/if_link.h | 14 ++++++++++++++ ip/ipaddress.c | 18 +++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)