lag: say what the command takes, and delete only when asked

Two small things about the same command.

The usage line offered "lag <1-4> [port]...", which leaves out "lag show" even
though that is the only way to see the groups, so the one subcommand a reader
most needs is the one the error does not mention.

And a group number with no ports after it quietly wiped the group. That is a
reasonable thing to want and an unreasonable thing to do by accident, as it is
one fat-fingered return away from a bare "lag 1". It now takes "lag 1 delete"
or "lag 1 d", and a bare group number prints the usage instead.

Nothing changes for a saved configuration: "lag 1 5 6" is what gets written and
what gets replayed, and neither the old bare form nor the new delete matches
the pattern that decides what is persisted.
This commit is contained in:
d00f committed 2026-09-05 13:28:15 +02:00
1 parent f2966ad248
commit ecac6d1934
1 file changed
+9 -3
+9 -3
View File
@@ -406,10 +406,16 @@ void parse_lag(void)
if (group > 3) if (group > 3)
goto err; goto err;
if (cmd_words_len == 2)
goto err;
if (cmd_compare(2, "delete") || cmd_compare(2, "d")) {
port_lag_members_set(group, 0);
return;
}
uint8_t w = 2; uint8_t w = 2;
while (w < cmd_words_len) { while (w < cmd_words_len) {
// write_char('|'); print_byte(w); write_char(':'); write_char(cmd_buffer[cmd_words_b[w]]); write_char('-');
// Parse port. // Parse port.
if (cmd_parse_port_separator(cmd_words_b[w++]) == 0) if (cmd_parse_port_separator(cmd_words_b[w++]) == 0)
goto err; goto err;
@@ -419,7 +425,7 @@ void parse_lag(void)
port_lag_members_set(group, members); port_lag_members_set(group, members);
return; return;
err: err:
print_string("Error: lag <1-4> [port]...\n"); print_string("Error: lag (show | <1-4> (delete | <port>...))\n");
} }