diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-07 17:00:53 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-07 17:00:53 +0200 |
commit | d5342a1ad13be16eaf6b78fe57e36679406ef85e (patch) | |
tree | dceb600732d4ecddce49a8f6aa5f04036810b14f | |
parent | 1140bf39ab113aefee8079755fac618bf6314db6 (diff) | |
download | busybox-w32-d5342a1ad13be16eaf6b78fe57e36679406ef85e.tar.gz busybox-w32-d5342a1ad13be16eaf6b78fe57e36679406ef85e.tar.bz2 busybox-w32-d5342a1ad13be16eaf6b78fe57e36679406ef85e.zip |
iproute: support advmss option
function old new delta
iproute_modify 1164 1221 +57
str_is_lock - 22 +22
packed_usage 31372 31382 +10
do_iproute 157 132 -25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 89/-25) Total: 64 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ip.c | 2 | ||||
-rw-r--r-- | networking/libiproute/iproute.c | 31 |
2 files changed, 20 insertions, 13 deletions
diff --git a/networking/ip.c b/networking/ip.c index 155adcfe4..0d66d5319 100644 --- a/networking/ip.c +++ b/networking/ip.c | |||
@@ -171,7 +171,7 @@ | |||
171 | //usage: " NODE_SPEC := PREFIX"IF_FEATURE_IP_RULE(" [table TABLE_ID]")" [proto RTPROTO] [scope SCOPE] [metric METRIC]\n" | 171 | //usage: " NODE_SPEC := PREFIX"IF_FEATURE_IP_RULE(" [table TABLE_ID]")" [proto RTPROTO] [scope SCOPE] [metric METRIC]\n" |
172 | //usage: " INFO_SPEC := NH OPTIONS\n" | 172 | //usage: " INFO_SPEC := NH OPTIONS\n" |
173 | //usage: " NH := [via [inet|inet6] ADDRESS] [dev IFACE] [src ADDRESS] [onlink]\n" | 173 | //usage: " NH := [via [inet|inet6] ADDRESS] [dev IFACE] [src ADDRESS] [onlink]\n" |
174 | //usage: " OPTIONS := [mtu NUM]" | 174 | //usage: " OPTIONS := [mtu [lock] NUM] [advmss [lock] NUM]" |
175 | //upstream man ip-route: | 175 | //upstream man ip-route: |
176 | //====================== | 176 | //====================== |
177 | //ip route { show | flush } SELECTOR | 177 | //ip route { show | flush } SELECTOR |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 62fa6efd3..fa616f8fc 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -322,17 +322,25 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, | |||
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
324 | 324 | ||
325 | static int str_is_lock(const char *str) | ||
326 | { | ||
327 | return strcmp(str, "lock") == 0; | ||
328 | } | ||
329 | |||
325 | /* Return value becomes exitcode. It's okay to not return at all */ | 330 | /* Return value becomes exitcode. It's okay to not return at all */ |
326 | static int iproute_modify(int cmd, unsigned flags, char **argv) | 331 | static int iproute_modify(int cmd, unsigned flags, char **argv) |
327 | { | 332 | { |
328 | /* If you add stuff here, update iproute_full_usage */ | 333 | /* If you add stuff here, update iproute_full_usage */ |
329 | static const char keywords[] ALIGN1 = | 334 | static const char keywords[] ALIGN1 = |
330 | "src\0""via\0""mtu\0""scope\0""protocol\0"IF_FEATURE_IP_RULE("table\0") | 335 | "src\0""via\0" |
336 | "mtu\0""advmss\0" | ||
337 | "scope\0""protocol\0"IF_FEATURE_IP_RULE("table\0") | ||
331 | "dev\0""oif\0""to\0""metric\0""onlink\0"; | 338 | "dev\0""oif\0""to\0""metric\0""onlink\0"; |
332 | enum { | 339 | enum { |
333 | ARG_src, | 340 | ARG_src, |
334 | ARG_via, | 341 | ARG_via, |
335 | ARG_mtu, | 342 | ARG_mtu, |
343 | ARG_advmss, | ||
336 | ARG_scope, | 344 | ARG_scope, |
337 | ARG_protocol, | 345 | ARG_protocol, |
338 | IF_FEATURE_IP_RULE(ARG_table,) | 346 | IF_FEATURE_IP_RULE(ARG_table,) |
@@ -405,12 +413,21 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
405 | } else if (arg == ARG_mtu) { | 413 | } else if (arg == ARG_mtu) { |
406 | unsigned mtu; | 414 | unsigned mtu; |
407 | NEXT_ARG(); | 415 | NEXT_ARG(); |
408 | if (strcmp(*argv, "lock") == 0) { | 416 | if (str_is_lock(*argv)) { |
409 | mxlock |= (1 << RTAX_MTU); | 417 | mxlock |= (1 << RTAX_MTU); |
410 | NEXT_ARG(); | 418 | NEXT_ARG(); |
411 | } | 419 | } |
412 | mtu = get_unsigned(*argv, "mtu"); | 420 | mtu = get_unsigned(*argv, "mtu"); |
413 | rta_addattr32(mxrta, sizeof(mxbuf), RTAX_MTU, mtu); | 421 | rta_addattr32(mxrta, sizeof(mxbuf), RTAX_MTU, mtu); |
422 | } else if (arg == ARG_advmss) { | ||
423 | unsigned mss; | ||
424 | NEXT_ARG(); | ||
425 | if (str_is_lock(*argv)) { | ||
426 | mxlock |= (1 << RTAX_ADVMSS); | ||
427 | NEXT_ARG(); | ||
428 | } | ||
429 | mss = get_unsigned(*argv, "advmss"); | ||
430 | rta_addattr32(mxrta, sizeof(mxbuf), RTAX_ADVMSS, mss); | ||
414 | } else if (arg == ARG_scope) { | 431 | } else if (arg == ARG_scope) { |
415 | uint32_t scope; | 432 | uint32_t scope; |
416 | NEXT_ARG(); | 433 | NEXT_ARG(); |
@@ -505,16 +522,6 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
505 | if (get_unsigned(&hoplimit, *argv, 0)) | 522 | if (get_unsigned(&hoplimit, *argv, 0)) |
506 | invarg("\"hoplimit\" value is invalid\n", *argv); | 523 | invarg("\"hoplimit\" value is invalid\n", *argv); |
507 | rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplimit); | 524 | rta_addattr32(mxrta, sizeof(mxbuf), RTAX_HOPLIMIT, hoplimit); |
508 | } else if (strcmp(*argv, "advmss") == 0) { | ||
509 | unsigned mss; | ||
510 | NEXT_ARG(); | ||
511 | if (strcmp(*argv, "lock") == 0) { | ||
512 | mxlock |= (1<<RTAX_ADVMSS); | ||
513 | NEXT_ARG(); | ||
514 | } | ||
515 | if (get_unsigned(&mss, *argv, 0)) | ||
516 | invarg("\"mss\" value is invalid\n", *argv); | ||
517 | rta_addattr32(mxrta, sizeof(mxbuf), RTAX_ADVMSS, mss); | ||
518 | } else if (matches(*argv, "reordering") == 0) { | 525 | } else if (matches(*argv, "reordering") == 0) { |
519 | unsigned reord; | 526 | unsigned reord; |
520 | NEXT_ARG(); | 527 | NEXT_ARG(); |