X Tutup
Skip to content

Commit dca0a4e

Browse files
committed
network: macvlan - add support to configure rx queue for broadcast/multicast
1 parent 7e27a74 commit dca0a4e

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
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/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