X Tutup
Skip to content

Commit f9ead1a

Browse files
authored
Merge pull request systemd#18230 from ssahani/macvlan-bcqueuelen
network: macvlan - add support to configure rx queue for broadcast / multicast
2 parents 3dc536e + dca0a4e commit f9ead1a

File tree

8 files changed

+79
-6
lines changed

8 files changed

+79
-6
lines changed

man/systemd.netdev.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,13 @@
546546
to this is reset. Defaults to unset.</para>
547547
</listitem>
548548
</varlistentry>
549+
<varlistentry>
550+
<term><varname>BroadcastMulticastQueueLength=</varname></term>
551+
<listitem>
552+
<para>Specifies the length of the receive queue for broadcast/multicast packets. An unsigned
553+
integer in the range 0—4294967294. Defaults to unset.</para>
554+
</listitem>
555+
</varlistentry>
549556
</variablelist>
550557
</refsect1>
551558

src/basic/linux/if_link.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ struct rtnl_link_stats {
7575
*
7676
* @rx_dropped: Number of packets received but not processed,
7777
* e.g. due to lack of resources or unsupported protocol.
78-
* For hardware interfaces this counter should not include packets
79-
* dropped by the device which are counted separately in
78+
* For hardware interfaces this counter may include packets discarded
79+
* due to L2 address filtering but should not include packets dropped
80+
* by the device due to buffer exhaustion which are counted separately in
8081
* @rx_missed_errors (since procfs folds those two counters together).
8182
*
8283
* @tx_dropped: Number of packets dropped on their way to transmission,
@@ -588,6 +589,8 @@ enum {
588589
IFLA_MACVLAN_MACADDR,
589590
IFLA_MACVLAN_MACADDR_DATA,
590591
IFLA_MACVLAN_MACADDR_COUNT,
592+
IFLA_MACVLAN_BC_QUEUE_LEN,
593+
IFLA_MACVLAN_BC_QUEUE_LEN_USED,
591594
__IFLA_MACVLAN_MAX,
592595
};
593596

src/libsystemd/sd-netlink/netlink-types.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,13 @@ static const NLTypeSystem rtnl_macvlan_macaddr_type_system = {
105105
};
106106

107107
static const NLType rtnl_link_info_data_macvlan_types[] = {
108-
[IFLA_MACVLAN_MODE] = { .type = NETLINK_TYPE_U32 },
109-
[IFLA_MACVLAN_FLAGS] = { .type = NETLINK_TYPE_U16 },
110-
[IFLA_MACVLAN_MACADDR_MODE] = { .type = NETLINK_TYPE_U32 },
111-
[IFLA_MACVLAN_MACADDR_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_macvlan_macaddr_type_system },
108+
[IFLA_MACVLAN_MODE] = { .type = NETLINK_TYPE_U32 },
109+
[IFLA_MACVLAN_FLAGS] = { .type = NETLINK_TYPE_U16 },
110+
[IFLA_MACVLAN_MACADDR_MODE] = { .type = NETLINK_TYPE_U32 },
111+
[IFLA_MACVLAN_MACADDR_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_macvlan_macaddr_type_system },
112+
[IFLA_MACVLAN_MACADDR_COUNT] = { .type = NETLINK_TYPE_U32 },
113+
[IFLA_MACVLAN_BC_QUEUE_LEN] = { .type = NETLINK_TYPE_U32 },
114+
[IFLA_MACVLAN_BC_QUEUE_LEN_USED] = { .type = NETLINK_TYPE_REJECT },
112115
};
113116

114117
static const NLType rtnl_link_info_data_bridge_types[] = {

src/libsystemd/sd-netlink/netlink-types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ enum {
2222
NETLINK_TYPE_UNION,
2323
NETLINK_TYPE_SOCKADDR,
2424
NETLINK_TYPE_BINARY,
25+
NETLINK_TYPE_BITFIELD32, /* NLA_BITFIELD32 */
26+
NETLINK_TYPE_REJECT, /* NLA_REJECT */
2527
};
2628

2729
typedef enum NLMatchType {

src/network/netdev/macvlan.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "conf-parser.h"
66
#include "macvlan.h"
77
#include "macvlan-util.h"
8+
#include "parse-util.h"
89

910
DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode");
1011

@@ -51,6 +52,57 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net
5152
return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_MODE attribute: %m");
5253
}
5354

55+
if (m->bc_queue_length != UINT32_MAX) {
56+
r = sd_netlink_message_append_u32(req, IFLA_MACVLAN_BC_QUEUE_LEN, m->bc_queue_length);
57+
if (r < 0)
58+
return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_BC_QUEUE_LEN attribute: %m");
59+
}
60+
61+
return 0;
62+
}
63+
64+
int config_parse_macvlan_broadcast_queue_size(
65+
const char *unit,
66+
const char *filename,
67+
unsigned line,
68+
const char *section,
69+
unsigned section_line,
70+
const char *lvalue,
71+
int ltype,
72+
const char *rvalue,
73+
void *data,
74+
void *userdata) {
75+
76+
MacVlan *m = userdata;
77+
uint32_t v;
78+
int r;
79+
80+
assert(filename);
81+
assert(section);
82+
assert(lvalue);
83+
assert(rvalue);
84+
assert(data);
85+
assert(userdata);
86+
87+
if (isempty(rvalue)) {
88+
m->bc_queue_length = UINT32_MAX;
89+
return 0;
90+
}
91+
92+
r = safe_atou32(rvalue, &v);
93+
if (r < 0) {
94+
log_syntax(unit, LOG_WARNING, filename, line, r,
95+
"Failed to parse BroadcastMulticastQueueLength=%s, ignoring assignment: %m", rvalue);
96+
return 0;
97+
}
98+
99+
if (v == UINT32_MAX) {
100+
log_syntax(unit, LOG_WARNING, filename, line, 0,
101+
"Invalid BroadcastMulticastQueueLength=%s, ignoring assignment: %m", rvalue);
102+
return 0;
103+
}
104+
105+
m->bc_queue_length = v;
54106
return 0;
55107
}
56108

@@ -82,6 +134,7 @@ static void macvlan_init(NetDev *n) {
82134
assert(m);
83135

84136
m->mode = _NETDEV_MACVLAN_MODE_INVALID;
137+
m->bc_queue_length = UINT32_MAX;
85138
}
86139

87140
const NetDevVTable macvtap_vtable = {

src/network/netdev/macvlan.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ struct MacVlan {
1212

1313
MacVlanMode mode;
1414
Set *match_source_mac;
15+
16+
uint32_t bc_queue_length;
1517
};
1618

1719
DEFINE_NETDEV_CAST(MACVLAN, MacVlan);
@@ -20,3 +22,4 @@ extern const NetDevVTable macvlan_vtable;
2022
extern const NetDevVTable macvtap_vtable;
2123

2224
CONFIG_PARSER_PROTOTYPE(config_parse_macvlan_mode);
25+
CONFIG_PARSER_PROTOTYPE(config_parse_macvlan_broadcast_queue_size);

src/network/netdev/netdev-gperf.gperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ VLAN.EgressQOSMaps, config_parse_vlan_qos_maps,
5757
VLAN.IngressQOSMaps, config_parse_vlan_qos_maps, 0, offsetof(VLan, ingress_qos_maps)
5858
MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
5959
MACVLAN.SourceMACAddress, config_parse_hwaddrs, 0, offsetof(MacVlan, match_source_mac)
60+
MACVLAN.BroadcastMulticastQueueLength, config_parse_macvlan_broadcast_queue_size, 0, offsetof(MacVlan, bc_queue_length)
6061
MACVTAP.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
6162
MACVTAP.SourceMACAddress, config_parse_hwaddrs, 0, offsetof(MacVlan, match_source_mac)
6263
IPVLAN.Mode, config_parse_ipvlan_mode, 0, offsetof(IPVlan, mode)

test/fuzz/fuzz-netdev-parser/directives.netdev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ IngressQOSMaps=
1010
[MACVLAN]
1111
Mode=
1212
SourceMACAddress=
13+
BroadcastMulticastQueueLength=
1314
[WireGuard]
1415
ListenPort=
1516
PrivateKey=

0 commit comments

Comments
 (0)
X Tutup