mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
net: Revert the ioctl SR-IOV VF status interface
A native route Netlink interface will replace this stack. Requested by: glebius This reverts commit1ccf543b21. This reverts commit2c04cfa148. This reverts commit2d6114f6d2. This reverts commitd15f2551b2. This reverts commitceb282bbd6. This reverts commitc30021fe0d. This reverts commitfb1820d23a. This reverts commit8696cc600f.
This commit is contained in:
1 parent
d1eeae7506
commit
a6999a1c94
38 files changed
+32
-1765
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
LIB= ifconfig
|
LIB= ifconfig
|
||||||
INTERNALLIB= true
|
INTERNALLIB= true
|
||||||
|
|
||||||
LIBADD= m nv
|
LIBADD= m
|
||||||
|
|
||||||
SHLIBDIR?= /lib
|
SHLIBDIR?= /lib
|
||||||
SHLIB_MAJOR= 2
|
SHLIB_MAJOR= 2
|
||||||
|
|||||||
@@ -84,7 +84,3 @@ FBSD_1.6 {
|
|||||||
ifconfig_sfp_rev_description;
|
ifconfig_sfp_rev_description;
|
||||||
ifconfig_sfp_rev_symbol;
|
ifconfig_sfp_rev_symbol;
|
||||||
};
|
};
|
||||||
|
|
||||||
FBSD_1.9 {
|
|
||||||
ifconfig_get_vf_status;
|
|
||||||
};
|
|
||||||
@@ -529,135 +529,6 @@ ifconfig_get_ifstatus(ifconfig_handle_t *h, const char *name,
|
|||||||
return (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFSTATUS, ifs));
|
return (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFSTATUS, ifs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ifconfig_vf_status_validate(const nvlist_t *status)
|
|
||||||
{
|
|
||||||
const nvlist_t * const *vfs;
|
|
||||||
const nvlist_t *extensions, *vf;
|
|
||||||
const char *name;
|
|
||||||
void *cookie;
|
|
||||||
size_t i, num_vfs;
|
|
||||||
int type;
|
|
||||||
|
|
||||||
if (!nvlist_exists_number(status, IFVF_STATUS_VERSION_KEY))
|
|
||||||
return (EBADMSG);
|
|
||||||
if (nvlist_get_number(status, IFVF_STATUS_VERSION_KEY) !=
|
|
||||||
IFVF_STATUS_VERSION)
|
|
||||||
return (EPROTONOSUPPORT);
|
|
||||||
if (!nvlist_exists_nvlist_array(status, IFVF_STATUS_VFS))
|
|
||||||
return (EBADMSG);
|
|
||||||
|
|
||||||
vfs = nvlist_get_nvlist_array(status, IFVF_STATUS_VFS, &num_vfs);
|
|
||||||
for (i = 0; i < num_vfs; i++) {
|
|
||||||
vf = vfs[i];
|
|
||||||
if (!nvlist_exists_number(vf, IFVF_STATUS_INDEX))
|
|
||||||
return (EBADMSG);
|
|
||||||
if (!nvlist_exists(vf, IFVF_STATUS_EXTENSIONS))
|
|
||||||
continue;
|
|
||||||
if (!nvlist_exists_nvlist(vf, IFVF_STATUS_EXTENSIONS))
|
|
||||||
return (EBADMSG);
|
|
||||||
extensions = nvlist_get_nvlist(vf, IFVF_STATUS_EXTENSIONS);
|
|
||||||
cookie = NULL;
|
|
||||||
while ((name = nvlist_next(extensions, &type, &cookie)) != NULL) {
|
|
||||||
if (type != NV_TYPE_NVLIST)
|
|
||||||
return (EBADMSG);
|
|
||||||
if (!nvlist_exists_number(nvlist_get_nvlist(extensions,
|
|
||||||
name), IFVF_STATUS_EXT_VERSION))
|
|
||||||
return (EBADMSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ifconfig_get_vf_status(ifconfig_handle_t *h, const char *name,
|
|
||||||
nvlist_t **statusp)
|
|
||||||
{
|
|
||||||
struct ifreq ifr;
|
|
||||||
nvlist_t *status;
|
|
||||||
void *buf, *newbuf;
|
|
||||||
size_t namelen;
|
|
||||||
u_int buflen, nextlen;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
if (h == NULL || name == NULL || statusp == NULL) {
|
|
||||||
if (h != NULL)
|
|
||||||
ifconfig_error(h, OTHER, EINVAL);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*statusp = NULL;
|
|
||||||
namelen = strnlen(name, IFNAMSIZ);
|
|
||||||
if (namelen == IFNAMSIZ) {
|
|
||||||
ifconfig_error(h, OTHER, ENAMETOOLONG);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ioctl(2) does not copy an _IOWR argument back to userspace when the
|
|
||||||
* command returns EFBIG, so the kernel's required length is not
|
|
||||||
* observable on a short-buffer error. Start with enough space for the
|
|
||||||
* common case and grow geometrically instead of relying on length.
|
|
||||||
*/
|
|
||||||
buflen = 16 * 1024;
|
|
||||||
buf = malloc(buflen);
|
|
||||||
if (buf == NULL) {
|
|
||||||
ifconfig_error(h, OTHER, ENOMEM);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
for (;;) {
|
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
|
||||||
memcpy(ifr.ifr_name, name, namelen + 1);
|
|
||||||
ifr.ifr_vf_status_nv.buffer = buf;
|
|
||||||
ifr.ifr_vf_status_nv.buf_length = buflen;
|
|
||||||
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFVFSTATUS, &ifr) == 0)
|
|
||||||
break;
|
|
||||||
if (ifconfig_err_errno(h) != EFBIG ||
|
|
||||||
buflen == IFR_VF_STATUS_NV_MAXBUFSIZE ||
|
|
||||||
ifr.ifr_vf_status_nv.length >
|
|
||||||
IFR_VF_STATUS_NV_MAXBUFSIZE) {
|
|
||||||
free(buf);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (ifr.ifr_vf_status_nv.length > buflen)
|
|
||||||
nextlen = ifr.ifr_vf_status_nv.length;
|
|
||||||
else if (buflen > IFR_VF_STATUS_NV_MAXBUFSIZE / 2)
|
|
||||||
nextlen = IFR_VF_STATUS_NV_MAXBUFSIZE;
|
|
||||||
else
|
|
||||||
nextlen = buflen * 2;
|
|
||||||
newbuf = realloc(buf, nextlen);
|
|
||||||
if (newbuf == NULL) {
|
|
||||||
free(buf);
|
|
||||||
ifconfig_error(h, OTHER, ENOMEM);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
buf = newbuf;
|
|
||||||
buflen = nextlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ifr.ifr_vf_status_nv.length == 0 ||
|
|
||||||
ifr.ifr_vf_status_nv.length > buflen) {
|
|
||||||
free(buf);
|
|
||||||
ifconfig_error(h, OTHER, EBADMSG);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
status = nvlist_unpack(buf, ifr.ifr_vf_status_nv.length, 0);
|
|
||||||
free(buf);
|
|
||||||
if (status == NULL) {
|
|
||||||
ifconfig_error(h, OTHER, EBADMSG);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
error = ifconfig_vf_status_validate(status);
|
|
||||||
if (error != 0) {
|
|
||||||
nvlist_destroy(status);
|
|
||||||
ifconfig_error(h, OTHER, error);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ifconfig_error_clear(h);
|
|
||||||
*statusp = status;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name)
|
ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sys/nv.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@@ -199,16 +198,6 @@ int ifconfig_get_groups(ifconfig_handle_t *h, const char *name,
|
|||||||
int ifconfig_get_ifstatus(ifconfig_handle_t *h, const char *name,
|
int ifconfig_get_ifstatus(ifconfig_handle_t *h, const char *name,
|
||||||
struct ifstat *stat);
|
struct ifstat *stat);
|
||||||
|
|
||||||
/** Retrieve structured SR-IOV VF status for an interface.
|
|
||||||
* @param h An open ifconfig state object
|
|
||||||
* @param name The PF interface name
|
|
||||||
* @param statusp Return argument. The caller owns the returned nvlist and
|
|
||||||
* must destroy it with nvlist_destroy().
|
|
||||||
* @return 0 on success, -1 on failure
|
|
||||||
*/
|
|
||||||
int ifconfig_get_vf_status(ifconfig_handle_t *h, const char *name,
|
|
||||||
nvlist_t **statusp);
|
|
||||||
|
|
||||||
/** Retrieve the interface media information
|
/** Retrieve the interface media information
|
||||||
* @param h An open ifconfig state object
|
* @param h An open ifconfig state object
|
||||||
* @param name The interface name
|
* @param name The interface name
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ CRUNCH_PROGS_sbin+= ipfw
|
|||||||
|
|
||||||
.if ${MK_PF} != "no"
|
.if ${MK_PF} != "no"
|
||||||
CRUNCH_PROGS_sbin+= pfctl
|
CRUNCH_PROGS_sbin+= pfctl
|
||||||
CRUNCH_LIBS_pfctl+= ${LIBPFCTL}
|
CRUNCH_LIBS_pfctl+= ${LIBPFCTL} ${LIBNV}
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.if ${MK_ROUTED} != "no"
|
.if ${MK_ROUTED} != "no"
|
||||||
@@ -143,7 +143,7 @@ CRUNCH_PROGS_usr.sbin+= zdb
|
|||||||
# CRUNCH_PROGS+= devd
|
# CRUNCH_PROGS+= devd
|
||||||
|
|
||||||
CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
|
CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
|
||||||
CRUNCH_LIBS_camcontrol+= ${LIBNVMF}
|
CRUNCH_LIBS_camcontrol+= ${LIBNVMF} ${LIBNV}
|
||||||
.if ${MK_ZFS} != "no"
|
.if ${MK_ZFS} != "no"
|
||||||
CRUNCH_LIBS+= -lavl -lpthread -lumem -lspl -lrt
|
CRUNCH_LIBS+= -lavl -lpthread -lumem -lspl -lrt
|
||||||
CRUNCH_LIBS_zfs+= ${LIBBE} \
|
CRUNCH_LIBS_zfs+= ${LIBBE} \
|
||||||
@@ -261,9 +261,10 @@ CRUNCH_ALIAS_chown= chgrp
|
|||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
CRUNCH_LIBS+= ${OBJTOP}/lib/libifconfig/libifconfig.a
|
CRUNCH_LIBS+= ${OBJTOP}/lib/libifconfig/libifconfig.a
|
||||||
CRUNCH_LIBS+= -lnv
|
|
||||||
CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
|
CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
|
||||||
|
|
||||||
|
CRUNCH_LIBS_ifconfig+= ${LIBNV}
|
||||||
|
|
||||||
CRUNCH_LIBS+= -lm
|
CRUNCH_LIBS+= -lm
|
||||||
|
|
||||||
.if ${MK_ISCSI} != "no"
|
.if ${MK_ISCSI} != "no"
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ SRCS+= ifgif.c # GIF reversed header workaround
|
|||||||
SRCS+= ifipsec.c # IPsec VTI
|
SRCS+= ifipsec.c # IPsec VTI
|
||||||
|
|
||||||
SRCS+= sfp.c # SFP/SFP+ information
|
SRCS+= sfp.c # SFP/SFP+ information
|
||||||
SRCS+= ifvfstatus.c # VF status information
|
|
||||||
LIBADD+= ifconfig m util
|
LIBADD+= ifconfig m util
|
||||||
CFLAGS+= -I${SRCTOP}/lib/libifconfig -I${OBJTOP}/lib/libifconfig
|
CFLAGS+= -I${SRCTOP}/lib/libifconfig -I${OBJTOP}/lib/libifconfig
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 8, 2026
|
.Dd August 10, 2026
|
||||||
.Dt IFCONFIG 8
|
.Dt IFCONFIG 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -325,60 +325,6 @@ will attempt to load it.
|
|||||||
Display only the interfaces that are up.
|
Display only the interfaces that are up.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Get more verbose status for an interface.
|
Get more verbose status for an interface.
|
||||||
When supported, this includes the status of configured SR-IOV virtual
|
|
||||||
functions.
|
|
||||||
Fields that the PF driver cannot observe are omitted; an omitted field does
|
|
||||||
not mean false or zero.
|
|
||||||
The status begins with the PF link state and speed normally advertised to
|
|
||||||
VFs, followed by the number of VFs and one record for each VF.
|
|
||||||
PF link status does not demonstrate that a VF driver is operational.
|
|
||||||
.Pp
|
|
||||||
Per-VF fields are arranged in the following groups:
|
|
||||||
.Bl -tag -width "resources"
|
|
||||||
.It Cm identity
|
|
||||||
The primary MAC address known to the PF.
|
|
||||||
.It Cm state
|
|
||||||
.Cm configured=yes
|
|
||||||
means that the PF accepted the VF configuration.
|
|
||||||
.Cm initialized=yes
|
|
||||||
means that the VF completed its driver or mailbox handshake since its last
|
|
||||||
reset.
|
|
||||||
When available, this group also reports whether traffic is enabled, whether
|
|
||||||
malicious-driver detection blocked the VF, and whether it is quarantined.
|
|
||||||
.It Cm resources
|
|
||||||
The number of symmetric RX/TX queue pairs allocated to the VF.
|
|
||||||
This is not necessarily the number of queue pairs currently used by its
|
|
||||||
driver.
|
|
||||||
.It Cm vlan
|
|
||||||
An access VLAN is imposed by the PF; trunk mode means that no access VLAN is
|
|
||||||
imposed and does not promise unlimited filter capacity.
|
|
||||||
The filter count includes explicit filters recorded by the PF and excludes
|
|
||||||
implicit untagged and priority-tag membership.
|
|
||||||
.It Cm policy
|
|
||||||
Administrative permissions for VF requests, MAC anti-spoofing state, and an
|
|
||||||
optional per-VF link-state policy.
|
|
||||||
Permissions describe what the VF may request, not its current requests.
|
|
||||||
.It Cm protocol
|
|
||||||
The negotiated PF/VF mailbox API version, when known.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
For example:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
VF-visible PF link: state=up speed=10000Mbps
|
|
||||||
virtual functions: 1
|
|
||||||
vf 0:
|
|
||||||
identity: mac=02:00:00:00:00:01
|
|
||||||
state: configured=yes initialized=yes traffic=enabled
|
|
||||||
resources: queue-pairs=4
|
|
||||||
vlan: mode=trunk filters=0
|
|
||||||
policy: set-mac=denied set-vlan=allowed anti-spoof=on
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
See
|
|
||||||
.Xr iovctl.conf 5
|
|
||||||
for VF configuration and
|
|
||||||
.Xr iovctl 8
|
|
||||||
for PCI attachment and passthrough status.
|
|
||||||
.It Ar address
|
.It Ar address
|
||||||
For the inet family,
|
For the inet family,
|
||||||
the address is either a host name present in the host name data
|
the address is either a host name present in the host name data
|
||||||
|
|||||||
@@ -1891,8 +1891,6 @@ status(if_ctx *ctx, const struct sockaddr_dl *sdl __unused, struct ifaddrs *ifa)
|
|||||||
args->afp->af_other_status(ctx);
|
args->afp->af_other_status(ctx);
|
||||||
|
|
||||||
print_ifstatus(ctx);
|
print_ifstatus(ctx);
|
||||||
if (args->verbose > 0)
|
|
||||||
vf_status(ctx);
|
|
||||||
if (args->verbose > 0)
|
if (args->verbose > 0)
|
||||||
sfp_status(ctx);
|
sfp_status(ctx);
|
||||||
|
|
||||||
|
|||||||
@@ -281,7 +281,6 @@ void clone_setdefcallback_prefix(const char *, clone_callback_func *);
|
|||||||
void clone_setdefcallback_filter(clone_match_func *, clone_callback_func *);
|
void clone_setdefcallback_filter(clone_match_func *, clone_callback_func *);
|
||||||
|
|
||||||
void sfp_status(if_ctx *ctx);
|
void sfp_status(if_ctx *ctx);
|
||||||
void vf_status(if_ctx *ctx);
|
|
||||||
|
|
||||||
struct sockaddr_dl;
|
struct sockaddr_dl;
|
||||||
bool match_ether(const struct sockaddr_dl *sdl);
|
bool match_ether(const struct sockaddr_dl *sdl);
|
||||||
|
|||||||
@@ -414,8 +414,6 @@ status_nl(if_ctx *ctx, struct iface *iface)
|
|||||||
args->afp->af_other_status(ctx);
|
args->afp->af_other_status(ctx);
|
||||||
|
|
||||||
print_ifstatus(ctx);
|
print_ifstatus(ctx);
|
||||||
if (args->verbose > 0)
|
|
||||||
vf_status(ctx);
|
|
||||||
if (args->drivername || args->verbose) {
|
if (args->drivername || args->verbose) {
|
||||||
if (ifconfig_get_orig_name(lifh, link->ifla_ifname,
|
if (ifconfig_get_orig_name(lifh, link->ifla_ifname,
|
||||||
&drivername) != 0) {
|
&drivername) != 0) {
|
||||||
|
|||||||
@@ -1,212 +0,0 @@
|
|||||||
/*-
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 Intel Corporation
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/nv.h>
|
|
||||||
|
|
||||||
#include <net/ethernet.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ifconfig.h"
|
|
||||||
|
|
||||||
static void
|
|
||||||
vf_group_begin(bool *printed, const char *name)
|
|
||||||
{
|
|
||||||
if (!*printed) {
|
|
||||||
printf("\t\t\t%s:", name);
|
|
||||||
*printed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
vf_group_end(bool printed)
|
|
||||||
{
|
|
||||||
if (printed)
|
|
||||||
putchar('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
vf_status(if_ctx *ctx)
|
|
||||||
{
|
|
||||||
const nvlist_t * const *vfs;
|
|
||||||
const nvlist_t *vf;
|
|
||||||
const void *mac;
|
|
||||||
nvlist_t *status;
|
|
||||||
const char *mode, *state;
|
|
||||||
size_t maclen, num_vfs;
|
|
||||||
uint64_t speed;
|
|
||||||
bool printed;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
if (ifconfig_get_vf_status(lifh, ctx->ifname, &status) != 0) {
|
|
||||||
error = ifconfig_err_errno(lifh);
|
|
||||||
if (error == EINVAL || error == ENOTTY || error == ENXIO ||
|
|
||||||
error == ENOTSUP || error == EOPNOTSUPP)
|
|
||||||
return;
|
|
||||||
errno = error;
|
|
||||||
warn("SIOCGIFVFSTATUS");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nvlist_exists_string(status, IFVF_STATUS_PF_LINK_STATE)) {
|
|
||||||
state = nvlist_get_string(status, IFVF_STATUS_PF_LINK_STATE);
|
|
||||||
printf("\tVF-visible PF link: state=%s", state);
|
|
||||||
if (nvlist_exists_number(status, IFVF_STATUS_PF_LINK_SPEED)) {
|
|
||||||
speed = nvlist_get_number(status,
|
|
||||||
IFVF_STATUS_PF_LINK_SPEED);
|
|
||||||
if (speed % IF_Mbps(1) == 0)
|
|
||||||
printf(" speed=%juMbps", (uintmax_t)(speed /
|
|
||||||
IF_Mbps(1)));
|
|
||||||
else
|
|
||||||
printf(" speed=%jubps", (uintmax_t)speed);
|
|
||||||
}
|
|
||||||
putchar('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
vfs = nvlist_get_nvlist_array(status, IFVF_STATUS_VFS, &num_vfs);
|
|
||||||
printf("\tvirtual functions: %zu\n", num_vfs);
|
|
||||||
for (size_t i = 0; i < num_vfs; i++) {
|
|
||||||
vf = vfs[i];
|
|
||||||
printf("\t\tvf %3ju:\n",
|
|
||||||
(uintmax_t)(nvlist_exists_number(vf, IFVF_STATUS_INDEX) ?
|
|
||||||
nvlist_get_number(vf, IFVF_STATUS_INDEX) : i));
|
|
||||||
|
|
||||||
printed = false;
|
|
||||||
if (nvlist_exists_binary(vf, IFVF_STATUS_MAC)) {
|
|
||||||
mac = nvlist_get_binary(vf, IFVF_STATUS_MAC, &maclen);
|
|
||||||
if (maclen == ETHER_ADDR_LEN) {
|
|
||||||
vf_group_begin(&printed, "identity");
|
|
||||||
printf(" mac=%s", ether_ntoa(mac));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vf_group_end(printed);
|
|
||||||
|
|
||||||
printed = false;
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_CONFIGURED)) {
|
|
||||||
vf_group_begin(&printed, "state");
|
|
||||||
printf(" configured=%s",
|
|
||||||
nvlist_get_bool(vf, IFVF_STATUS_CONFIGURED) ?
|
|
||||||
"yes" : "no");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_INITIALIZED)) {
|
|
||||||
vf_group_begin(&printed, "state");
|
|
||||||
printf(" initialized=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_INITIALIZED) ? "yes" : "no");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_TRAFFIC_ENABLED)) {
|
|
||||||
vf_group_begin(&printed, "state");
|
|
||||||
printf(" traffic=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_TRAFFIC_ENABLED) ? "enabled" : "disabled");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_MDD_BLOCKED)) {
|
|
||||||
vf_group_begin(&printed, "state");
|
|
||||||
printf(" mdd-blocked=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_MDD_BLOCKED) ? "yes" : "no");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_QUARANTINED)) {
|
|
||||||
vf_group_begin(&printed, "state");
|
|
||||||
printf(" quarantined=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_QUARANTINED) ? "yes" : "no");
|
|
||||||
}
|
|
||||||
vf_group_end(printed);
|
|
||||||
|
|
||||||
printed = false;
|
|
||||||
if (nvlist_exists_number(vf, IFVF_STATUS_NUM_QUEUES)) {
|
|
||||||
vf_group_begin(&printed, "resources");
|
|
||||||
printf(" queue-pairs=%ju",
|
|
||||||
(uintmax_t)nvlist_get_number(vf,
|
|
||||||
IFVF_STATUS_NUM_QUEUES));
|
|
||||||
}
|
|
||||||
vf_group_end(printed);
|
|
||||||
|
|
||||||
printed = false;
|
|
||||||
if (nvlist_exists_string(vf, IFVF_STATUS_VLAN_MODE)) {
|
|
||||||
mode = nvlist_get_string(vf, IFVF_STATUS_VLAN_MODE);
|
|
||||||
vf_group_begin(&printed, "vlan");
|
|
||||||
printf(" mode=%s", mode);
|
|
||||||
if (strcmp(mode, IFVF_VLAN_MODE_ACCESS) == 0 &&
|
|
||||||
nvlist_exists_number(vf, IFVF_STATUS_VLAN))
|
|
||||||
printf(" vid=%ju", (uintmax_t)nvlist_get_number(vf,
|
|
||||||
IFVF_STATUS_VLAN));
|
|
||||||
}
|
|
||||||
if (nvlist_exists_number(vf, IFVF_STATUS_VLAN_COUNT)) {
|
|
||||||
vf_group_begin(&printed, "vlan");
|
|
||||||
printf(" filters=%ju", (uintmax_t)nvlist_get_number(vf,
|
|
||||||
IFVF_STATUS_VLAN_COUNT));
|
|
||||||
}
|
|
||||||
if (nvlist_exists_number(vf, IFVF_STATUS_VLAN_LIMIT)) {
|
|
||||||
vf_group_begin(&printed, "vlan");
|
|
||||||
printf(" limit=%ju", (uintmax_t)nvlist_get_number(vf,
|
|
||||||
IFVF_STATUS_VLAN_LIMIT));
|
|
||||||
}
|
|
||||||
vf_group_end(printed);
|
|
||||||
|
|
||||||
printed = false;
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_ALLOW_SET_MAC)) {
|
|
||||||
vf_group_begin(&printed, "policy");
|
|
||||||
printf(" set-mac=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_ALLOW_SET_MAC) ? "allowed" : "denied");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_ALLOW_SET_VLAN)) {
|
|
||||||
vf_group_begin(&printed, "policy");
|
|
||||||
printf(" set-vlan=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_ALLOW_SET_VLAN) ? "allowed" : "denied");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_MAC_ANTI_SPOOF)) {
|
|
||||||
vf_group_begin(&printed, "policy");
|
|
||||||
printf(" anti-spoof=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_MAC_ANTI_SPOOF) ? "on" : "off");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_bool(vf, IFVF_STATUS_ALLOW_PROMISC)) {
|
|
||||||
vf_group_begin(&printed, "policy");
|
|
||||||
printf(" promisc=%s", nvlist_get_bool(vf,
|
|
||||||
IFVF_STATUS_ALLOW_PROMISC) ? "allowed" : "denied");
|
|
||||||
}
|
|
||||||
if (nvlist_exists_string(vf, IFVF_STATUS_LINK_STATE_POLICY)) {
|
|
||||||
vf_group_begin(&printed, "policy");
|
|
||||||
printf(" link-state=%s", nvlist_get_string(vf,
|
|
||||||
IFVF_STATUS_LINK_STATE_POLICY));
|
|
||||||
}
|
|
||||||
vf_group_end(printed);
|
|
||||||
|
|
||||||
printed = false;
|
|
||||||
if (nvlist_exists_string(vf, IFVF_STATUS_API_VERSION)) {
|
|
||||||
vf_group_begin(&printed, "protocol");
|
|
||||||
printf(" api=%s", nvlist_get_string(vf,
|
|
||||||
IFVF_STATUS_API_VERSION));
|
|
||||||
}
|
|
||||||
vf_group_end(printed);
|
|
||||||
|
|
||||||
}
|
|
||||||
nvlist_destroy(status);
|
|
||||||
}
|
|
||||||
+1
-117
@@ -22,7 +22,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 8, 2026
|
.Dd July 28, 2026
|
||||||
.Dt RTNETLINK 4
|
.Dt RTNETLINK 4
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -325,17 +325,7 @@ The following filters are recognised by the kernel:
|
|||||||
ifi_index interface index
|
ifi_index interface index
|
||||||
IFLA_IFNAME interface name
|
IFLA_IFNAME interface name
|
||||||
IFLA_ALT_IFNAME interface name
|
IFLA_ALT_IFNAME interface name
|
||||||
IFLA_EXT_MASK extended information selection bitmap
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
|
||||||
Setting the
|
|
||||||
.Dv RTEXT_FILTER_VF
|
|
||||||
bit in
|
|
||||||
.Dv IFLA_EXT_MASK
|
|
||||||
requests SR-IOV VF status.
|
|
||||||
The query is opt-in because obtaining status can require entering the PF
|
|
||||||
driver.
|
|
||||||
VF status is not included in unsolicited link notifications.
|
|
||||||
.Ss TLVs
|
.Ss TLVs
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
.It Dv IFLA_ADDRESS
|
.It Dv IFLA_ADDRESS
|
||||||
@@ -350,112 +340,6 @@ VF status is not included in unsolicited link notifications.
|
|||||||
(uint32_t) (readonly) Interface index.
|
(uint32_t) (readonly) Interface index.
|
||||||
.It Dv IFLA_MASTER
|
.It Dv IFLA_MASTER
|
||||||
(uint32_t) Parent interface index.
|
(uint32_t) Parent interface index.
|
||||||
.It Dv IFLA_NUM_VF
|
|
||||||
(uint32_t) (readonly) Number of active VFs.
|
|
||||||
This attribute is returned with a successful
|
|
||||||
.Dv RTEXT_FILTER_VF
|
|
||||||
query.
|
|
||||||
.It Dv IFLA_FREEBSD
|
|
||||||
(nested) Local interface attributes.
|
|
||||||
When requested,
|
|
||||||
.Dv IFLAF_VF_STATUS
|
|
||||||
contains the following nested attributes:
|
|
||||||
.Bd -literal -offset indent -compact
|
|
||||||
IFLAF_VFS_VERSION (uint32_t) VF status schema version
|
|
||||||
IFLAF_VFS_ERROR (uint32_t) errno if the PF query failed
|
|
||||||
IFLAF_VFS_PF_LINK_STATE (uint8_t) IFLAF_VF_LINK_*
|
|
||||||
IFLAF_VFS_PF_LINK_SPEED (uint64_t) bits per second
|
|
||||||
IFLAF_VFS_LIST (nested) repeated IFLAF_VF_LIST_ENTRY
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
On a successful query,
|
|
||||||
.Dv IFLAF_VFS_VERSION
|
|
||||||
and
|
|
||||||
.Dv IFLAF_VFS_LIST
|
|
||||||
are present.
|
|
||||||
If the PF status query fails,
|
|
||||||
.Dv IFLAF_VFS_ERROR
|
|
||||||
contains the errno value and the other status attributes are omitted.
|
|
||||||
.Pp
|
|
||||||
Each
|
|
||||||
.Dv IFLAF_VF_LIST_ENTRY
|
|
||||||
may contain the following attributes:
|
|
||||||
.Bd -literal -offset indent -compact
|
|
||||||
IFLAF_VF_INDEX (uint32_t) PF-local VF index
|
|
||||||
IFLAF_VF_CONFIGURED (uint8_t) PF accepted configuration
|
|
||||||
IFLAF_VF_INITIALIZED (uint8_t) VF handshake completed
|
|
||||||
IFLAF_VF_MAC (binary) PF-known primary MAC address
|
|
||||||
IFLAF_VF_VLAN_MODE (uint8_t) IFLAF_VF_VLAN_*
|
|
||||||
IFLAF_VF_VLAN (uint16_t) access VLAN identifier
|
|
||||||
IFLAF_VF_VLAN_COUNT (uint32_t) explicit VLAN filters
|
|
||||||
IFLAF_VF_VLAN_LIMIT (uint32_t) explicit VLAN-filter limit
|
|
||||||
IFLAF_VF_NUM_QUEUES (uint32_t) allocated RX/TX queue pairs
|
|
||||||
IFLAF_VF_ALLOW_SET_MAC (uint8_t) administrative permission
|
|
||||||
IFLAF_VF_ALLOW_SET_VLAN (uint8_t) administrative permission
|
|
||||||
IFLAF_VF_MAC_ANTI_SPOOF (uint8_t) MAC anti-spoofing enabled
|
|
||||||
IFLAF_VF_ALLOW_PROMISC (uint8_t) administrative permission
|
|
||||||
IFLAF_VF_TRAFFIC_ENABLED (uint8_t) VF traffic enabled
|
|
||||||
IFLAF_VF_MDD_BLOCKED (uint8_t) malicious-driver block active
|
|
||||||
IFLAF_VF_QUARANTINED (uint8_t) persistent quarantine active
|
|
||||||
IFLAF_VF_API_VERSION (string) negotiated mailbox API
|
|
||||||
IFLAF_VF_LINK_STATE_POLICY (uint8_t) IFLAF_VF_LINK_*
|
|
||||||
IFLAF_VF_EXTENSIONS (nested) driver-specific namespaces
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
.Dv IFLAF_VF_INDEX
|
|
||||||
is required in every list entry.
|
|
||||||
Other fields are optional and are omitted when the PF driver cannot observe
|
|
||||||
them; omission does not mean false or zero.
|
|
||||||
Boolean attributes contain zero or one.
|
|
||||||
.Dv IFLAF_VF_CONFIGURED
|
|
||||||
means that the PF accepted the VF configuration, while
|
|
||||||
.Dv IFLAF_VF_INITIALIZED
|
|
||||||
means that the VF completed its driver or mailbox handshake since its last
|
|
||||||
reset.
|
|
||||||
.Pp
|
|
||||||
.Dv IFLAF_VF_NUM_QUEUES
|
|
||||||
is the number of allocated symmetric RX/TX queue pairs, not necessarily the
|
|
||||||
number currently used by the VF driver.
|
|
||||||
Access VLAN mode means that the PF imposes
|
|
||||||
.Dv IFLAF_VF_VLAN ;
|
|
||||||
trunk mode means that no access VLAN is imposed and does not promise unlimited
|
|
||||||
filter capacity.
|
|
||||||
.Dv IFLAF_VF_VLAN_COUNT
|
|
||||||
counts explicit filters recorded by the PF and excludes implicit untagged and
|
|
||||||
priority-tag membership.
|
|
||||||
The permission attributes describe requests the VF may make, not requests it
|
|
||||||
has made.
|
|
||||||
The top-level PF link state and speed are values normally advertised to VFs,
|
|
||||||
not evidence that a VF driver is operational.
|
|
||||||
.Pp
|
|
||||||
Link-state values are:
|
|
||||||
.Bd -literal -offset indent -compact
|
|
||||||
IFLAF_VF_LINK_UNKNOWN state is unavailable
|
|
||||||
IFLAF_VF_LINK_DOWN link is forced or observed down
|
|
||||||
IFLAF_VF_LINK_UP link is forced or observed up
|
|
||||||
IFLAF_VF_LINK_AUTO VF follows PF link state
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
VLAN-mode values are:
|
|
||||||
.Bd -literal -offset indent -compact
|
|
||||||
IFLAF_VF_VLAN_UNKNOWN mode is unavailable
|
|
||||||
IFLAF_VF_VLAN_ACCESS PF imposes an access VLAN
|
|
||||||
IFLAF_VF_VLAN_TRUNK no access VLAN is imposed
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
Driver-specific data is returned under
|
|
||||||
.Dv IFLAF_VF_EXTENSIONS
|
|
||||||
as repeated
|
|
||||||
.Dv IFLAF_VF_EXT_LIST_ENTRY
|
|
||||||
objects.
|
|
||||||
Each object contains a stable namespace string in
|
|
||||||
.Dv IFLAF_VF_EXT_NAME
|
|
||||||
and its packed, versioned
|
|
||||||
.Xr nvlist 9
|
|
||||||
in
|
|
||||||
.Dv IFLAF_VF_EXT_DATA .
|
|
||||||
Each namespace contains a version number.
|
|
||||||
Consumers must ignore unknown namespaces and fields.
|
|
||||||
.It Dv IFLA_LINKINFO
|
.It Dv IFLA_LINKINFO
|
||||||
(nested) Interface type-specific attributes:
|
(nested) Interface type-specific attributes:
|
||||||
.Bd -literal -offset indent -compact
|
.Bd -literal -offset indent -compact
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ _DP_gmock= gtest
|
|||||||
_DP_gmock_main= gmock
|
_DP_gmock_main= gmock
|
||||||
_DP_gtest= pthread regex
|
_DP_gtest= pthread regex
|
||||||
_DP_gtest_main= gtest
|
_DP_gtest_main= gtest
|
||||||
_DP_ifconfig= m nv
|
_DP_ifconfig= m
|
||||||
_DP_ipf= kvm
|
_DP_ipf= kvm
|
||||||
_DP_iscsiutil= md
|
_DP_iscsiutil= md
|
||||||
_DP_kldelf= elf
|
_DP_kldelf= elf
|
||||||
@@ -512,7 +512,7 @@ _DP_zpool= md pthread z icp spl nvpair avl umem
|
|||||||
_DP_zutil= avl geom m
|
_DP_zutil= avl geom m
|
||||||
_DP_be= zfs spl nvpair zfsbootenv
|
_DP_be= zfs spl nvpair zfsbootenv
|
||||||
_DP_netmap=
|
_DP_netmap=
|
||||||
_DP_ifconfig= m nv
|
_DP_ifconfig= m
|
||||||
_DP_pfctl= nv
|
_DP_pfctl= nv
|
||||||
_DP_krb5ss= edit
|
_DP_krb5ss= edit
|
||||||
|
|
||||||
|
|||||||
@@ -665,7 +665,6 @@ static device_method_t igb_if_methods[] = {
|
|||||||
DEVMETHOD(ifdi_iov_init, igb_if_iov_init),
|
DEVMETHOD(ifdi_iov_init, igb_if_iov_init),
|
||||||
DEVMETHOD(ifdi_iov_uninit, igb_if_iov_uninit),
|
DEVMETHOD(ifdi_iov_uninit, igb_if_iov_uninit),
|
||||||
DEVMETHOD(ifdi_iov_vf_add, igb_if_iov_vf_add),
|
DEVMETHOD(ifdi_iov_vf_add, igb_if_iov_vf_add),
|
||||||
DEVMETHOD(ifdi_vf_status, igb_if_vf_status),
|
|
||||||
#endif
|
#endif
|
||||||
DEVMETHOD_END
|
DEVMETHOD_END
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1995,64 +1995,6 @@ igb_iov_validate(struct e1000_softc *sc, u16 num_vfs)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
igb_if_vf_status(if_ctx_t ctx, nvlist_t *status)
|
|
||||||
{
|
|
||||||
struct e1000_softc *sc;
|
|
||||||
struct igb_vf *vf;
|
|
||||||
nvlist_t **vfs;
|
|
||||||
u_int num_queues;
|
|
||||||
int error, i;
|
|
||||||
|
|
||||||
sc = iflib_get_softc(ctx);
|
|
||||||
if (sc->num_vfs == 0)
|
|
||||||
return (ENXIO);
|
|
||||||
num_queues = sc->hw.mac.type == e1000_82576 ?
|
|
||||||
IGB_82576_VF_QUEUES : IGB_I350_VF_QUEUES;
|
|
||||||
vfs = mallocarray(sc->num_vfs, sizeof(*vfs), M_IGB_IOV,
|
|
||||||
M_WAITOK | M_ZERO);
|
|
||||||
for (i = 0; i < sc->num_vfs; i++) {
|
|
||||||
vf = &sc->vfs[i];
|
|
||||||
vfs[i] = nvlist_create(0);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_INDEX, i);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_CONFIGURED,
|
|
||||||
(vf->flags & IGB_VF_ACTIVE) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_INITIALIZED,
|
|
||||||
(vf->flags & IGB_VF_CTS) != 0);
|
|
||||||
nvlist_add_binary(vfs[i], IFVF_STATUS_MAC, vf->mac,
|
|
||||||
ETHER_ADDR_LEN);
|
|
||||||
if (vf->default_vlan == 0)
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
|
|
||||||
IFVF_VLAN_MODE_TRUNK);
|
|
||||||
else {
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
|
|
||||||
IFVF_VLAN_MODE_ACCESS);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN,
|
|
||||||
vf->default_vlan);
|
|
||||||
}
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN_COUNT,
|
|
||||||
vf->vlan_count);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES, num_queues);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_MAC,
|
|
||||||
(vf->flags & IGB_VF_CAP_MAC) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_VLAN,
|
|
||||||
vf->default_vlan == 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_MAC_ANTI_SPOOF,
|
|
||||||
(vf->flags & IGB_VF_MAC_ANTI_SPOOF) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_PROMISC,
|
|
||||||
(vf->flags & IGB_VF_ALLOW_PROMISC) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_MDD_BLOCKED,
|
|
||||||
(vf->flags & IGB_VF_MDD_BLOCKED) != 0);
|
|
||||||
}
|
|
||||||
nvlist_add_nvlist_array(status, IFVF_STATUS_VFS,
|
|
||||||
(const nvlist_t * const *)vfs, sc->num_vfs);
|
|
||||||
error = nvlist_error(status);
|
|
||||||
for (i = 0; i < sc->num_vfs; i++)
|
|
||||||
nvlist_destroy(vfs[i]);
|
|
||||||
free(vfs, M_IGB_IOV);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
igb_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config)
|
igb_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ int igb_iov_validate(struct e1000_softc *, u16);
|
|||||||
int igb_if_iov_init(if_ctx_t, u16, const nvlist_t *);
|
int igb_if_iov_init(if_ctx_t, u16, const nvlist_t *);
|
||||||
void igb_if_iov_uninit(if_ctx_t);
|
void igb_if_iov_uninit(if_ctx_t);
|
||||||
int igb_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *);
|
int igb_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *);
|
||||||
int igb_if_vf_status(if_ctx_t, nvlist_t *);
|
|
||||||
void igb_iov_initialize(struct e1000_softc *);
|
void igb_iov_initialize(struct e1000_softc *);
|
||||||
void igb_iov_handle_mbx(struct e1000_softc *);
|
void igb_iov_handle_mbx(struct e1000_softc *);
|
||||||
void igb_iov_handle_mdd(struct e1000_softc *);
|
void igb_iov_handle_mdd(struct e1000_softc *);
|
||||||
|
|||||||
@@ -380,7 +380,6 @@ static device_method_t ixgbe_if_methods[] = {
|
|||||||
DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init),
|
DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init),
|
||||||
DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit),
|
DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit),
|
||||||
DEVMETHOD(ifdi_iov_vf_add, ixgbe_if_iov_vf_add),
|
DEVMETHOD(ifdi_iov_vf_add, ixgbe_if_iov_vf_add),
|
||||||
DEVMETHOD(ifdi_vf_status, ixgbe_if_vf_status),
|
|
||||||
#endif /* PCI_IOV */
|
#endif /* PCI_IOV */
|
||||||
DEVMETHOD_END
|
DEVMETHOD_END
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1686,96 +1686,6 @@ ixgbe_mbx_pending(struct ixgbe_softc *sc)
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
|
||||||
ixgbe_vf_api_version(uint16_t api_ver)
|
|
||||||
{
|
|
||||||
switch (api_ver) {
|
|
||||||
case ixgbe_mbox_api_10:
|
|
||||||
return ("1.0");
|
|
||||||
case ixgbe_mbox_api_20:
|
|
||||||
return ("2.0");
|
|
||||||
case ixgbe_mbox_api_11:
|
|
||||||
return ("1.1");
|
|
||||||
case ixgbe_mbox_api_12:
|
|
||||||
return ("1.2");
|
|
||||||
case ixgbe_mbox_api_13:
|
|
||||||
return ("1.3");
|
|
||||||
case ixgbe_mbox_api_14:
|
|
||||||
return ("1.4");
|
|
||||||
case ixgbe_mbox_api_15:
|
|
||||||
return ("1.5");
|
|
||||||
case ixgbe_mbox_api_16:
|
|
||||||
return ("1.6");
|
|
||||||
default:
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ixgbe_if_vf_status(if_ctx_t ctx, nvlist_t *status)
|
|
||||||
{
|
|
||||||
struct ixgbe_softc *sc;
|
|
||||||
struct ixgbe_vf *vf;
|
|
||||||
const char *api_ver;
|
|
||||||
nvlist_t **vfs;
|
|
||||||
int error, i;
|
|
||||||
|
|
||||||
sc = iflib_get_softc(ctx);
|
|
||||||
if (sc->num_vfs == 0)
|
|
||||||
return (ENXIO);
|
|
||||||
vfs = mallocarray(sc->num_vfs, sizeof(*vfs), M_IXGBE_SRIOV,
|
|
||||||
M_WAITOK | M_ZERO);
|
|
||||||
for (i = 0; i < sc->num_vfs; i++) {
|
|
||||||
vf = &sc->vfs[i];
|
|
||||||
vfs[i] = nvlist_create(0);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_INDEX, i);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_CONFIGURED,
|
|
||||||
(vf->flags & IXGBE_VF_ACTIVE) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_INITIALIZED,
|
|
||||||
(vf->flags & IXGBE_VF_CTS) != 0);
|
|
||||||
nvlist_add_binary(vfs[i], IFVF_STATUS_MAC, vf->ether_addr,
|
|
||||||
ETHER_ADDR_LEN);
|
|
||||||
if (vf->default_vlan == 0)
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
|
|
||||||
IFVF_VLAN_MODE_TRUNK);
|
|
||||||
else {
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
|
|
||||||
IFVF_VLAN_MODE_ACCESS);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN,
|
|
||||||
vf->default_vlan);
|
|
||||||
}
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN_COUNT,
|
|
||||||
vf->num_vlans);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES,
|
|
||||||
ixgbe_vf_queues(sc->iov_mode));
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_MAC,
|
|
||||||
(vf->flags & IXGBE_VF_CAP_MAC) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_VLAN,
|
|
||||||
(vf->flags & IXGBE_VF_CAP_VLAN) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_MAC_ANTI_SPOOF,
|
|
||||||
(vf->flags & IXGBE_VF_ANTI_SPOOF) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_PROMISC,
|
|
||||||
(vf->flags & IXGBE_VF_ALLOW_PROMISC) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_TRAFFIC_ENABLED,
|
|
||||||
(vf->flags & IXGBE_VF_TRAFFIC_DISABLED) == 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_MDD_BLOCKED,
|
|
||||||
(vf->flags & IXGBE_VF_MDD_BLOCKED) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_QUARANTINED,
|
|
||||||
(vf->flags & IXGBE_VF_QUARANTINED) != 0);
|
|
||||||
api_ver = ixgbe_vf_api_version(vf->api_ver);
|
|
||||||
if (api_ver != NULL)
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_API_VERSION,
|
|
||||||
api_ver);
|
|
||||||
}
|
|
||||||
nvlist_add_nvlist_array(status, IFVF_STATUS_VFS,
|
|
||||||
(const nvlist_t * const *)vfs, sc->num_vfs);
|
|
||||||
error = nvlist_error(status);
|
|
||||||
for (i = 0; i < sc->num_vfs; i++)
|
|
||||||
nvlist_destroy(vfs[i]);
|
|
||||||
free(vfs, M_IXGBE_SRIOV);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ixgbe_iov_validate(struct ixgbe_softc *sc, u16 num_vfs)
|
ixgbe_iov_validate(struct ixgbe_softc *sc, u16 num_vfs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,7 +85,6 @@
|
|||||||
|
|
||||||
int ixgbe_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *);
|
int ixgbe_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *);
|
||||||
int ixgbe_if_iov_init(if_ctx_t, u16, const nvlist_t *);
|
int ixgbe_if_iov_init(if_ctx_t, u16, const nvlist_t *);
|
||||||
int ixgbe_if_vf_status(if_ctx_t, nvlist_t *);
|
|
||||||
int ixgbe_iov_validate(struct ixgbe_softc *, u16);
|
int ixgbe_iov_validate(struct ixgbe_softc *, u16);
|
||||||
void ixgbe_if_iov_uninit(if_ctx_t);
|
void ixgbe_if_iov_uninit(if_ctx_t);
|
||||||
void ixgbe_initialize_iov(struct ixgbe_softc *);
|
void ixgbe_initialize_iov(struct ixgbe_softc *);
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ static uint64_t ixl_if_get_counter(if_ctx_t ctx, ift_counter cnt);
|
|||||||
static int ixl_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req);
|
static int ixl_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req);
|
||||||
static int ixl_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data);
|
static int ixl_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data);
|
||||||
static bool ixl_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event);
|
static bool ixl_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event);
|
||||||
static int ixl_if_vf_status(if_ctx_t ctx, nvlist_t *status);
|
|
||||||
#ifdef PCI_IOV
|
#ifdef PCI_IOV
|
||||||
static void ixl_if_vflr_handle(if_ctx_t ctx);
|
static void ixl_if_vflr_handle(if_ctx_t ctx);
|
||||||
#endif
|
#endif
|
||||||
@@ -194,7 +193,6 @@ static device_method_t ixl_if_methods[] = {
|
|||||||
DEVMETHOD(ifdi_i2c_req, ixl_if_i2c_req),
|
DEVMETHOD(ifdi_i2c_req, ixl_if_i2c_req),
|
||||||
DEVMETHOD(ifdi_priv_ioctl, ixl_if_priv_ioctl),
|
DEVMETHOD(ifdi_priv_ioctl, ixl_if_priv_ioctl),
|
||||||
DEVMETHOD(ifdi_needs_restart, ixl_if_needs_restart),
|
DEVMETHOD(ifdi_needs_restart, ixl_if_needs_restart),
|
||||||
DEVMETHOD(ifdi_vf_status, ixl_if_vf_status),
|
|
||||||
#ifdef PCI_IOV
|
#ifdef PCI_IOV
|
||||||
DEVMETHOD(ifdi_iov_init, ixl_if_iov_init),
|
DEVMETHOD(ifdi_iov_init, ixl_if_iov_init),
|
||||||
DEVMETHOD(ifdi_iov_uninit, ixl_if_iov_uninit),
|
DEVMETHOD(ifdi_iov_uninit, ixl_if_iov_uninit),
|
||||||
@@ -364,7 +362,6 @@ ixl_register(device_t dev)
|
|||||||
{
|
{
|
||||||
return (&ixl_sctx_init);
|
return (&ixl_sctx_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ixl_allocate_pci_resources(struct ixl_pf *pf)
|
ixl_allocate_pci_resources(struct ixl_pf *pf)
|
||||||
{
|
{
|
||||||
@@ -1927,68 +1924,6 @@ ixl_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ixl_if_vf_status(if_ctx_t ctx, nvlist_t *status)
|
|
||||||
{
|
|
||||||
struct ixl_pf *pf;
|
|
||||||
nvlist_t **vfs;
|
|
||||||
struct ixl_vf *vf;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
pf = iflib_get_softc(ctx);
|
|
||||||
if (pf->num_vfs < 1)
|
|
||||||
return (ENXIO);
|
|
||||||
|
|
||||||
vfs = mallocarray(pf->num_vfs, sizeof(*vfs), M_IXL,
|
|
||||||
M_WAITOK | M_ZERO);
|
|
||||||
for (int i = 0; i < pf->num_vfs; i++) {
|
|
||||||
vf = &pf->vfs[i];
|
|
||||||
vfs[i] = nvlist_create(0);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_INDEX, vf->vf_num);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_CONFIGURED,
|
|
||||||
(vf->vf_flags & VF_FLAG_ENABLED) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_INITIALIZED,
|
|
||||||
(vf->vf_flags & VF_FLAG_INITIALIZED) != 0);
|
|
||||||
nvlist_add_binary(vfs[i], IFVF_STATUS_MAC, vf->mac,
|
|
||||||
ETHER_ADDR_LEN);
|
|
||||||
if (vf->default_vlan == 0) {
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
|
|
||||||
IFVF_VLAN_MODE_TRUNK);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN_COUNT,
|
|
||||||
vf->vsi.num_vlans);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN_LIMIT,
|
|
||||||
IXL_VF_MAX_VLAN_FILTERS);
|
|
||||||
} else {
|
|
||||||
nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
|
|
||||||
IFVF_VLAN_MODE_ACCESS);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN,
|
|
||||||
vf->default_vlan);
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_VLAN_COUNT, 1);
|
|
||||||
}
|
|
||||||
nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES,
|
|
||||||
vf->qtag.num_active);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_MAC,
|
|
||||||
(vf->vf_flags & VF_FLAG_SET_MAC_CAP) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_VLAN,
|
|
||||||
(vf->vf_flags & VF_FLAG_VLAN_CAP) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_MAC_ANTI_SPOOF,
|
|
||||||
(vf->vf_flags & VF_FLAG_MAC_ANTI_SPOOF) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_PROMISC,
|
|
||||||
(vf->vf_flags & VF_FLAG_PROMISC_CAP) != 0);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_TRAFFIC_ENABLED,
|
|
||||||
!vf->mdd_blocked);
|
|
||||||
nvlist_add_bool(vfs[i], IFVF_STATUS_MDD_BLOCKED,
|
|
||||||
vf->mdd_blocked);
|
|
||||||
}
|
|
||||||
nvlist_add_nvlist_array(status, IFVF_STATUS_VFS,
|
|
||||||
(const nvlist_t * const *)vfs, pf->num_vfs);
|
|
||||||
error = nvlist_error(status);
|
|
||||||
for (int i = 0; i < pf->num_vfs; i++)
|
|
||||||
nvlist_destroy(vfs[i]);
|
|
||||||
free(vfs, M_IXL);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sanity check and save off tunable values.
|
* Sanity check and save off tunable values.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+11
-163
@@ -124,12 +124,6 @@ struct ifreq_buffer32 {
|
|||||||
uint32_t buffer; /* (void *) */
|
uint32_t buffer; /* (void *) */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ifreq_nv_req32 {
|
|
||||||
u_int buf_length;
|
|
||||||
u_int length;
|
|
||||||
uint32_t buffer; /* (void *) */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interface request structure used for socket
|
* Interface request structure used for socket
|
||||||
* ioctl's. All interface ioctl's must have parameter
|
* ioctl's. All interface ioctl's must have parameter
|
||||||
@@ -154,7 +148,6 @@ struct ifreq32 {
|
|||||||
int ifru_cap[2];
|
int ifru_cap[2];
|
||||||
u_int ifru_fib;
|
u_int ifru_fib;
|
||||||
u_char ifru_vlan_pcp;
|
u_char ifru_vlan_pcp;
|
||||||
struct ifreq_nv_req32 ifru_nv;
|
|
||||||
} ifr_ifru;
|
} ifr_ifru;
|
||||||
};
|
};
|
||||||
CTASSERT(sizeof(struct ifreq) == sizeof(struct ifreq32));
|
CTASSERT(sizeof(struct ifreq) == sizeof(struct ifreq32));
|
||||||
@@ -2244,74 +2237,6 @@ ifr_buffer_set_length(void *data, size_t len)
|
|||||||
ifrup->ifr.ifr_ifru.ifru_buffer.length = len;
|
ifrup->ifr.ifr_ifru.ifru_buffer.length = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
|
||||||
ifr_nv_get_buffer(void *data)
|
|
||||||
{
|
|
||||||
union ifreq_union *ifrup;
|
|
||||||
|
|
||||||
ifrup = data;
|
|
||||||
#ifdef COMPAT_FREEBSD32
|
|
||||||
if (SV_CURPROC_FLAG(SV_ILP32))
|
|
||||||
return ((void *)(uintptr_t)
|
|
||||||
ifrup->ifr32.ifr_ifru.ifru_nv.buffer);
|
|
||||||
#endif
|
|
||||||
return (ifrup->ifr.ifr_ifru.ifru_nv.buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ifr_nv_set_buffer_null(void *data)
|
|
||||||
{
|
|
||||||
union ifreq_union *ifrup;
|
|
||||||
|
|
||||||
ifrup = data;
|
|
||||||
#ifdef COMPAT_FREEBSD32
|
|
||||||
if (SV_CURPROC_FLAG(SV_ILP32))
|
|
||||||
ifrup->ifr32.ifr_ifru.ifru_nv.buffer = 0;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
ifrup->ifr.ifr_ifru.ifru_nv.buffer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u_int
|
|
||||||
ifr_nv_get_buf_length(void *data)
|
|
||||||
{
|
|
||||||
union ifreq_union *ifrup;
|
|
||||||
|
|
||||||
ifrup = data;
|
|
||||||
#ifdef COMPAT_FREEBSD32
|
|
||||||
if (SV_CURPROC_FLAG(SV_ILP32))
|
|
||||||
return (ifrup->ifr32.ifr_ifru.ifru_nv.buf_length);
|
|
||||||
#endif
|
|
||||||
return (ifrup->ifr.ifr_ifru.ifru_nv.buf_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
static u_int
|
|
||||||
ifr_nv_get_length(void *data)
|
|
||||||
{
|
|
||||||
union ifreq_union *ifrup;
|
|
||||||
|
|
||||||
ifrup = data;
|
|
||||||
#ifdef COMPAT_FREEBSD32
|
|
||||||
if (SV_CURPROC_FLAG(SV_ILP32))
|
|
||||||
return (ifrup->ifr32.ifr_ifru.ifru_nv.length);
|
|
||||||
#endif
|
|
||||||
return (ifrup->ifr.ifr_ifru.ifru_nv.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ifr_nv_set_length(void *data, u_int len)
|
|
||||||
{
|
|
||||||
union ifreq_union *ifrup;
|
|
||||||
|
|
||||||
ifrup = data;
|
|
||||||
#ifdef COMPAT_FREEBSD32
|
|
||||||
if (SV_CURPROC_FLAG(SV_ILP32))
|
|
||||||
ifrup->ifr32.ifr_ifru.ifru_nv.length = len;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
ifrup->ifr.ifr_ifru.ifru_nv.length = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
ifr_data_get_ptr(void *ifrp)
|
ifr_data_get_ptr(void *ifrp)
|
||||||
{
|
{
|
||||||
@@ -2411,53 +2336,6 @@ if_capint_to_capnv(nvlist_t *nv, const struct ifcap_nv_bit_name *nn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
if_get_vf_status(if_t ifp, nvlist_t **statusp)
|
|
||||||
{
|
|
||||||
nvlist_t *status;
|
|
||||||
uint64_t baudrate;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
*statusp = NULL;
|
|
||||||
if (ifp->if_ioctl == NULL)
|
|
||||||
return (EOPNOTSUPP);
|
|
||||||
|
|
||||||
status = nvlist_create(0);
|
|
||||||
nvlist_add_number(status, IFVF_STATUS_VERSION_KEY,
|
|
||||||
IFVF_STATUS_VERSION);
|
|
||||||
error = (*ifp->if_ioctl)(ifp, SIOCGIFVFSTATUS,
|
|
||||||
__DECONST(caddr_t, status));
|
|
||||||
if (error != 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
switch (if_getlinkstate(ifp)) {
|
|
||||||
case LINK_STATE_DOWN:
|
|
||||||
nvlist_add_string(status, IFVF_STATUS_PF_LINK_STATE,
|
|
||||||
IFVF_LINK_STATE_DOWN);
|
|
||||||
break;
|
|
||||||
case LINK_STATE_UP:
|
|
||||||
nvlist_add_string(status, IFVF_STATUS_PF_LINK_STATE,
|
|
||||||
IFVF_LINK_STATE_UP);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
nvlist_add_string(status, IFVF_STATUS_PF_LINK_STATE,
|
|
||||||
IFVF_LINK_STATE_UNKNOWN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
baudrate = if_getbaudrate(ifp);
|
|
||||||
if (baudrate != 0)
|
|
||||||
nvlist_add_number(status, IFVF_STATUS_PF_LINK_SPEED, baudrate);
|
|
||||||
error = nvlist_error(status);
|
|
||||||
if (error == 0) {
|
|
||||||
*statusp = status;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
nvlist_destroy(status);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hardware specific interface ioctls.
|
* Hardware specific interface ioctls.
|
||||||
*/
|
*/
|
||||||
@@ -2471,7 +2349,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
|||||||
char *descrbuf;
|
char *descrbuf;
|
||||||
char new_name[IFNAMSIZ];
|
char new_name[IFNAMSIZ];
|
||||||
void *buf;
|
void *buf;
|
||||||
nvlist_t *nvcap, *nvstatus;
|
nvlist_t *nvcap;
|
||||||
struct siocsifcapnv_driver_data drv_ioctl_data;
|
struct siocsifcapnv_driver_data drv_ioctl_data;
|
||||||
|
|
||||||
ifr = (struct ifreq *)data;
|
ifr = (struct ifreq *)data;
|
||||||
@@ -2518,50 +2396,20 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
|||||||
error = EDOOFUS;
|
error = EDOOFUS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (nvbuflen > ifr_nv_get_buf_length(data)) {
|
if (nvbuflen > ifr->ifr_cap_nv.buf_length) {
|
||||||
ifr_nv_set_length(data, nvbuflen);
|
ifr->ifr_cap_nv.length = nvbuflen;
|
||||||
ifr_nv_set_buffer_null(data);
|
ifr->ifr_cap_nv.buffer = NULL;
|
||||||
error = EFBIG;
|
error = EFBIG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ifr_nv_set_length(data, nvbuflen);
|
ifr->ifr_cap_nv.length = nvbuflen;
|
||||||
error = copyout(buf, ifr_nv_get_buffer(data), nvbuflen);
|
error = copyout(buf, ifr->ifr_cap_nv.buffer, nvbuflen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(buf, M_NVLIST);
|
free(buf, M_NVLIST);
|
||||||
nvlist_destroy(nvcap);
|
nvlist_destroy(nvcap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCGIFVFSTATUS:
|
|
||||||
buf = NULL;
|
|
||||||
nvstatus = NULL;
|
|
||||||
for (;;) {
|
|
||||||
error = if_get_vf_status(ifp, &nvstatus);
|
|
||||||
if (error != 0)
|
|
||||||
break;
|
|
||||||
buf = nvlist_pack(nvstatus, &nvbuflen);
|
|
||||||
if (buf == NULL) {
|
|
||||||
error = nvlist_error(nvstatus);
|
|
||||||
if (error == 0)
|
|
||||||
error = EDOOFUS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (nvbuflen > IFR_VF_STATUS_NV_MAXBUFSIZE) {
|
|
||||||
error = E2BIG;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ifr_nv_set_length(data, nvbuflen);
|
|
||||||
if (nvbuflen > ifr_nv_get_buf_length(data)) {
|
|
||||||
error = EFBIG;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
error = copyout(buf, ifr_nv_get_buffer(data), nvbuflen);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free(buf, M_NVLIST);
|
|
||||||
nvlist_destroy(nvstatus);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SIOCGIFDATA:
|
case SIOCGIFDATA:
|
||||||
{
|
{
|
||||||
struct if_data ifd;
|
struct if_data ifd;
|
||||||
@@ -2715,16 +2563,16 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
|||||||
return (EOPNOTSUPP);
|
return (EOPNOTSUPP);
|
||||||
if ((ifp->if_capabilities & IFCAP_NV) == 0)
|
if ((ifp->if_capabilities & IFCAP_NV) == 0)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
if (ifr_nv_get_length(data) > IFR_CAP_NV_MAXBUFSIZE)
|
if (ifr->ifr_cap_nv.length > IFR_CAP_NV_MAXBUFSIZE)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
nvcap = NULL;
|
nvcap = NULL;
|
||||||
buf = malloc(ifr_nv_get_length(data), M_TEMP, M_WAITOK);
|
buf = malloc(ifr->ifr_cap_nv.length, M_TEMP, M_WAITOK);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
error = copyin(ifr_nv_get_buffer(data), buf,
|
error = copyin(ifr->ifr_cap_nv.buffer, buf,
|
||||||
ifr_nv_get_length(data));
|
ifr->ifr_cap_nv.length);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
nvcap = nvlist_unpack(buf, ifr_nv_get_length(data), 0);
|
nvcap = nvlist_unpack(buf, ifr->ifr_cap_nv.length, 0);
|
||||||
if (nvcap == NULL) {
|
if (nvcap == NULL) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -450,76 +450,6 @@ struct ifreq_nv_req {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define IFR_CAP_NV_MAXBUFSIZE (2 * 1024 * 1024)
|
#define IFR_CAP_NV_MAXBUFSIZE (2 * 1024 * 1024)
|
||||||
#define IFR_VF_STATUS_NV_MAXBUFSIZE (2 * 1024 * 1024)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SIOCGIFVFSTATUS schema contract.
|
|
||||||
*
|
|
||||||
* The top-level nvlist contains a version number and an array of per-VF
|
|
||||||
* nvlists. Per-VF keys other than the index are optional: providers omit
|
|
||||||
* values that are unknown or cannot be observed rather than reporting a
|
|
||||||
* false or zero value. "configured" means that the PF accepted the VF
|
|
||||||
* configuration, while "initialized" means that the VF completed its
|
|
||||||
* driver/mailbox handshake since its last reset. The MAC address is the
|
|
||||||
* PF's known primary address for the VF. The queue count is the number of
|
|
||||||
* allocated symmetric RX/TX queue pairs, not necessarily the number the
|
|
||||||
* guest currently uses.
|
|
||||||
*
|
|
||||||
* An access VLAN is imposed by the PF. Trunk mode means that no access
|
|
||||||
* VLAN is imposed; it does not promise unlimited VLAN-filter capacity.
|
|
||||||
* The VLAN count is the number of explicit filters recorded by the PF and
|
|
||||||
* excludes implicit untagged or priority-tag membership. "allow-*" values
|
|
||||||
* are administrative permissions, not the VF's current requests, and the
|
|
||||||
* blocked values describe current runtime state. The top-level PF link
|
|
||||||
* state and speed are the PF ifnet values normally advertised to VFs, not
|
|
||||||
* evidence that a guest driver is operational; speed is in bits per second.
|
|
||||||
* A per-VF link-state policy, when present, can override PF link visibility.
|
|
||||||
* Driver-specific data is stored in the optional "extensions" nvlist. Its
|
|
||||||
* keys are stable namespace names, not runtime device names. Each namespace
|
|
||||||
* contains a mandatory version number and owns the types and meanings of its
|
|
||||||
* remaining keys. Consumers must ignore unknown namespaces and keys. A
|
|
||||||
* provider omits an extension value that it cannot observe, and must not
|
|
||||||
* duplicate a field whose semantics are already represented by the common
|
|
||||||
* schema. Additive optional keys retain the namespace version; incompatible
|
|
||||||
* type or structural changes require a new namespace version.
|
|
||||||
*
|
|
||||||
* Additive optional common keys retain the top-level version. Change the
|
|
||||||
* top-level version only for an incompatible type or structural change.
|
|
||||||
*/
|
|
||||||
#define IFVF_STATUS_VERSION 1
|
|
||||||
#define IFVF_STATUS_VERSION_KEY "version"
|
|
||||||
#define IFVF_STATUS_VFS "vfs"
|
|
||||||
#define IFVF_STATUS_PF_LINK_STATE "pf-link-state"
|
|
||||||
#define IFVF_STATUS_PF_LINK_SPEED "pf-link-speed"
|
|
||||||
#define IFVF_STATUS_INDEX "index"
|
|
||||||
#define IFVF_STATUS_CONFIGURED "configured"
|
|
||||||
#define IFVF_STATUS_INITIALIZED "initialized"
|
|
||||||
#define IFVF_STATUS_MAC "mac-address"
|
|
||||||
#define IFVF_STATUS_VLAN_MODE "vlan-mode"
|
|
||||||
#define IFVF_STATUS_VLAN "vlan"
|
|
||||||
#define IFVF_STATUS_VLAN_COUNT "vlan-count"
|
|
||||||
#define IFVF_STATUS_VLAN_LIMIT "vlan-limit"
|
|
||||||
#define IFVF_STATUS_NUM_QUEUES "num-queues"
|
|
||||||
#define IFVF_STATUS_ALLOW_SET_MAC "allow-set-mac"
|
|
||||||
#define IFVF_STATUS_ALLOW_SET_VLAN "allow-set-vlan"
|
|
||||||
#define IFVF_STATUS_MAC_ANTI_SPOOF "mac-anti-spoof"
|
|
||||||
#define IFVF_STATUS_ALLOW_PROMISC "allow-promisc"
|
|
||||||
#define IFVF_STATUS_TRAFFIC_ENABLED "traffic-enabled"
|
|
||||||
#define IFVF_STATUS_MDD_BLOCKED "mdd-blocked"
|
|
||||||
#define IFVF_STATUS_QUARANTINED "quarantined"
|
|
||||||
#define IFVF_STATUS_API_VERSION "api-version"
|
|
||||||
#define IFVF_STATUS_LINK_STATE_POLICY "link-state-policy"
|
|
||||||
#define IFVF_STATUS_EXTENSIONS "extensions"
|
|
||||||
|
|
||||||
#define IFVF_STATUS_EXT_VERSION "version"
|
|
||||||
|
|
||||||
#define IFVF_VLAN_MODE_ACCESS "access"
|
|
||||||
#define IFVF_VLAN_MODE_TRUNK "trunk"
|
|
||||||
|
|
||||||
#define IFVF_LINK_STATE_UNKNOWN "unknown"
|
|
||||||
#define IFVF_LINK_STATE_DOWN "down"
|
|
||||||
#define IFVF_LINK_STATE_UP "up"
|
|
||||||
#define IFVF_LINK_STATE_AUTO "auto"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interface request structure used for socket
|
* Interface request structure used for socket
|
||||||
@@ -570,7 +500,6 @@ struct ifreq {
|
|||||||
#define ifr_vlan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */
|
#define ifr_vlan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */
|
||||||
#define ifr_lan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */
|
#define ifr_lan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */
|
||||||
#define ifr_cap_nv ifr_ifru.ifru_nv /* nv-based cap interface */
|
#define ifr_cap_nv ifr_ifru.ifru_nv /* nv-based cap interface */
|
||||||
#define ifr_vf_status_nv ifr_ifru.ifru_nv /* nv-based VF status */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _SIZEOF_ADDR_IFREQ(ifr) \
|
#define _SIZEOF_ADDR_IFREQ(ifr) \
|
||||||
|
|||||||
@@ -763,7 +763,6 @@ void *ifr_buffer_get_buffer(void *data);
|
|||||||
size_t ifr_buffer_get_length(void *data);
|
size_t ifr_buffer_get_length(void *data);
|
||||||
|
|
||||||
int ifhwioctl(u_long, if_t, caddr_t, struct thread *);
|
int ifhwioctl(u_long, if_t, caddr_t, struct thread *);
|
||||||
int if_get_vf_status(if_t, struct nvlist **);
|
|
||||||
|
|
||||||
#ifdef DEVICE_POLLING
|
#ifdef DEVICE_POLLING
|
||||||
enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS };
|
enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS };
|
||||||
|
|||||||
@@ -112,12 +112,6 @@ CODE {
|
|||||||
return (ENOTSUP);
|
return (ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
null_vf_status(if_ctx_t _ctx __unused, nvlist_t *_status __unused)
|
|
||||||
{
|
|
||||||
return (ENOTSUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
null_needs_restart(if_ctx_t _ctx __unused, enum iflib_restart_event _event __unused)
|
null_needs_restart(if_ctx_t _ctx __unused, enum iflib_restart_event _event __unused)
|
||||||
{
|
{
|
||||||
@@ -381,8 +375,3 @@ METHOD int get_downreason {
|
|||||||
if_ctx_t _ctx;
|
if_ctx_t _ctx;
|
||||||
struct ifdownreason *_ifdr;
|
struct ifdownreason *_ifdr;
|
||||||
} DEFAULT null_get_downreason;
|
} DEFAULT null_get_downreason;
|
||||||
|
|
||||||
METHOD int vf_status {
|
|
||||||
if_ctx_t _ctx;
|
|
||||||
nvlist_t *_status;
|
|
||||||
} DEFAULT null_vf_status;
|
|
||||||
@@ -4675,28 +4675,6 @@ iflib_if_ioctl(if_t ifp, u_long command, caddr_t data)
|
|||||||
err = IFDI_GET_DOWNREASON(ctx, (struct ifdownreason *)data);
|
err = IFDI_GET_DOWNREASON(ctx, (struct ifdownreason *)data);
|
||||||
CTX_UNLOCK(ctx);
|
CTX_UNLOCK(ctx);
|
||||||
break;
|
break;
|
||||||
case SIOCGIFVFSTATUS:
|
|
||||||
{
|
|
||||||
kobjop_desc_t kobj_desc;
|
|
||||||
kobj_method_t *kobj_method;
|
|
||||||
|
|
||||||
/* VF status describes children of an SR-IOV PF. */
|
|
||||||
if (CTX_IS_VF(ctx)) {
|
|
||||||
err = ENOTSUP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
kobj_desc = &ifdi_vf_status_desc;
|
|
||||||
kobj_method = kobj_lookup_method(((kobj_t)ctx)->ops->cls,
|
|
||||||
NULL, kobj_desc);
|
|
||||||
if (kobj_method == &kobj_desc->deflt) {
|
|
||||||
err = ENOTSUP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
CTX_LOCK(ctx);
|
|
||||||
err = IFDI_VF_STATUS(ctx, (nvlist_t *)data);
|
|
||||||
CTX_UNLOCK(ctx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
err = ether_ioctl(ifp, command, data);
|
err = ether_ioctl(ifp, command, data);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -178,113 +178,6 @@ SNL_DECLARE_PARSER_EXT(snl_rtm_route_parser, sizeof(struct rtmsg),
|
|||||||
_cb_p_route);
|
_cb_p_route);
|
||||||
|
|
||||||
/* RTM_<NEW|DEL|GET>LINK message parser */
|
/* RTM_<NEW|DEL|GET>LINK message parser */
|
||||||
struct snl_parsed_vf_extension {
|
|
||||||
char *name;
|
|
||||||
struct nlattr *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define _OUT(_field) offsetof(struct snl_parsed_vf_extension, _field)
|
|
||||||
static const struct snl_attr_parser _nla_p_vf_extension[] = {
|
|
||||||
{ .type = IFLAF_VF_EXT_NAME, .off = _OUT(name),
|
|
||||||
.cb = snl_attr_dup_string },
|
|
||||||
{ .type = IFLAF_VF_EXT_DATA, .off = _OUT(data),
|
|
||||||
.cb = snl_attr_dup_nla },
|
|
||||||
};
|
|
||||||
#undef _OUT
|
|
||||||
SNL_DECLARE_ATTR_PARSER_EXT(_vf_extension_parser,
|
|
||||||
sizeof(struct snl_parsed_vf_extension), _nla_p_vf_extension, NULL);
|
|
||||||
|
|
||||||
struct snl_parsed_vf {
|
|
||||||
uint32_t index;
|
|
||||||
uint32_t vlan_count;
|
|
||||||
uint32_t vlan_limit;
|
|
||||||
uint32_t num_queues;
|
|
||||||
uint16_t vlan;
|
|
||||||
uint8_t configured;
|
|
||||||
uint8_t initialized;
|
|
||||||
uint8_t vlan_mode;
|
|
||||||
uint8_t allow_set_mac;
|
|
||||||
uint8_t allow_set_vlan;
|
|
||||||
uint8_t mac_anti_spoof;
|
|
||||||
uint8_t allow_promisc;
|
|
||||||
uint8_t traffic_enabled;
|
|
||||||
uint8_t mdd_blocked;
|
|
||||||
uint8_t quarantined;
|
|
||||||
uint8_t link_state_policy;
|
|
||||||
char *api_version;
|
|
||||||
struct nlattr *mac;
|
|
||||||
struct snl_parray extensions;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define _OUT(_field) offsetof(struct snl_parsed_vf, _field)
|
|
||||||
static const struct snl_attr_parser _nla_p_vf[] = {
|
|
||||||
{ .type = IFLAF_VF_INDEX, .off = _OUT(index),
|
|
||||||
.cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLAF_VF_CONFIGURED, .off = _OUT(configured),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_INITIALIZED, .off = _OUT(initialized),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_MAC, .off = _OUT(mac), .cb = snl_attr_dup_nla },
|
|
||||||
{ .type = IFLAF_VF_VLAN_MODE, .off = _OUT(vlan_mode),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_VLAN, .off = _OUT(vlan),
|
|
||||||
.cb = snl_attr_get_uint16 },
|
|
||||||
{ .type = IFLAF_VF_VLAN_COUNT, .off = _OUT(vlan_count),
|
|
||||||
.cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLAF_VF_VLAN_LIMIT, .off = _OUT(vlan_limit),
|
|
||||||
.cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLAF_VF_NUM_QUEUES, .off = _OUT(num_queues),
|
|
||||||
.cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLAF_VF_ALLOW_SET_MAC, .off = _OUT(allow_set_mac),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_ALLOW_SET_VLAN, .off = _OUT(allow_set_vlan),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_MAC_ANTI_SPOOF, .off = _OUT(mac_anti_spoof),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_ALLOW_PROMISC, .off = _OUT(allow_promisc),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_TRAFFIC_ENABLED, .off = _OUT(traffic_enabled),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_MDD_BLOCKED, .off = _OUT(mdd_blocked),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_QUARANTINED, .off = _OUT(quarantined),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_API_VERSION, .off = _OUT(api_version),
|
|
||||||
.cb = snl_attr_dup_string },
|
|
||||||
{ .type = IFLAF_VF_LINK_STATE_POLICY,
|
|
||||||
.off = _OUT(link_state_policy), .cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VF_EXTENSIONS, .off = _OUT(extensions),
|
|
||||||
.arg = &_vf_extension_parser, .cb = snl_attr_get_parray },
|
|
||||||
};
|
|
||||||
#undef _OUT
|
|
||||||
SNL_DECLARE_ATTR_PARSER_EXT(_vf_parser, sizeof(struct snl_parsed_vf),
|
|
||||||
_nla_p_vf, NULL);
|
|
||||||
|
|
||||||
struct snl_parsed_vf_status {
|
|
||||||
uint64_t pf_link_speed;
|
|
||||||
uint32_t version;
|
|
||||||
uint32_t error;
|
|
||||||
uint8_t pf_link_state;
|
|
||||||
struct snl_parray vfs;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define _OUT(_field) offsetof(struct snl_parsed_vf_status, _field)
|
|
||||||
static const struct snl_attr_parser _nla_p_vf_status[] = {
|
|
||||||
{ .type = IFLAF_VFS_VERSION, .off = _OUT(version),
|
|
||||||
.cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLAF_VFS_ERROR, .off = _OUT(error),
|
|
||||||
.cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLAF_VFS_PF_LINK_STATE, .off = _OUT(pf_link_state),
|
|
||||||
.cb = snl_attr_get_uint8 },
|
|
||||||
{ .type = IFLAF_VFS_PF_LINK_SPEED, .off = _OUT(pf_link_speed),
|
|
||||||
.cb = snl_attr_get_uint64 },
|
|
||||||
{ .type = IFLAF_VFS_LIST, .off = _OUT(vfs),
|
|
||||||
.arg = &_vf_parser, .cb = snl_attr_get_parray },
|
|
||||||
};
|
|
||||||
#undef _OUT
|
|
||||||
SNL_DECLARE_ATTR_PARSER_EXT(_vf_status_parser,
|
|
||||||
sizeof(struct snl_parsed_vf_status), _nla_p_vf_status, NULL);
|
|
||||||
|
|
||||||
struct snl_parsed_link {
|
struct snl_parsed_link {
|
||||||
uint32_t ifi_index;
|
uint32_t ifi_index;
|
||||||
uint32_t ifi_flags;
|
uint32_t ifi_flags;
|
||||||
@@ -298,11 +191,9 @@ struct snl_parsed_link {
|
|||||||
struct nlattr *ifla_broadcast;
|
struct nlattr *ifla_broadcast;
|
||||||
char *ifla_ifalias;
|
char *ifla_ifalias;
|
||||||
uint32_t ifla_promiscuity;
|
uint32_t ifla_promiscuity;
|
||||||
uint32_t ifla_num_vf;
|
|
||||||
struct rtnl_link_stats64 *ifla_stats64;
|
struct rtnl_link_stats64 *ifla_stats64;
|
||||||
struct nlattr *iflaf_orig_hwaddr;
|
struct nlattr *iflaf_orig_hwaddr;
|
||||||
struct snl_attr_bitset iflaf_caps;
|
struct snl_attr_bitset iflaf_caps;
|
||||||
struct snl_parsed_vf_status iflaf_vf_status;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _IN(_field) offsetof(struct ifinfomsg, _field)
|
#define _IN(_field) offsetof(struct ifinfomsg, _field)
|
||||||
@@ -310,8 +201,6 @@ struct snl_parsed_link {
|
|||||||
static const struct snl_attr_parser _nla_p_link_fbsd[] = {
|
static const struct snl_attr_parser _nla_p_link_fbsd[] = {
|
||||||
{ .type = IFLAF_ORIG_HWADDR, .off = _OUT(iflaf_orig_hwaddr), .cb = snl_attr_dup_nla },
|
{ .type = IFLAF_ORIG_HWADDR, .off = _OUT(iflaf_orig_hwaddr), .cb = snl_attr_dup_nla },
|
||||||
{ .type = IFLAF_CAPS, .off = _OUT(iflaf_caps), .cb = snl_attr_get_bitset_c },
|
{ .type = IFLAF_CAPS, .off = _OUT(iflaf_caps), .cb = snl_attr_get_bitset_c },
|
||||||
{ .type = IFLAF_VF_STATUS, .off = _OUT(iflaf_vf_status),
|
|
||||||
.arg = &_vf_status_parser, .cb = snl_attr_get_nested },
|
|
||||||
};
|
};
|
||||||
SNL_DECLARE_ATTR_PARSER(_link_fbsd_parser, _nla_p_link_fbsd);
|
SNL_DECLARE_ATTR_PARSER(_link_fbsd_parser, _nla_p_link_fbsd);
|
||||||
|
|
||||||
@@ -322,7 +211,6 @@ static const struct snl_attr_parser _nla_p_link[] = {
|
|||||||
{ .type = IFLA_MTU, .off = _OUT(ifla_mtu), .cb = snl_attr_get_uint32 },
|
{ .type = IFLA_MTU, .off = _OUT(ifla_mtu), .cb = snl_attr_get_uint32 },
|
||||||
{ .type = IFLA_OPERSTATE, .off = _OUT(ifla_operstate), .cb = snl_attr_get_uint8 },
|
{ .type = IFLA_OPERSTATE, .off = _OUT(ifla_operstate), .cb = snl_attr_get_uint8 },
|
||||||
{ .type = IFLA_IFALIAS, .off = _OUT(ifla_ifalias), .cb = snl_attr_dup_string },
|
{ .type = IFLA_IFALIAS, .off = _OUT(ifla_ifalias), .cb = snl_attr_dup_string },
|
||||||
{ .type = IFLA_NUM_VF, .off = _OUT(ifla_num_vf), .cb = snl_attr_get_uint32 },
|
|
||||||
{ .type = IFLA_STATS64, .off = _OUT(ifla_stats64), .cb = snl_attr_dup_struct },
|
{ .type = IFLA_STATS64, .off = _OUT(ifla_stats64), .cb = snl_attr_dup_struct },
|
||||||
{ .type = IFLA_PROMISCUITY, .off = _OUT(ifla_promiscuity), .cb = snl_attr_get_uint32 },
|
{ .type = IFLA_PROMISCUITY, .off = _OUT(ifla_promiscuity), .cb = snl_attr_get_uint32 },
|
||||||
{ .type = IFLA_CARRIER, .off = _OUT(ifla_carrier), .cb = snl_attr_get_uint8 },
|
{ .type = IFLA_CARRIER, .off = _OUT(ifla_carrier), .cb = snl_attr_get_uint8 },
|
||||||
|
|||||||
+6
-278
@@ -33,7 +33,6 @@
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/jail.h>
|
#include <sys/jail.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/nv.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
@@ -66,7 +65,6 @@ struct netlink_walkargs {
|
|||||||
struct nlpcb *so;
|
struct nlpcb *so;
|
||||||
struct ucred *cred;
|
struct ucred *cred;
|
||||||
uint32_t fibnum;
|
uint32_t fibnum;
|
||||||
uint32_t ext_mask;
|
|
||||||
int family;
|
int family;
|
||||||
int error;
|
int error;
|
||||||
int count;
|
int count;
|
||||||
@@ -281,245 +279,6 @@ dump_iface_caps(struct nl_writer *nw, struct ifnet *ifp)
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t
|
|
||||||
vf_link_state(const char *state)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (strcmp(state, IFVF_LINK_STATE_DOWN) == 0)
|
|
||||||
return (IFLAF_VF_LINK_DOWN);
|
|
||||||
if (strcmp(state, IFVF_LINK_STATE_UP) == 0)
|
|
||||||
return (IFLAF_VF_LINK_UP);
|
|
||||||
if (strcmp(state, IFVF_LINK_STATE_AUTO) == 0)
|
|
||||||
return (IFLAF_VF_LINK_AUTO);
|
|
||||||
return (IFLAF_VF_LINK_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_bool(struct nl_writer *nw, const nvlist_t *vf, const char *name,
|
|
||||||
uint16_t attr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!nvlist_exists_bool(vf, name))
|
|
||||||
return (true);
|
|
||||||
return (nlattr_add_u8(nw, attr, nvlist_get_bool(vf, name) ? 1 : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_u16(struct nl_writer *nw, const nvlist_t *vf, const char *name,
|
|
||||||
uint16_t attr)
|
|
||||||
{
|
|
||||||
uint64_t value;
|
|
||||||
|
|
||||||
if (!nvlist_exists_number(vf, name))
|
|
||||||
return (true);
|
|
||||||
value = nvlist_get_number(vf, name);
|
|
||||||
if (value > UINT16_MAX)
|
|
||||||
return (false);
|
|
||||||
return (nlattr_add_u16(nw, attr, (uint16_t)value));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_u32(struct nl_writer *nw, const nvlist_t *vf, const char *name,
|
|
||||||
uint16_t attr)
|
|
||||||
{
|
|
||||||
uint64_t value;
|
|
||||||
|
|
||||||
if (!nvlist_exists_number(vf, name))
|
|
||||||
return (true);
|
|
||||||
value = nvlist_get_number(vf, name);
|
|
||||||
if (value > UINT32_MAX)
|
|
||||||
return (false);
|
|
||||||
return (nlattr_add_u32(nw, attr, (uint32_t)value));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_string(struct nl_writer *nw, const nvlist_t *vf, const char *name,
|
|
||||||
uint16_t attr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!nvlist_exists_string(vf, name))
|
|
||||||
return (true);
|
|
||||||
return (nlattr_add_string(nw, attr, nvlist_get_string(vf, name)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_extensions(struct nl_writer *nw, const nvlist_t *vf)
|
|
||||||
{
|
|
||||||
const nvlist_t *extension, *extensions;
|
|
||||||
const char *name;
|
|
||||||
void *buf, *cookie;
|
|
||||||
size_t buflen;
|
|
||||||
int entry_off, extensions_off, type;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
if (!nvlist_exists(vf, IFVF_STATUS_EXTENSIONS))
|
|
||||||
return (true);
|
|
||||||
if (!nvlist_exists_nvlist(vf, IFVF_STATUS_EXTENSIONS))
|
|
||||||
return (false);
|
|
||||||
|
|
||||||
extensions = nvlist_get_nvlist(vf, IFVF_STATUS_EXTENSIONS);
|
|
||||||
extensions_off = nlattr_add_nested(nw, IFLAF_VF_EXTENSIONS);
|
|
||||||
if (extensions_off == 0)
|
|
||||||
return (false);
|
|
||||||
cookie = NULL;
|
|
||||||
while ((name = nvlist_next(extensions, &type, &cookie)) != NULL) {
|
|
||||||
if (type != NV_TYPE_NVLIST)
|
|
||||||
return (false);
|
|
||||||
extension = nvlist_get_nvlist(extensions, name);
|
|
||||||
if (!nvlist_exists_number(extension,
|
|
||||||
IFVF_STATUS_EXT_VERSION))
|
|
||||||
return (false);
|
|
||||||
buf = nvlist_pack(extension, &buflen);
|
|
||||||
if (buf == NULL)
|
|
||||||
return (false);
|
|
||||||
if (buflen > UINT16_MAX - sizeof(struct nlattr)) {
|
|
||||||
free(buf, M_NVLIST);
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
entry_off = nlattr_add_nested(nw,
|
|
||||||
IFLAF_VF_EXT_LIST_ENTRY);
|
|
||||||
if (entry_off == 0) {
|
|
||||||
free(buf, M_NVLIST);
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
ok = nlattr_add_string(nw, IFLAF_VF_EXT_NAME, name) &&
|
|
||||||
nlattr_add(nw, IFLAF_VF_EXT_DATA, (uint16_t)buflen, buf);
|
|
||||||
free(buf, M_NVLIST);
|
|
||||||
if (!ok)
|
|
||||||
return (false);
|
|
||||||
nlattr_set_len(nw, entry_off);
|
|
||||||
}
|
|
||||||
nlattr_set_len(nw, extensions_off);
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_entry(struct nl_writer *nw, const nvlist_t *vf)
|
|
||||||
{
|
|
||||||
const void *mac;
|
|
||||||
const char *mode, *policy;
|
|
||||||
size_t maclen;
|
|
||||||
uint8_t vlan_mode;
|
|
||||||
int off;
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
off = nlattr_add_nested(nw, IFLAF_VF_LIST_ENTRY);
|
|
||||||
if (off == 0)
|
|
||||||
return (false);
|
|
||||||
ok = dump_vf_u32(nw, vf, IFVF_STATUS_INDEX, IFLAF_VF_INDEX) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_CONFIGURED,
|
|
||||||
IFLAF_VF_CONFIGURED) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_INITIALIZED,
|
|
||||||
IFLAF_VF_INITIALIZED);
|
|
||||||
if (!ok)
|
|
||||||
return (false);
|
|
||||||
|
|
||||||
if (nvlist_exists_binary(vf, IFVF_STATUS_MAC)) {
|
|
||||||
mac = nvlist_get_binary(vf, IFVF_STATUS_MAC, &maclen);
|
|
||||||
if (maclen > UINT16_MAX - sizeof(struct nlattr) ||
|
|
||||||
!nlattr_add(nw, IFLAF_VF_MAC, (uint16_t)maclen, mac))
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
if (nvlist_exists_string(vf, IFVF_STATUS_VLAN_MODE)) {
|
|
||||||
mode = nvlist_get_string(vf, IFVF_STATUS_VLAN_MODE);
|
|
||||||
if (strcmp(mode, IFVF_VLAN_MODE_ACCESS) == 0)
|
|
||||||
vlan_mode = IFLAF_VF_VLAN_ACCESS;
|
|
||||||
else if (strcmp(mode, IFVF_VLAN_MODE_TRUNK) == 0)
|
|
||||||
vlan_mode = IFLAF_VF_VLAN_TRUNK;
|
|
||||||
else
|
|
||||||
vlan_mode = IFLAF_VF_VLAN_UNKNOWN;
|
|
||||||
if (!nlattr_add_u8(nw, IFLAF_VF_VLAN_MODE, vlan_mode))
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
ok = dump_vf_u16(nw, vf, IFVF_STATUS_VLAN, IFLAF_VF_VLAN) &&
|
|
||||||
dump_vf_u32(nw, vf, IFVF_STATUS_VLAN_COUNT,
|
|
||||||
IFLAF_VF_VLAN_COUNT) &&
|
|
||||||
dump_vf_u32(nw, vf, IFVF_STATUS_VLAN_LIMIT,
|
|
||||||
IFLAF_VF_VLAN_LIMIT) &&
|
|
||||||
dump_vf_u32(nw, vf, IFVF_STATUS_NUM_QUEUES,
|
|
||||||
IFLAF_VF_NUM_QUEUES) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_ALLOW_SET_MAC,
|
|
||||||
IFLAF_VF_ALLOW_SET_MAC) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_ALLOW_SET_VLAN,
|
|
||||||
IFLAF_VF_ALLOW_SET_VLAN) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_MAC_ANTI_SPOOF,
|
|
||||||
IFLAF_VF_MAC_ANTI_SPOOF) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_ALLOW_PROMISC,
|
|
||||||
IFLAF_VF_ALLOW_PROMISC) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_TRAFFIC_ENABLED,
|
|
||||||
IFLAF_VF_TRAFFIC_ENABLED) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_MDD_BLOCKED,
|
|
||||||
IFLAF_VF_MDD_BLOCKED) &&
|
|
||||||
dump_vf_bool(nw, vf, IFVF_STATUS_QUARANTINED,
|
|
||||||
IFLAF_VF_QUARANTINED) &&
|
|
||||||
dump_vf_string(nw, vf, IFVF_STATUS_API_VERSION,
|
|
||||||
IFLAF_VF_API_VERSION);
|
|
||||||
if (!ok)
|
|
||||||
return (false);
|
|
||||||
if (nvlist_exists_string(vf, IFVF_STATUS_LINK_STATE_POLICY)) {
|
|
||||||
policy = nvlist_get_string(vf,
|
|
||||||
IFVF_STATUS_LINK_STATE_POLICY);
|
|
||||||
if (!nlattr_add_u8(nw, IFLAF_VF_LINK_STATE_POLICY,
|
|
||||||
vf_link_state(policy)))
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
if (!dump_vf_extensions(nw, vf))
|
|
||||||
return (false);
|
|
||||||
nlattr_set_len(nw, off);
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
dump_vf_status(struct nl_writer *nw, const nvlist_t *status, int error)
|
|
||||||
{
|
|
||||||
const nvlist_t * const *vfs;
|
|
||||||
const char *state;
|
|
||||||
size_t i, num_vfs;
|
|
||||||
uint64_t version;
|
|
||||||
int list_off, off;
|
|
||||||
|
|
||||||
off = nlattr_add_nested(nw, IFLAF_VF_STATUS);
|
|
||||||
if (off == 0)
|
|
||||||
return (false);
|
|
||||||
if (error != 0) {
|
|
||||||
if (!nlattr_add_u32(nw, IFLAF_VFS_ERROR, (uint32_t)error))
|
|
||||||
return (false);
|
|
||||||
nlattr_set_len(nw, off);
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nvlist_exists_number(status, IFVF_STATUS_VERSION_KEY))
|
|
||||||
return (false);
|
|
||||||
version = nvlist_get_number(status, IFVF_STATUS_VERSION_KEY);
|
|
||||||
if (version > UINT32_MAX ||
|
|
||||||
!nlattr_add_u32(nw, IFLAF_VFS_VERSION, (uint32_t)version))
|
|
||||||
return (false);
|
|
||||||
if (nvlist_exists_string(status, IFVF_STATUS_PF_LINK_STATE)) {
|
|
||||||
state = nvlist_get_string(status, IFVF_STATUS_PF_LINK_STATE);
|
|
||||||
if (!nlattr_add_u8(nw, IFLAF_VFS_PF_LINK_STATE,
|
|
||||||
vf_link_state(state)))
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
if (nvlist_exists_number(status, IFVF_STATUS_PF_LINK_SPEED) &&
|
|
||||||
!nlattr_add_u64(nw, IFLAF_VFS_PF_LINK_SPEED,
|
|
||||||
nvlist_get_number(status, IFVF_STATUS_PF_LINK_SPEED)))
|
|
||||||
return (false);
|
|
||||||
if (!nvlist_exists_nvlist_array(status, IFVF_STATUS_VFS))
|
|
||||||
return (false);
|
|
||||||
|
|
||||||
vfs = nvlist_get_nvlist_array(status, IFVF_STATUS_VFS, &num_vfs);
|
|
||||||
list_off = nlattr_add_nested(nw, IFLAF_VFS_LIST);
|
|
||||||
if (list_off == 0)
|
|
||||||
return (false);
|
|
||||||
for (i = 0; i < num_vfs; i++) {
|
|
||||||
if (!dump_vf_entry(nw, vfs[i]))
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
nlattr_set_len(nw, list_off);
|
|
||||||
nlattr_set_len(nw, off);
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dumps interface state, properties and metrics.
|
* Dumps interface state, properties and metrics.
|
||||||
* @nw: message writer
|
* @nw: message writer
|
||||||
@@ -531,26 +290,12 @@ dump_vf_status(struct nl_writer *nw, const nvlist_t *status, int error)
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
dump_iface(struct nl_writer *nw, if_t ifp, const struct nlmsghdr *hdr,
|
dump_iface(struct nl_writer *nw, if_t ifp, const struct nlmsghdr *hdr,
|
||||||
int if_flags_mask, const char *ifname, uint32_t ext_mask)
|
int if_flags_mask, const char *ifname)
|
||||||
{
|
{
|
||||||
struct epoch_tracker et;
|
struct epoch_tracker et;
|
||||||
nvlist_t *vf_status;
|
|
||||||
size_t num_vfs;
|
|
||||||
struct ifinfomsg *ifinfo;
|
struct ifinfomsg *ifinfo;
|
||||||
bool include_vf_status;
|
|
||||||
int vf_error;
|
|
||||||
|
|
||||||
NL_LOG(LOG_DEBUG3, "dumping interface %s data", if_name(ifp));
|
NL_LOG(LOG_DEBUG3, "dumping interface %s data", if_name(ifp));
|
||||||
vf_status = NULL;
|
|
||||||
vf_error = 0;
|
|
||||||
include_vf_status = (ext_mask & RTEXT_FILTER_VF) != 0;
|
|
||||||
if (include_vf_status) {
|
|
||||||
vf_error = if_get_vf_status(ifp, &vf_status);
|
|
||||||
if (vf_error == EINVAL || vf_error == ENOTTY ||
|
|
||||||
vf_error == ENXIO || vf_error == ENOTSUP ||
|
|
||||||
vf_error == EOPNOTSUPP)
|
|
||||||
include_vf_status = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nlmsg_reply(nw, hdr, sizeof(struct ifinfomsg)))
|
if (!nlmsg_reply(nw, hdr, sizeof(struct ifinfomsg)))
|
||||||
goto enomem;
|
goto enomem;
|
||||||
@@ -596,14 +341,6 @@ dump_iface(struct nl_writer *nw, if_t ifp, const struct nlmsghdr *hdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nlattr_add_u32(nw, IFLA_MTU, if_getmtu(ifp));
|
nlattr_add_u32(nw, IFLA_MTU, if_getmtu(ifp));
|
||||||
if (vf_status != NULL &&
|
|
||||||
nvlist_exists_nvlist_array(vf_status, IFVF_STATUS_VFS)) {
|
|
||||||
(void)nvlist_get_nvlist_array(vf_status, IFVF_STATUS_VFS,
|
|
||||||
&num_vfs);
|
|
||||||
if (num_vfs > UINT32_MAX ||
|
|
||||||
!nlattr_add_u32(nw, IFLA_NUM_VF, (uint32_t)num_vfs))
|
|
||||||
goto enomem;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
nlattr_add_u32(nw, IFLA_MIN_MTU, 60);
|
nlattr_add_u32(nw, IFLA_MIN_MTU, 60);
|
||||||
nlattr_add_u32(nw, IFLA_MAX_MTU, 9000);
|
nlattr_add_u32(nw, IFLA_MAX_MTU, 9000);
|
||||||
@@ -618,9 +355,6 @@ dump_iface(struct nl_writer *nw, if_t ifp, const struct nlmsghdr *hdr,
|
|||||||
if (off != 0) {
|
if (off != 0) {
|
||||||
get_hwaddr(nw, ifp);
|
get_hwaddr(nw, ifp);
|
||||||
dump_iface_caps(nw, ifp);
|
dump_iface_caps(nw, ifp);
|
||||||
if (include_vf_status &&
|
|
||||||
!dump_vf_status(nw, vf_status, vf_error))
|
|
||||||
goto enomem;
|
|
||||||
|
|
||||||
nlattr_set_len(nw, off);
|
nlattr_set_len(nw, off);
|
||||||
}
|
}
|
||||||
@@ -634,14 +368,11 @@ dump_iface(struct nl_writer *nw, if_t ifp, const struct nlmsghdr *hdr,
|
|||||||
|
|
||||||
nw->ifp = ifp;
|
nw->ifp = ifp;
|
||||||
|
|
||||||
if (nlmsg_end(nw)) {
|
if (nlmsg_end(nw))
|
||||||
nvlist_destroy(vf_status);
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
|
||||||
|
|
||||||
enomem:
|
enomem:
|
||||||
nvlist_destroy(vf_status);
|
NL_LOG(LOG_DEBUG, "unable to dump interface %s state (ENOMEM)", if_name(ifp));
|
||||||
NL_LOG(LOG_DEBUG, "unable to dump interface %s state", if_name(ifp));
|
|
||||||
nlmsg_abort(nw);
|
nlmsg_abort(nw);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
@@ -684,7 +415,6 @@ static const struct nlattr_parser nla_p_if[] = {
|
|||||||
{ .type = IFLA_LINKINFO, .arg = &linfo_parser, .cb = nlattr_get_nested },
|
{ .type = IFLA_LINKINFO, .arg = &linfo_parser, .cb = nlattr_get_nested },
|
||||||
{ .type = IFLA_IFALIAS, .off = _OUT(ifla_ifalias), .cb = nlattr_get_string },
|
{ .type = IFLA_IFALIAS, .off = _OUT(ifla_ifalias), .cb = nlattr_get_string },
|
||||||
{ .type = IFLA_GROUP, .off = _OUT(ifla_group), .cb = nlattr_get_string },
|
{ .type = IFLA_GROUP, .off = _OUT(ifla_group), .cb = nlattr_get_string },
|
||||||
{ .type = IFLA_EXT_MASK, .off = _OUT(ifla_ext_mask), .cb = nlattr_get_uint32 },
|
|
||||||
{ .type = IFLA_ALT_IFNAME, .off = _OUT(ifla_ifname), .cb = nlattr_get_string },
|
{ .type = IFLA_ALT_IFNAME, .off = _OUT(ifla_ifname), .cb = nlattr_get_string },
|
||||||
};
|
};
|
||||||
#undef _IN
|
#undef _IN
|
||||||
@@ -711,7 +441,7 @@ static int
|
|||||||
dump_cb(if_t ifp, void *_arg)
|
dump_cb(if_t ifp, void *_arg)
|
||||||
{
|
{
|
||||||
struct netlink_walkargs *wa = (struct netlink_walkargs *)_arg;
|
struct netlink_walkargs *wa = (struct netlink_walkargs *)_arg;
|
||||||
if (!dump_iface(wa->nw, ifp, &wa->hdr, 0, NULL, wa->ext_mask))
|
if (!dump_iface(wa->nw, ifp, &wa->hdr, 0, NULL))
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -743,7 +473,6 @@ rtnl_handle_getlink(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *n
|
|||||||
.hdr.nlmsg_seq = hdr->nlmsg_seq,
|
.hdr.nlmsg_seq = hdr->nlmsg_seq,
|
||||||
.hdr.nlmsg_flags = hdr->nlmsg_flags,
|
.hdr.nlmsg_flags = hdr->nlmsg_flags,
|
||||||
.hdr.nlmsg_type = NL_RTM_NEWLINK,
|
.hdr.nlmsg_type = NL_RTM_NEWLINK,
|
||||||
.ext_mask = attrs.ifla_ext_mask,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Fast track for an interface w/ explicit name or index match */
|
/* Fast track for an interface w/ explicit name or index match */
|
||||||
@@ -762,8 +491,7 @@ rtnl_handle_getlink(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *n
|
|||||||
|
|
||||||
if (ifp != NULL) {
|
if (ifp != NULL) {
|
||||||
if (match_iface(ifp, &attrs)) {
|
if (match_iface(ifp, &attrs)) {
|
||||||
if (!dump_iface(wa.nw, ifp, &wa.hdr, 0, NULL,
|
if (!dump_iface(wa.nw, ifp, &wa.hdr, 0, NULL))
|
||||||
wa.ext_mask))
|
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
} else
|
} else
|
||||||
error = ENODEV;
|
error = ENODEV;
|
||||||
@@ -1690,7 +1418,7 @@ rtnl_handle_ifevent(if_t ifp, int nlmsg_type, int if_flags_mask,
|
|||||||
NL_LOG(LOG_DEBUG, "error allocating group writer");
|
NL_LOG(LOG_DEBUG, "error allocating group writer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dump_iface(&nw, ifp, &hdr, if_flags_mask, ifname, 0);
|
dump_iface(&nw, ifp, &hdr, if_flags_mask, ifname);
|
||||||
nlmsg_flush(&nw);
|
nlmsg_flush(&nw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ enum {
|
|||||||
#define IFLA_NET_NS_PID IFLA_NET_NS_PID
|
#define IFLA_NET_NS_PID IFLA_NET_NS_PID
|
||||||
IFLA_IFALIAS = 20, /* string: interface description */
|
IFLA_IFALIAS = 20, /* string: interface description */
|
||||||
#define IFLA_IFALIAS IFLA_IFALIAS
|
#define IFLA_IFALIAS IFLA_IFALIAS
|
||||||
IFLA_NUM_VF = 21, /* u32: active VFs, when requested */
|
IFLA_NUM_VF = 21, /* not supported */
|
||||||
#define IFLA_NUM_VF IFLA_NUM_VF
|
#define IFLA_NUM_VF IFLA_NUM_VF
|
||||||
IFLA_VFINFO_LIST= 22, /* not supported */
|
IFLA_VFINFO_LIST= 22, /* not supported */
|
||||||
#define IFLA_VFINFO_LIST IFLA_VFINFO_LIST
|
#define IFLA_VFINFO_LIST IFLA_VFINFO_LIST
|
||||||
@@ -147,95 +147,15 @@ enum {
|
|||||||
};
|
};
|
||||||
#define IFLA_MAX (__IFLA_MAX - 1)
|
#define IFLA_MAX (__IFLA_MAX - 1)
|
||||||
|
|
||||||
/* IFLA_EXT_MASK values. */
|
|
||||||
#define RTEXT_FILTER_VF (1U << 0)
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
IFLAF_UNSPEC = 0,
|
IFLAF_UNSPEC = 0,
|
||||||
IFLAF_ORIG_IFNAME = 1, /* string, original interface name at creation */
|
IFLAF_ORIG_IFNAME = 1, /* string, original interface name at creation */
|
||||||
IFLAF_ORIG_HWADDR = 2, /* binary, original hardware address */
|
IFLAF_ORIG_HWADDR = 2, /* binary, original hardware address */
|
||||||
IFLAF_CAPS = 3, /* bitset, interface capabilities */
|
IFLAF_CAPS = 3, /* bitset, interface capabilities */
|
||||||
IFLAF_VF_STATUS = 4, /* nested, IFLAF_VFS_* */
|
|
||||||
__IFLAF_MAX
|
__IFLAF_MAX
|
||||||
};
|
};
|
||||||
#define IFLAF_MAX (__IFLAF_MAX - 1)
|
#define IFLAF_MAX (__IFLAF_MAX - 1)
|
||||||
|
|
||||||
/* IFLAF_VF_STATUS attributes. */
|
|
||||||
enum {
|
|
||||||
IFLAF_VFS_UNSPEC = 0,
|
|
||||||
IFLAF_VFS_VERSION = 1, /* u32: IFVF_STATUS_VERSION */
|
|
||||||
IFLAF_VFS_ERROR = 2, /* u32: errno from requested query */
|
|
||||||
IFLAF_VFS_PF_LINK_STATE = 3, /* u8: IFLAF_VF_LINK_* */
|
|
||||||
IFLAF_VFS_PF_LINK_SPEED = 4, /* u64: bits per second */
|
|
||||||
IFLAF_VFS_LIST = 5, /* nested, IFLAF_VF_LIST_* */
|
|
||||||
__IFLAF_VFS_MAX
|
|
||||||
};
|
|
||||||
#define IFLAF_VFS_MAX (__IFLAF_VFS_MAX - 1)
|
|
||||||
|
|
||||||
/* IFLAF_VFS_LIST attributes. */
|
|
||||||
enum {
|
|
||||||
IFLAF_VF_LIST_UNSPEC = 0,
|
|
||||||
IFLAF_VF_LIST_ENTRY = 1, /* nested, IFLAF_VF_*; repeated */
|
|
||||||
__IFLAF_VF_LIST_MAX
|
|
||||||
};
|
|
||||||
#define IFLAF_VF_LIST_MAX (__IFLAF_VF_LIST_MAX - 1)
|
|
||||||
|
|
||||||
/* IFLAF_VF_LIST_ENTRY attributes. */
|
|
||||||
enum {
|
|
||||||
IFLAF_VF_UNSPEC = 0,
|
|
||||||
IFLAF_VF_INDEX = 1, /* u32 */
|
|
||||||
IFLAF_VF_CONFIGURED = 2, /* u8 boolean */
|
|
||||||
IFLAF_VF_INITIALIZED = 3, /* u8 boolean */
|
|
||||||
IFLAF_VF_MAC = 4, /* binary */
|
|
||||||
IFLAF_VF_VLAN_MODE = 5, /* u8: IFLAF_VF_VLAN_* */
|
|
||||||
IFLAF_VF_VLAN = 6, /* u16 */
|
|
||||||
IFLAF_VF_VLAN_COUNT = 7, /* u32 */
|
|
||||||
IFLAF_VF_VLAN_LIMIT = 8, /* u32 */
|
|
||||||
IFLAF_VF_NUM_QUEUES = 9, /* u32 */
|
|
||||||
IFLAF_VF_ALLOW_SET_MAC = 10, /* u8 boolean */
|
|
||||||
IFLAF_VF_ALLOW_SET_VLAN = 11, /* u8 boolean */
|
|
||||||
IFLAF_VF_MAC_ANTI_SPOOF = 12, /* u8 boolean */
|
|
||||||
IFLAF_VF_ALLOW_PROMISC = 13, /* u8 boolean */
|
|
||||||
IFLAF_VF_TRAFFIC_ENABLED = 14, /* u8 boolean */
|
|
||||||
IFLAF_VF_MDD_BLOCKED = 15, /* u8 boolean */
|
|
||||||
IFLAF_VF_QUARANTINED = 16, /* u8 boolean */
|
|
||||||
IFLAF_VF_API_VERSION = 17, /* string */
|
|
||||||
IFLAF_VF_LINK_STATE_POLICY = 18, /* u8: IFLAF_VF_LINK_* */
|
|
||||||
IFLAF_VF_EXTENSIONS = 19, /* nested, IFLAF_VF_EXT_LIST_* */
|
|
||||||
__IFLAF_VF_MAX
|
|
||||||
};
|
|
||||||
#define IFLAF_VF_MAX (__IFLAF_VF_MAX - 1)
|
|
||||||
|
|
||||||
/* IFLAF_VF_EXTENSIONS attributes. */
|
|
||||||
enum {
|
|
||||||
IFLAF_VF_EXT_LIST_UNSPEC = 0,
|
|
||||||
IFLAF_VF_EXT_LIST_ENTRY = 1, /* nested; repeated */
|
|
||||||
__IFLAF_VF_EXT_LIST_MAX
|
|
||||||
};
|
|
||||||
#define IFLAF_VF_EXT_LIST_MAX (__IFLAF_VF_EXT_LIST_MAX - 1)
|
|
||||||
|
|
||||||
/* IFLAF_VF_EXT_LIST_ENTRY attributes. */
|
|
||||||
enum {
|
|
||||||
IFLAF_VF_EXT_UNSPEC = 0,
|
|
||||||
IFLAF_VF_EXT_NAME = 1, /* string: stable namespace */
|
|
||||||
IFLAF_VF_EXT_DATA = 2, /* binary: packed namespace nvlist */
|
|
||||||
__IFLAF_VF_EXT_MAX
|
|
||||||
};
|
|
||||||
#define IFLAF_VF_EXT_MAX (__IFLAF_VF_EXT_MAX - 1)
|
|
||||||
|
|
||||||
enum {
|
|
||||||
IFLAF_VF_LINK_UNKNOWN = 0,
|
|
||||||
IFLAF_VF_LINK_DOWN = 1,
|
|
||||||
IFLAF_VF_LINK_UP = 2,
|
|
||||||
IFLAF_VF_LINK_AUTO = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
IFLAF_VF_VLAN_UNKNOWN = 0,
|
|
||||||
IFLAF_VF_VLAN_ACCESS = 1,
|
|
||||||
IFLAF_VF_VLAN_TRUNK = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attributes that can be used as filters:
|
* Attributes that can be used as filters:
|
||||||
* IFLA_IFNAME, IFLA_GROUP, IFLA_ALT_IFNAME
|
* IFLA_IFNAME, IFLA_GROUP, IFLA_ALT_IFNAME
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ struct nl_parsed_link {
|
|||||||
int ifi_index;
|
int ifi_index;
|
||||||
uint32_t ifla_link;
|
uint32_t ifla_link;
|
||||||
uint32_t ifla_mtu;
|
uint32_t ifla_mtu;
|
||||||
uint32_t ifla_ext_mask;
|
|
||||||
uint32_t ifi_flags;
|
uint32_t ifi_flags;
|
||||||
uint32_t ifi_change;
|
uint32_t ifi_change;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -152,6 +152,4 @@
|
|||||||
#define SIOCSUMBPARAM _IOW('i', 158, struct ifreq) /* set MBIM param */
|
#define SIOCSUMBPARAM _IOW('i', 158, struct ifreq) /* set MBIM param */
|
||||||
#define SIOCGUMBPARAM _IOWR('i', 159, struct ifreq) /* get MBIM param */
|
#define SIOCGUMBPARAM _IOWR('i', 159, struct ifreq) /* get MBIM param */
|
||||||
|
|
||||||
#define SIOCGIFVFSTATUS _IOWR('i', 163, struct ifreq) /* get VF status */
|
|
||||||
|
|
||||||
#endif /* !_SYS_SOCKIO_H_ */
|
#endif /* !_SYS_SOCKIO_H_ */
|
||||||
@@ -137,34 +137,6 @@ class NlAttrU32(NlAttr):
|
|||||||
return self._to_bytes(struct.pack("@I", self.u32))
|
return self._to_bytes(struct.pack("@I", self.u32))
|
||||||
|
|
||||||
|
|
||||||
class NlAttrU64(NlAttr):
|
|
||||||
def __init__(self, nla_type, val):
|
|
||||||
self.u64 = enum_or_int(val)
|
|
||||||
super().__init__(nla_type, b"")
|
|
||||||
|
|
||||||
@property
|
|
||||||
def nla_len(self):
|
|
||||||
return 12
|
|
||||||
|
|
||||||
def _print_attr_value(self):
|
|
||||||
return " val={}".format(self.u64)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _validate(data):
|
|
||||||
assert len(data) == 12
|
|
||||||
nla_len, nla_type = struct.unpack("@HH", data[:4])
|
|
||||||
assert nla_len == 12
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _parse(cls, data):
|
|
||||||
nla_len, nla_type = struct.unpack("@HH", data[:4])
|
|
||||||
val = struct.unpack("@Q", data[4:])[0]
|
|
||||||
return cls(nla_type, val)
|
|
||||||
|
|
||||||
def __bytes__(self):
|
|
||||||
return self._to_bytes(struct.pack("@Q", self.u64))
|
|
||||||
|
|
||||||
|
|
||||||
class NlAttrS32(NlAttr):
|
class NlAttrS32(NlAttr):
|
||||||
def __init__(self, nla_type, val):
|
def __init__(self, nla_type, val):
|
||||||
self.s32 = enum_or_int(val)
|
self.s32 = enum_or_int(val)
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ from atf_python.sys.netlink.attrs import NlAttr
|
|||||||
from atf_python.sys.netlink.attrs import NlAttrIp
|
from atf_python.sys.netlink.attrs import NlAttrIp
|
||||||
from atf_python.sys.netlink.attrs import NlAttrNested
|
from atf_python.sys.netlink.attrs import NlAttrNested
|
||||||
from atf_python.sys.netlink.attrs import NlAttrStr
|
from atf_python.sys.netlink.attrs import NlAttrStr
|
||||||
from atf_python.sys.netlink.attrs import NlAttrU16
|
|
||||||
from atf_python.sys.netlink.attrs import NlAttrU32
|
from atf_python.sys.netlink.attrs import NlAttrU32
|
||||||
from atf_python.sys.netlink.attrs import NlAttrU64
|
|
||||||
from atf_python.sys.netlink.attrs import NlAttrU8
|
from atf_python.sys.netlink.attrs import NlAttrU8
|
||||||
from atf_python.sys.netlink.message import StdNetlinkMessage
|
from atf_python.sys.netlink.message import StdNetlinkMessage
|
||||||
from atf_python.sys.netlink.message import NlMsgProps
|
from atf_python.sys.netlink.message import NlMsgProps
|
||||||
@@ -363,56 +361,6 @@ class IflafAttrType(Enum):
|
|||||||
IFLAF_UNSPEC = 0
|
IFLAF_UNSPEC = 0
|
||||||
IFLAF_ORIG_IFNAME = 1
|
IFLAF_ORIG_IFNAME = 1
|
||||||
IFLAF_ORIG_HWADDR = 2
|
IFLAF_ORIG_HWADDR = 2
|
||||||
IFLAF_CAPS = 3
|
|
||||||
IFLAF_VF_STATUS = 4
|
|
||||||
|
|
||||||
|
|
||||||
class IflafVfStatusType(Enum):
|
|
||||||
IFLAF_VFS_UNSPEC = 0
|
|
||||||
IFLAF_VFS_VERSION = 1
|
|
||||||
IFLAF_VFS_ERROR = 2
|
|
||||||
IFLAF_VFS_PF_LINK_STATE = 3
|
|
||||||
IFLAF_VFS_PF_LINK_SPEED = 4
|
|
||||||
IFLAF_VFS_LIST = 5
|
|
||||||
|
|
||||||
|
|
||||||
class IflafVfListType(Enum):
|
|
||||||
IFLAF_VF_LIST_UNSPEC = 0
|
|
||||||
IFLAF_VF_LIST_ENTRY = 1
|
|
||||||
|
|
||||||
|
|
||||||
class IflafVfType(Enum):
|
|
||||||
IFLAF_VF_UNSPEC = 0
|
|
||||||
IFLAF_VF_INDEX = 1
|
|
||||||
IFLAF_VF_CONFIGURED = 2
|
|
||||||
IFLAF_VF_INITIALIZED = 3
|
|
||||||
IFLAF_VF_MAC = 4
|
|
||||||
IFLAF_VF_VLAN_MODE = 5
|
|
||||||
IFLAF_VF_VLAN = 6
|
|
||||||
IFLAF_VF_VLAN_COUNT = 7
|
|
||||||
IFLAF_VF_VLAN_LIMIT = 8
|
|
||||||
IFLAF_VF_NUM_QUEUES = 9
|
|
||||||
IFLAF_VF_ALLOW_SET_MAC = 10
|
|
||||||
IFLAF_VF_ALLOW_SET_VLAN = 11
|
|
||||||
IFLAF_VF_MAC_ANTI_SPOOF = 12
|
|
||||||
IFLAF_VF_ALLOW_PROMISC = 13
|
|
||||||
IFLAF_VF_TRAFFIC_ENABLED = 14
|
|
||||||
IFLAF_VF_MDD_BLOCKED = 15
|
|
||||||
IFLAF_VF_QUARANTINED = 16
|
|
||||||
IFLAF_VF_API_VERSION = 17
|
|
||||||
IFLAF_VF_LINK_STATE_POLICY = 18
|
|
||||||
IFLAF_VF_EXTENSIONS = 19
|
|
||||||
|
|
||||||
|
|
||||||
class IflafVfExtListType(Enum):
|
|
||||||
IFLAF_VF_EXT_LIST_UNSPEC = 0
|
|
||||||
IFLAF_VF_EXT_LIST_ENTRY = 1
|
|
||||||
|
|
||||||
|
|
||||||
class IflafVfExtType(Enum):
|
|
||||||
IFLAF_VF_EXT_UNSPEC = 0
|
|
||||||
IFLAF_VF_EXT_NAME = 1
|
|
||||||
IFLAF_VF_EXT_DATA = 2
|
|
||||||
|
|
||||||
|
|
||||||
class IflinkInfo(Enum):
|
class IflinkInfo(Enum):
|
||||||
@@ -673,65 +621,6 @@ rtnl_route_attrs = prepare_attrs_map(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
rtnl_iflaf_vf_ext_attrs = [
|
|
||||||
AttrDescr(IflafVfExtType.IFLAF_VF_EXT_NAME, NlAttrStr),
|
|
||||||
AttrDescr(IflafVfExtType.IFLAF_VF_EXT_DATA, NlAttr),
|
|
||||||
]
|
|
||||||
|
|
||||||
rtnl_iflaf_vf_ext_list_attrs = [
|
|
||||||
AttrDescr(
|
|
||||||
IflafVfExtListType.IFLAF_VF_EXT_LIST_ENTRY,
|
|
||||||
NlAttrNested,
|
|
||||||
rtnl_iflaf_vf_ext_attrs,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
rtnl_iflaf_vf_attrs = [
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_INDEX, NlAttrU32),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_CONFIGURED, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_INITIALIZED, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_MAC, NlAttrMac),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_VLAN_MODE, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_VLAN, NlAttrU16),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_VLAN_COUNT, NlAttrU32),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_VLAN_LIMIT, NlAttrU32),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_NUM_QUEUES, NlAttrU32),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_ALLOW_SET_MAC, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_ALLOW_SET_VLAN, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_MAC_ANTI_SPOOF, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_ALLOW_PROMISC, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_TRAFFIC_ENABLED, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_MDD_BLOCKED, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_QUARANTINED, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_API_VERSION, NlAttrStr),
|
|
||||||
AttrDescr(IflafVfType.IFLAF_VF_LINK_STATE_POLICY, NlAttrU8),
|
|
||||||
AttrDescr(
|
|
||||||
IflafVfType.IFLAF_VF_EXTENSIONS,
|
|
||||||
NlAttrNested,
|
|
||||||
rtnl_iflaf_vf_ext_list_attrs,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
rtnl_iflaf_vf_list_attrs = [
|
|
||||||
AttrDescr(
|
|
||||||
IflafVfListType.IFLAF_VF_LIST_ENTRY,
|
|
||||||
NlAttrNested,
|
|
||||||
rtnl_iflaf_vf_attrs,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
rtnl_iflaf_vf_status_attrs = [
|
|
||||||
AttrDescr(IflafVfStatusType.IFLAF_VFS_VERSION, NlAttrU32),
|
|
||||||
AttrDescr(IflafVfStatusType.IFLAF_VFS_ERROR, NlAttrU32),
|
|
||||||
AttrDescr(IflafVfStatusType.IFLAF_VFS_PF_LINK_STATE, NlAttrU8),
|
|
||||||
AttrDescr(IflafVfStatusType.IFLAF_VFS_PF_LINK_SPEED, NlAttrU64),
|
|
||||||
AttrDescr(
|
|
||||||
IflafVfStatusType.IFLAF_VFS_LIST,
|
|
||||||
NlAttrNested,
|
|
||||||
rtnl_iflaf_vf_list_attrs,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
rtnl_ifla_attrs = prepare_attrs_map(
|
rtnl_ifla_attrs = prepare_attrs_map(
|
||||||
[
|
[
|
||||||
AttrDescr(IflattrType.IFLA_ADDRESS, NlAttrMac),
|
AttrDescr(IflattrType.IFLA_ADDRESS, NlAttrMac),
|
||||||
@@ -743,7 +632,6 @@ rtnl_ifla_attrs = prepare_attrs_map(
|
|||||||
AttrDescr(IflattrType.IFLA_OPERSTATE, NlAttrU8),
|
AttrDescr(IflattrType.IFLA_OPERSTATE, NlAttrU8),
|
||||||
AttrDescr(IflattrType.IFLA_CARRIER, NlAttrU8),
|
AttrDescr(IflattrType.IFLA_CARRIER, NlAttrU8),
|
||||||
AttrDescr(IflattrType.IFLA_IFALIAS, NlAttrStr),
|
AttrDescr(IflattrType.IFLA_IFALIAS, NlAttrStr),
|
||||||
AttrDescr(IflattrType.IFLA_NUM_VF, NlAttrU32),
|
|
||||||
AttrDescr(IflattrType.IFLA_STATS64, NlAttrIfStats),
|
AttrDescr(IflattrType.IFLA_STATS64, NlAttrIfStats),
|
||||||
AttrDescr(IflattrType.IFLA_NEW_IFINDEX, NlAttrU32),
|
AttrDescr(IflattrType.IFLA_NEW_IFINDEX, NlAttrU32),
|
||||||
AttrDescr(
|
AttrDescr(
|
||||||
@@ -759,11 +647,6 @@ rtnl_ifla_attrs = prepare_attrs_map(
|
|||||||
NlAttrNested,
|
NlAttrNested,
|
||||||
[
|
[
|
||||||
AttrDescr(IflafAttrType.IFLAF_ORIG_HWADDR, NlAttrMac),
|
AttrDescr(IflafAttrType.IFLAF_ORIG_HWADDR, NlAttrMac),
|
||||||
AttrDescr(
|
|
||||||
IflafAttrType.IFLAF_VF_STATUS,
|
|
||||||
NlAttrNested,
|
|
||||||
rtnl_iflaf_vf_status_attrs,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import socket
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from atf_python.sys.netlink.netlink_route import IflattrType
|
from atf_python.sys.netlink.netlink_route import IflattrType
|
||||||
from atf_python.sys.netlink.netlink_route import IflafAttrType
|
|
||||||
from atf_python.sys.netlink.netlink_route import IflinkInfo
|
from atf_python.sys.netlink.netlink_route import IflinkInfo
|
||||||
from atf_python.sys.netlink.netlink_route import IfLinkInfoDataVlan
|
from atf_python.sys.netlink.netlink_route import IfLinkInfoDataVlan
|
||||||
from atf_python.sys.netlink.netlink_route import NetlinkIflaMessage
|
from atf_python.sys.netlink.netlink_route import NetlinkIflaMessage
|
||||||
@@ -28,14 +27,12 @@ class TestRtNlIface(NetlinkTestTemplate, SingleVnetTestTemplate):
|
|||||||
super().setup_method(method)
|
super().setup_method(method)
|
||||||
self.setup_netlink(NlConst.NETLINK_ROUTE)
|
self.setup_netlink(NlConst.NETLINK_ROUTE)
|
||||||
|
|
||||||
def get_interface_byname(self, ifname, ext_mask=0):
|
def get_interface_byname(self, ifname):
|
||||||
msg = NetlinkIflaMessage(self.helper, NlRtMsgType.RTM_GETLINK.value)
|
msg = NetlinkIflaMessage(self.helper, NlRtMsgType.RTM_GETLINK.value)
|
||||||
msg.nl_hdr.nlmsg_flags = (
|
msg.nl_hdr.nlmsg_flags = (
|
||||||
NlmBaseFlags.NLM_F_ACK.value | NlmBaseFlags.NLM_F_REQUEST.value
|
NlmBaseFlags.NLM_F_ACK.value | NlmBaseFlags.NLM_F_REQUEST.value
|
||||||
)
|
)
|
||||||
msg.add_nla(NlAttrStr(IflattrType.IFLA_IFNAME, ifname))
|
msg.add_nla(NlAttrStr(IflattrType.IFLA_IFNAME, ifname))
|
||||||
if ext_mask != 0:
|
|
||||||
msg.add_nla(NlAttrU32(IflattrType.IFLA_EXT_MASK, ext_mask))
|
|
||||||
self.write_message(msg)
|
self.write_message(msg)
|
||||||
while True:
|
while True:
|
||||||
rx_msg = self.read_message()
|
rx_msg = self.read_message()
|
||||||
@@ -72,14 +69,6 @@ class TestRtNlIface(NetlinkTestTemplate, SingleVnetTestTemplate):
|
|||||||
assert rx_msg.is_type(NlMsgType.NLMSG_ERROR)
|
assert rx_msg.is_type(NlMsgType.NLMSG_ERROR)
|
||||||
assert rx_msg.error_code == errno.ENODEV
|
assert rx_msg.error_code == errno.ENODEV
|
||||||
|
|
||||||
def test_get_iface_vf_filter_unsupported(self):
|
|
||||||
"""Tests that the VF filter is accepted on a non-SR-IOV interface"""
|
|
||||||
rx_msg = self.get_interface_byname("lo0", 1)
|
|
||||||
assert rx_msg.get_nla(IflattrType.IFLA_NUM_VF) is None
|
|
||||||
fbsd = rx_msg.get_nla(IflattrType.IFLA_FREEBSD)
|
|
||||||
assert fbsd is not None
|
|
||||||
assert fbsd.get_nla(IflafAttrType.IFLAF_VF_STATUS) is None
|
|
||||||
|
|
||||||
@pytest.mark.require_user("root")
|
@pytest.mark.require_user("root")
|
||||||
def test_create_iface_plain(self):
|
def test_create_iface_plain(self):
|
||||||
"""Tests loopback creation w/o any parameters"""
|
"""Tests loopback creation w/o any parameters"""
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ static const struct snl_hdr_parser *snl_all_core_parsers[] = {
|
|||||||
|
|
||||||
static const struct snl_hdr_parser *snl_all_route_parsers[] = {
|
static const struct snl_hdr_parser *snl_all_route_parsers[] = {
|
||||||
&_metrics_mp_nh_parser, &_mpath_nh_parser, &_metrics_parser, &snl_rtm_route_parser,
|
&_metrics_mp_nh_parser, &_mpath_nh_parser, &_metrics_parser, &snl_rtm_route_parser,
|
||||||
&_vf_extension_parser, &_vf_parser, &_vf_status_parser,
|
|
||||||
&_link_fbsd_parser, &snl_rtm_link_parser, &snl_rtm_link_parser_simple,
|
&_link_fbsd_parser, &snl_rtm_link_parser, &snl_rtm_link_parser_simple,
|
||||||
&_neigh_fbsd_parser, &snl_rtm_neigh_parser,
|
&_neigh_fbsd_parser, &snl_rtm_neigh_parser,
|
||||||
&_addr_fbsd_parser, &snl_rtm_addr_parser, &_nh_fbsd_parser, &snl_nhmsg_parser,
|
&_addr_fbsd_parser, &snl_rtm_addr_parser, &_nh_fbsd_parser, &snl_nhmsg_parser,
|
||||||
@@ -38,93 +37,6 @@ ATF_TC_BODY(snl_verify_core_parsers, tc)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TC(snl_parse_vf_status);
|
|
||||||
ATF_TC_HEAD(snl_parse_vf_status, tc)
|
|
||||||
{
|
|
||||||
atf_tc_set_md_var(tc, "descr",
|
|
||||||
"Tests snl(3) parsing nested VF status");
|
|
||||||
atf_tc_set_md_var(tc, "require.kmods", "netlink");
|
|
||||||
}
|
|
||||||
|
|
||||||
ATF_TC_BODY(snl_parse_vf_status, tc)
|
|
||||||
{
|
|
||||||
static const uint8_t mac[] = { 0x02, 0, 0, 0, 0, 1 };
|
|
||||||
static const uint8_t extension_data[] = { 1, 2, 3, 4 };
|
|
||||||
struct snl_parsed_vf_extension *extension;
|
|
||||||
struct snl_parsed_vf_status *status;
|
|
||||||
struct snl_parsed_link link = {};
|
|
||||||
struct snl_parsed_vf *vf;
|
|
||||||
struct snl_state ss;
|
|
||||||
struct snl_writer nw;
|
|
||||||
struct nlmsghdr *hdr;
|
|
||||||
int entry_off, extension_off, extensions_off, fbsd_off, list_off;
|
|
||||||
int status_off;
|
|
||||||
|
|
||||||
ATF_REQUIRE(snl_init(&ss, NETLINK_ROUTE));
|
|
||||||
snl_init_writer(&ss, &nw);
|
|
||||||
hdr = snl_create_msg_request(&nw, RTM_NEWLINK);
|
|
||||||
ATF_REQUIRE(hdr != NULL);
|
|
||||||
ATF_REQUIRE(snl_reserve_msg_object(&nw, struct ifinfomsg) != NULL);
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_u32(&nw, IFLA_NUM_VF, 1));
|
|
||||||
|
|
||||||
fbsd_off = snl_add_msg_attr_nested(&nw, IFLA_FREEBSD);
|
|
||||||
ATF_REQUIRE(fbsd_off != 0);
|
|
||||||
status_off = snl_add_msg_attr_nested(&nw, IFLAF_VF_STATUS);
|
|
||||||
ATF_REQUIRE(status_off != 0);
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_u32(&nw, IFLAF_VFS_VERSION, 1));
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_u8(&nw, IFLAF_VFS_PF_LINK_STATE,
|
|
||||||
IFLAF_VF_LINK_UP));
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_u64(&nw, IFLAF_VFS_PF_LINK_SPEED,
|
|
||||||
10000000000ULL));
|
|
||||||
|
|
||||||
list_off = snl_add_msg_attr_nested(&nw, IFLAF_VFS_LIST);
|
|
||||||
ATF_REQUIRE(list_off != 0);
|
|
||||||
entry_off = snl_add_msg_attr_nested(&nw, IFLAF_VF_LIST_ENTRY);
|
|
||||||
ATF_REQUIRE(entry_off != 0);
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_u32(&nw, IFLAF_VF_INDEX, 7));
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_u8(&nw, IFLAF_VF_CONFIGURED, 1));
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr(&nw, IFLAF_VF_MAC, sizeof(mac), mac));
|
|
||||||
|
|
||||||
extensions_off = snl_add_msg_attr_nested(&nw,
|
|
||||||
IFLAF_VF_EXTENSIONS);
|
|
||||||
ATF_REQUIRE(extensions_off != 0);
|
|
||||||
extension_off = snl_add_msg_attr_nested(&nw,
|
|
||||||
IFLAF_VF_EXT_LIST_ENTRY);
|
|
||||||
ATF_REQUIRE(extension_off != 0);
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr_string(&nw, IFLAF_VF_EXT_NAME,
|
|
||||||
"driver.test"));
|
|
||||||
ATF_REQUIRE(snl_add_msg_attr(&nw, IFLAF_VF_EXT_DATA,
|
|
||||||
sizeof(extension_data), extension_data));
|
|
||||||
snl_end_attr_nested(&nw, extension_off);
|
|
||||||
snl_end_attr_nested(&nw, extensions_off);
|
|
||||||
snl_end_attr_nested(&nw, entry_off);
|
|
||||||
snl_end_attr_nested(&nw, list_off);
|
|
||||||
snl_end_attr_nested(&nw, status_off);
|
|
||||||
snl_end_attr_nested(&nw, fbsd_off);
|
|
||||||
ATF_REQUIRE(snl_finalize_msg(&nw) != NULL);
|
|
||||||
|
|
||||||
ATF_REQUIRE(snl_parse_nlmsg(&ss, hdr, &snl_rtm_link_parser, &link));
|
|
||||||
ATF_CHECK_EQ(link.ifla_num_vf, 1);
|
|
||||||
status = &link.iflaf_vf_status;
|
|
||||||
ATF_CHECK_EQ(status->version, 1);
|
|
||||||
ATF_CHECK_EQ(status->pf_link_state, IFLAF_VF_LINK_UP);
|
|
||||||
ATF_CHECK_EQ(status->pf_link_speed, 10000000000ULL);
|
|
||||||
ATF_REQUIRE_EQ(status->vfs.count, 1);
|
|
||||||
vf = status->vfs.items[0];
|
|
||||||
ATF_CHECK_EQ(vf->index, 7);
|
|
||||||
ATF_CHECK_EQ(vf->configured, 1);
|
|
||||||
ATF_REQUIRE(vf->mac != NULL);
|
|
||||||
ATF_CHECK_EQ(NLA_DATA_LEN(vf->mac), sizeof(mac));
|
|
||||||
ATF_CHECK(memcmp(NLA_DATA(vf->mac), mac, sizeof(mac)) == 0);
|
|
||||||
ATF_REQUIRE_EQ(vf->extensions.count, 1);
|
|
||||||
extension = vf->extensions.items[0];
|
|
||||||
ATF_CHECK_STREQ(extension->name, "driver.test");
|
|
||||||
ATF_REQUIRE(extension->data != NULL);
|
|
||||||
ATF_CHECK_EQ(NLA_DATA_LEN(extension->data), sizeof(extension_data));
|
|
||||||
ATF_CHECK(memcmp(NLA_DATA(extension->data), extension_data,
|
|
||||||
sizeof(extension_data)) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ATF_TC(snl_verify_route_parsers);
|
ATF_TC(snl_verify_route_parsers);
|
||||||
ATF_TC_HEAD(snl_verify_route_parsers, tc)
|
ATF_TC_HEAD(snl_verify_route_parsers, tc)
|
||||||
{
|
{
|
||||||
@@ -319,7 +231,6 @@ ATF_TP_ADD_TCS(tp)
|
|||||||
{
|
{
|
||||||
ATF_TP_ADD_TC(tp, snl_verify_core_parsers);
|
ATF_TP_ADD_TC(tp, snl_verify_core_parsers);
|
||||||
ATF_TP_ADD_TC(tp, snl_verify_route_parsers);
|
ATF_TP_ADD_TC(tp, snl_verify_route_parsers);
|
||||||
ATF_TP_ADD_TC(tp, snl_parse_vf_status);
|
|
||||||
ATF_TP_ADD_TC(tp, snl_parse_errmsg_capped);
|
ATF_TP_ADD_TC(tp, snl_parse_errmsg_capped);
|
||||||
ATF_TP_ADD_TC(tp, snl_parse_errmsg_capped_extack);
|
ATF_TP_ADD_TC(tp, snl_parse_errmsg_capped_extack);
|
||||||
ATF_TP_ADD_TC(tp, snl_parse_errmsg_uncapped_extack);
|
ATF_TP_ADD_TC(tp, snl_parse_errmsg_uncapped_extack);
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ CRUNCH_SRCDIRS+= sbin
|
|||||||
CRUNCH_LIBS+= -l80211 -lalias -lcam -lcursesw -ldevstat -lipsec
|
CRUNCH_LIBS+= -l80211 -lalias -lcam -lcursesw -ldevstat -lipsec
|
||||||
# Don't forget this - ifconfig, etc -adrian
|
# Don't forget this - ifconfig, etc -adrian
|
||||||
CRUNCH_LIBS+= ${OBJTOP}/lib/libifconfig/libifconfig.a
|
CRUNCH_LIBS+= ${OBJTOP}/lib/libifconfig/libifconfig.a
|
||||||
CRUNCH_LIBS+= -lnv
|
|
||||||
CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lsbuf -lufs
|
CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lsbuf -lufs
|
||||||
CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
|
CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ CRUNCH_LIBS+= -lmemstat -lnetgraph
|
|||||||
|
|
||||||
# ifconfig
|
# ifconfig
|
||||||
CRUNCH_PROGS_sbin+= ifconfig
|
CRUNCH_PROGS_sbin+= ifconfig
|
||||||
|
CRUNCH_LIBS_ifconfig+= ${LIBNV}
|
||||||
CRUNCH_SHLIBS+= -l80211
|
CRUNCH_SHLIBS+= -l80211
|
||||||
|
|
||||||
# wlan stuff
|
# wlan stuff
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 8, 2026
|
.Dd August 10, 2026
|
||||||
.Dt IOVCTL 8
|
.Dt IOVCTL 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -131,18 +131,10 @@ to stdout.
|
|||||||
This action may be used to discover the configuration parameters supported on
|
This action may be used to discover the configuration parameters supported on
|
||||||
a given PF device.
|
a given PF device.
|
||||||
.El
|
.El
|
||||||
.Pp
|
|
||||||
For network devices, use
|
|
||||||
.Xr ifconfig 8
|
|
||||||
with the
|
|
||||||
.Fl v
|
|
||||||
option on the PF interface to display NIC-specific VF initialization,
|
|
||||||
resource, and policy state.
|
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr vmm 4 ,
|
.Xr vmm 4 ,
|
||||||
.Xr iovctl.conf 5 ,
|
.Xr iovctl.conf 5 ,
|
||||||
.Xr rc.conf 5 ,
|
.Xr rc.conf 5
|
||||||
.Xr ifconfig 8
|
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
This manual page was written by
|
This manual page was written by
|
||||||
.An Ryan Stone Aq Mt [email protected] .
|
.An Ryan Stone Aq Mt [email protected] .
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 8, 2026
|
.Dd August 10, 2026
|
||||||
.Dt IOVCTL.CONF 5
|
.Dt IOVCTL.CONF 5
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -145,14 +145,7 @@ After creating VFs, display their PCI attachment and passthrough state with:
|
|||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
iovctl -L -d ix0
|
iovctl -L -d ix0
|
||||||
.Ed
|
.Ed
|
||||||
For network devices, display NIC-specific initialization, resources, and
|
|
||||||
policy state with:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
ifconfig -v ix0
|
|
||||||
.Ed
|
|
||||||
See
|
See
|
||||||
.Xr ifconfig 8
|
|
||||||
and
|
|
||||||
.Xr iovctl 8
|
.Xr iovctl 8
|
||||||
for the meaning of the reported fields.
|
for the meaning of the reported fields.
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
@@ -181,7 +174,6 @@ VF-0 {
|
|||||||
.Ed
|
.Ed
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr rc.conf 5 ,
|
.Xr rc.conf 5 ,
|
||||||
.Xr ifconfig 8 ,
|
|
||||||
.Xr iovctl 8
|
.Xr iovctl 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
This manual page was written by
|
This manual page was written by
|
||||||
|
|||||||
Reference in new issue
Block a user