mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
util: define virNetDevRxFilter and basic utility functions
This same structure will be used to retrieve RX filter info for interfaces on the host via netlink messages, and RX filter info for interfaces on the guest via the qemu "query-rx-filter" command.
This commit is contained in:
parent
cfddf59cee
commit
aa7c595a31
@ -1615,6 +1615,10 @@ virNetDevReplaceMacAddress;
|
|||||||
virNetDevReplaceNetConfig;
|
virNetDevReplaceNetConfig;
|
||||||
virNetDevRestoreMacAddress;
|
virNetDevRestoreMacAddress;
|
||||||
virNetDevRestoreNetConfig;
|
virNetDevRestoreNetConfig;
|
||||||
|
virNetDevRxFilterFree;
|
||||||
|
virNetDevRxFilterModeTypeFromString;
|
||||||
|
virNetDevRxFilterModeTypeToString;
|
||||||
|
virNetDevRxFilterNew;
|
||||||
virNetDevSetIPv4Address;
|
virNetDevSetIPv4Address;
|
||||||
virNetDevSetMAC;
|
virNetDevSetMAC;
|
||||||
virNetDevSetMTU;
|
virNetDevSetMTU;
|
||||||
|
@ -1932,3 +1932,34 @@ virNetDevGetLinkInfo(const char *ifname,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* defined(__linux__) */
|
#endif /* defined(__linux__) */
|
||||||
|
|
||||||
|
|
||||||
|
VIR_ENUM_IMPL(virNetDevRxFilterMode,
|
||||||
|
VIR_NETDEV_RX_FILTER_MODE_LAST,
|
||||||
|
"none",
|
||||||
|
"normal",
|
||||||
|
"all");
|
||||||
|
|
||||||
|
|
||||||
|
virNetDevRxFilterPtr
|
||||||
|
virNetDevRxFilterNew(void)
|
||||||
|
{
|
||||||
|
virNetDevRxFilterPtr filter;
|
||||||
|
|
||||||
|
if (VIR_ALLOC(filter) < 0)
|
||||||
|
return NULL;
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNetDevRxFilterFree(virNetDevRxFilterPtr filter)
|
||||||
|
{
|
||||||
|
if (filter) {
|
||||||
|
VIR_FREE(filter->name);
|
||||||
|
VIR_FREE(filter->unicast.table);
|
||||||
|
VIR_FREE(filter->multicast.table);
|
||||||
|
VIR_FREE(filter->vlan.table);
|
||||||
|
VIR_FREE(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2007-2013 Red Hat, Inc.
|
* Copyright (C) 2007-2014 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -37,6 +37,42 @@ typedef struct ifreq virIfreq;
|
|||||||
typedef void virIfreq;
|
typedef void virIfreq;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_NETDEV_RX_FILTER_MODE_NONE = 0,
|
||||||
|
VIR_NETDEV_RX_FILTER_MODE_NORMAL,
|
||||||
|
VIR_NETDEV_RX_FILTER_MODE_ALL,
|
||||||
|
|
||||||
|
VIR_NETDEV_RX_FILTER_MODE_LAST
|
||||||
|
} virNetDevRxFilterMode;
|
||||||
|
VIR_ENUM_DECL(virNetDevRxFilterMode)
|
||||||
|
|
||||||
|
typedef struct _virNetDevRxFilter virNetDevRxFilter;
|
||||||
|
typedef virNetDevRxFilter *virNetDevRxFilterPtr;
|
||||||
|
struct _virNetDevRxFilter {
|
||||||
|
char *name; /* the alias used by qemu, *not* name used by guest */
|
||||||
|
virMacAddr mac;
|
||||||
|
bool promiscuous;
|
||||||
|
bool broadcastAllowed;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int mode; /* enum virNetDevRxFilterMode */
|
||||||
|
bool overflow;
|
||||||
|
virMacAddrPtr table;
|
||||||
|
size_t nTable;
|
||||||
|
} unicast;
|
||||||
|
struct {
|
||||||
|
int mode; /* enum virNetDevRxFilterMode */
|
||||||
|
bool overflow;
|
||||||
|
virMacAddrPtr table;
|
||||||
|
size_t nTable;
|
||||||
|
} multicast;
|
||||||
|
struct {
|
||||||
|
int mode; /* enum virNetDevRxFilterMode */
|
||||||
|
unsigned int *table;
|
||||||
|
size_t nTable;
|
||||||
|
} vlan;
|
||||||
|
};
|
||||||
|
|
||||||
int virNetDevSetupControl(const char *ifname,
|
int virNetDevSetupControl(const char *ifname,
|
||||||
virIfreq *ifr)
|
virIfreq *ifr)
|
||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
@ -150,4 +186,8 @@ int virNetDevGetLinkInfo(const char *ifname,
|
|||||||
virInterfaceLinkPtr lnk)
|
virInterfaceLinkPtr lnk)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
|
virNetDevRxFilterPtr virNetDevRxFilterNew(void)
|
||||||
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
void virNetDevRxFilterFree(virNetDevRxFilterPtr filter);
|
||||||
|
|
||||||
#endif /* __VIR_NETDEV_H__ */
|
#endif /* __VIR_NETDEV_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user