Skip to content

Commit 42f5642

Browse files
tkarlsdsahern
authored andcommitted
iplink:macvlan: Added bcqueuelen parameter
This patch allows the user to set and retrieve the IFLA_MACVLAN_BC_QUEUE_LEN parameter via the bcqueuelen command line argument This parameter controls the requested size of the queue for broadcast and multicast packages in the macvlan driver. If not specified, the driver default (1000) will be used. Note: The request is per macvlan but the actually used queue length per port is the maximum of any request to any macvlan connected to the same port. For this reason, the used queue length IFLA_MACVLAN_BC_QUEUE_LEN_USED is also retrieved and displayed in order to aid in the understanding of the setting. However, it can of course not be directly set. Signed-off-by: Thomas Karlsson <[email protected]> Signed-off-by: David Ahern <[email protected]>
1 parent ee50fd5 commit 42f5642

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

ip/iplink_macvlan.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
static void print_explain(struct link_util *lu, FILE *f)
3131
{
3232
fprintf(f,
33-
"Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS\n"
33+
"Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN]\n"
3434
"\n"
3535
"MODE: private | vepa | bridge | passthru | source\n"
3636
"MODE_FLAG: null | nopromisc\n"
3737
"MODE_OPTS: for mode \"source\":\n"
38-
"\tmacaddr { { add | del } <macaddr> | set [ <macaddr> [ <macaddr> ... ] ] | flush }\n",
38+
"\tmacaddr { { add | del } <macaddr> | set [ <macaddr> [ <macaddr> ... ] ] | flush }\n"
39+
"BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n",
3940
lu->id
4041
);
4142
}
@@ -62,6 +63,14 @@ static int flag_arg(const char *arg)
6263
return -1;
6364
}
6465

66+
static int bc_queue_len_arg(const char *arg)
67+
{
68+
fprintf(stderr,
69+
"Error: argument of \"bcqueuelen\" must be a positive integer [0-4294967295], not \"%s\"\n",
70+
arg);
71+
return -1;
72+
}
73+
6574
static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
6675
struct nlmsghdr *n)
6776
{
@@ -150,6 +159,14 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
150159
} else if (matches(*argv, "nopromisc") == 0) {
151160
flags |= MACVLAN_FLAG_NOPROMISC;
152161
has_flags = 1;
162+
} else if (matches(*argv, "bcqueuelen") == 0) {
163+
__u32 bc_queue_len;
164+
NEXT_ARG();
165+
166+
if (get_u32(&bc_queue_len, *argv, 0)) {
167+
return bc_queue_len_arg(*argv);
168+
}
169+
addattr32(n, 1024, IFLA_MACVLAN_BC_QUEUE_LEN, bc_queue_len);
153170
} else if (matches(*argv, "help") == 0) {
154171
explain(lu);
155172
return -1;
@@ -212,6 +229,18 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
212229
if (flags & MACVLAN_FLAG_NOPROMISC)
213230
print_bool(PRINT_ANY, "nopromisc", "nopromisc ", true);
214231

232+
if (tb[IFLA_MACVLAN_BC_QUEUE_LEN] &&
233+
RTA_PAYLOAD(tb[IFLA_MACVLAN_BC_QUEUE_LEN]) >= sizeof(__u32)) {
234+
__u32 bc_queue_len = rta_getattr_u32(tb[IFLA_MACVLAN_BC_QUEUE_LEN]);
235+
print_luint(PRINT_ANY, "bcqueuelen", "bcqueuelen %lu ", bc_queue_len);
236+
}
237+
238+
if (tb[IFLA_MACVLAN_BC_QUEUE_LEN_USED] &&
239+
RTA_PAYLOAD(tb[IFLA_MACVLAN_BC_QUEUE_LEN_USED]) >= sizeof(__u32)) {
240+
__u32 bc_queue_len = rta_getattr_u32(tb[IFLA_MACVLAN_BC_QUEUE_LEN_USED]);
241+
print_luint(PRINT_ANY, "usedbcqueuelen", "usedbcqueuelen %lu ", bc_queue_len);
242+
}
243+
215244
/* in source mode, there are more options to print */
216245

217246
if (mode != MACVLAN_MODE_SOURCE)

man/man8/ip-link.8.in

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,7 @@ the following additional arguments are supported:
13521352
.BR type " { " macvlan " | " macvtap " } "
13531353
.BR mode " { " private " | " vepa " | " bridge " | " passthru
13541354
.RB " [ " nopromisc " ] | " source " } "
1355+
.RB " [ " bcqueuelen " { " LENGTH " } ] "
13551356

13561357
.in +8
13571358
.sp
@@ -1395,6 +1396,18 @@ against source mac address from received frames on underlying interface. This
13951396
allows creating mac based VLAN associations, instead of standard port or tag
13961397
based. The feature is useful to deploy 802.1x mac based behavior,
13971398
where drivers of underlying interfaces doesn't allows that.
1399+
1400+
.BR bcqueuelen " { " LENGTH " } "
1401+
- Set the length of the RX queue used to process broadcast and multicast packets.
1402+
.BR LENGTH " must be a positive integer in the range [0-4294967295]."
1403+
Setting a length of 0 will effectively drop all broadcast/multicast traffic.
1404+
If not specified the macvlan driver default (1000) is used.
1405+
Note that all macvlans that share the same underlying device are using the same
1406+
.RB "queue. The parameter here is a " request ", the actual queue length used"
1407+
will be the maximum length that any macvlan interface has requested.
1408+
When listing device parameters both the bcqueuelen parameter
1409+
as well as the actual used bcqueuelen are listed to better help
1410+
the user understand the setting.
13981411
.in -8
13991412

14001413
.TP
@@ -2451,6 +2464,26 @@ Commands:
24512464
.sp
24522465
.in -8
24532466

2467+
Update the broadcast/multicast queue length.
2468+
2469+
.B "ip link set type { macvlan | macvap } "
2470+
[
2471+
.BI bcqueuelen " LENGTH "
2472+
]
2473+
2474+
.in +8
2475+
.BI bcqueuelen " LENGTH "
2476+
- Set the length of the RX queue used to process broadcast and multicast packets.
2477+
.IR LENGTH " must be a positive integer in the range [0-4294967295]."
2478+
Setting a length of 0 will effectively drop all broadcast/multicast traffic.
2479+
If not specified the macvlan driver default (1000) is used.
2480+
Note that all macvlans that share the same underlying device are using the same
2481+
.RB "queue. The parameter here is a " request ", the actual queue length used"
2482+
will be the maximum length that any macvlan interface has requested.
2483+
When listing device parameters both the bcqueuelen parameter
2484+
as well as the actual used bcqueuelen are listed to better help
2485+
the user understand the setting.
2486+
.in -8
24542487

24552488
.SS ip link show - display device attributes
24562489

0 commit comments

Comments
 (0)