aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/libnetlink.c
AgeCommit message (Collapse)Author
2019-07-02libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-22ip: use rtnl_send_check() on flush commands, closes 6962Denys Vlasenko
function old new delta rtnl_send_check - 160 +160 xrtnl_wilddump_request 64 66 +2 ipneigh_list_or_flush 714 706 -8 rtnl_send 69 - -69 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 1/1 up/down: 162/-77) Total: 85 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-11libbb: introduce and use bb_getsockname()Denys Vlasenko
function old new delta bb_getsockname - 18 +18 xrtnl_open 88 83 -5 do_iplink 1216 1209 -7 arping_main 1686 1668 -18 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/3 up/down: 18/-30) Total: -12 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-08ip: fix crash in "ip neigh show"Denys Vlasenko
parse_rtattr() was using tb[] array without initializing it. Based on patch by Balaji Punnuru <balaji_punnuru@cable.comcast.com> function old new delta parse_rtattr 85 107 +22 print_route 1630 1617 -13 print_linkinfo 807 794 -13 iproute_get 835 822 -13 print_rule 680 665 -15 ll_remember_index 263 248 -15 print_addrinfo 1223 1197 -26 ipaddr_list_or_flush 1253 1223 -30 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/7 up/down: 22/-125) Total: -103 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05whitespace and comment format fixes, no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-18libnetlink: fix alignment of netlink messagesHauke Mehrtens
A padding to align a message should not only be added between different attributes of a netlink message, but also at the end of the message to pad it to the correct size. Without this patch the following command does not work and returns an error code: ip link add type nlmon Without this ip from busybox sends this: sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=45, ...}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon"}, iov_len=45}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 45 return value: 2 The normal ip utile from iproute2 sends this: sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=48, ...}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48 return value: 0 With this patch ip from busybox sends this: sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=48, ...}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48 return value: 0 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-14libiproute: eliminate some redundant zero storesDenys Vlasenko
function old new delta do_iprule 974 955 -19 rtnl_dump_request 173 146 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-46) Total: -46 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-24ip: fix problem on mips64 n64 big endian musl systemsSzabolcs Nagy
Use designated initializers for struct msghdr. The struct layout is non-portable and musl libc does not match what busybox expects. Signed-off-by: Szabolcs Nagy <nsz@port70.net> Tested-by: Waldemar Brodkorb <wbx@openadk.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-23iproute: fix parsing and matching of of "short" IP addrs like 10/8Denys Vlasenko
function old new delta print_route 1613 1813 +200 get_addr_1 209 258 +49 get_prefix 393 356 -37 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 249/-37) Total: 212 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-09iproute: fix handling of "dev IFACE" selectorDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-30networking/*: remove superfluous commentsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-29whitespace cleanupDenys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-07-23libnetlink: code shrinkNatanael Copa
function old new delta xrtnl_open 95 93 -2 parse_rtattr 87 85 -2 rtnl_close 9 - -9 xrtnl_wilddump_request 101 64 -37 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-50) Total: -50 bytes Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28*: style fixes. no code changes (verified with objdump)Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-13*: use "can't" instead of "cannot"Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05*: add FAST_FUNC to function ptrs where it makes senseDenys Vlasenko
function old new delta evalcommand 1195 1209 +14 testcmd - 10 +10 printfcmd - 10 +10 echocmd - 10 +10 func_exec 270 276 +6 echo_dg 104 109 +5 store_nlmsg 85 89 +4 pseudo_exec_argv 195 198 +3 dotcmd 287 290 +3 machtime_stream 29 31 +2 discard_stream 24 26 +2 argstr 1299 1301 +2 killcmd 108 109 +1 evalfor 226 227 +1 daytime_stream 43 44 +1 run_list 2544 2543 -1 lookupvar 62 61 -1 ipaddr_modify 1310 1309 -1 ... parse_stream 2254 2245 -9 evalpipe 356 347 -9 collect_if 210 197 -13 read_opt 869 851 -18 handle_dollar 681 658 -23 print_addrinfo 1342 1303 -39 iterate_on_dir 156 59 -97 print_route 1709 1609 -100 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 12/130 up/down: 74/-767) Total: -693 bytes text data bss dec hex filename 841748 467 7872 850087 cf8a7 busybox_old 841061 467 7872 849400 cf5f8 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-04-21*: remove check for errors on getsockaddr in cases we know they can't happenDenis Vlasenko
libbb: make get_sock_lsa use only one getsockaddr syscall, not two function old new delta get_sock_lsa 72 101 +29 do_iplink 1151 1137 -14 arping_main 1585 1569 -16 dolisten 789 755 -34 xrtnl_open 161 94 -67
2008-12-08optimize 16- and 32-bit movesDenis Vlasenko
function old new delta udhcpd_main 1239 1257 +18 udhcp_add_simple_option 93 92 -1 buffer_read_le_u32 19 18 -1 unpack_gz_stream_with_info 526 520 -6 dnsd_main 1470 1463 -7 udhcp_run_script 1208 1186 -22 send_ACK 255 229 -26 arping_main 1661 1623 -38 send_offer 470 428 -42 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/8 up/down: 18/-143) Total: -125 bytes
2008-07-21- first pass to unify/cleanup uid handling (-236b)Bernhard Reutner-Fischer
This needs further love, alot of love.. Tito?
2008-06-29libiproute: print_route() always uses stdout, do not pass FILE pointer to it.Denis Vlasenko
libiproute: Use FAST_FUNC function old new delta iprule_modify 884 905 +21 ipaddr_modify 1289 1310 +21 rtnl_send 53 69 +16 xrtnl_wilddump_request 109 124 +15 xrtnl_dump_filter 394 403 +9 rtnl_talk 534 539 +5 print_addrinfo 1369 1374 +5 iproute_modify 1017 1020 +3 iprule_list 81 83 +2 xrtnl_open 163 161 -2 parse_rtattr 89 87 -2 ipaddr_list_or_flush 2176 2174 -2 addattr_l 91 88 -3 flush_update 116 108 -8 iproute_list_or_flush 1285 1263 -22 iproute_get 878 852 -26 print_route 1913 1752 -161 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 9/8 up/down: 97/-226) Total: -129 bytes
2008-06-12- make the first arg of the filter function passed to rtnl_dump_filter constantBernhard Reutner-Fischer
to match normal iproute. No obj-code changes.
2008-05-15more of -Wall fixes from Cristian Ionescu-Idbohrn.Denis Vlasenko
Some are fixing real bugs. function old new delta syslogd_main 938 958 +20 get_signum 136 143 +7 obj_load 777 782 +5 recv_from_to 210 214 +4 get_next_block 1795 1799 +4 display_topmem_process_list 1117 1121 +4 logread_main 484 487 +3 buffer_fill_and_print 73 76 +3 kill_main 687 689 +2 ll_remember_index 240 241 +1 do_stats 452 453 +1 if_readconf 166 165 -1 display_process_list 1192 1191 -1 run_applet_and_exit 507 505 -2 print_signames 33 31 -2 parse_one_line 1092 1090 -2 find_out_spec 57 55 -2 add_ksymoops_symbols 421 419 -2 ash_main 1407 1402 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 11/8 up/down: 54/-17) Total: 37 bytes
2007-12-02libnetlink: comment out unused code; don't use 8k stack buffersDenis Vlasenko
function old new delta ipaddr_modify 1305 1297 -8 do_iprule 963 955 -8 do_iproute 2193 2169 -24 xrtnl_dump_filter 418 391 -27 rtnl_talk 671 536 -135 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-202) Total: -202 bytes
2007-05-31use "glibc errno" trick not only for ash, but for entire busyboxDenis Vlasenko
(add/remove: 1/1 grow/shrink: 37/37 up/down: 139/-228) Total: -89 bytes
2007-04-12- add xsendto and use where appropriate; shrink iplink; sanitize libiproute ↵Bernhard Reutner-Fischer
a bit. -916 byte
2006-12-31stop using __u32 etc. uint32_t is there for a reasonDenis Vlasenko
2006-11-21- add 'ip rule' support. First take..Bernhard Reutner-Fischer
text data bss dec hex filename 2999 0 0 2999 bb7 networking/libiproute/iprule.o
2006-10-27last nail into error_msg() (de)capitalizationDenis Vlasenko
2006-10-14add open_read_close() and similar stuffDenis Vlasenko
2006-07-02Standardize on the vi editing directives being on the first line."Robert P. J. Day"
2006-06-02Header cleanup: don't #include headers that libbb.h already includes.Rob Landley
2006-03-03Kill off some unused code that was wasting several k, as noticed byEric Andersen
Denis Vlasenko when building with -ffunction-sections -fdata-sections
2006-01-30sort out yet more type issuesEric Andersen
2004-05-05Steve Grubb writes:Eric Andersen
Hello, Last November a bug was found in iproute. CAN-2003-0856 has more information. Basically, netlink packets can come from any user. If a program performs action based on netlink packets, they must be examined to make sure they came from the place they are expected (the kernel). Attached is a patch against pre8. Please apply this before releasing 1.00 final. All users of busy box may be vulnerable to local attacks without it. Best Regards, Steve Grubb
2004-03-15Remove trailing whitespace. Update copyright to include 2004.Eric Andersen
2003-06-20Patch from Lars Kellogg-Stedman:Eric Andersen
I'm building BusyBox using a development kit for MontaVista Hardhat Linux (PPC) -- which, at least in this instance, is based around kernel 2.2.14. I've had to massage a few files in networking/libiproute/ to make it compile. Specifically: (1) Added a #include <sys/uio.h> for the iovec structure in libnetlink.c, (2) Put ifdefs in ll_types.c and ll_proto.c around various constants (ETH_P_xxx and ARPHRD_xxx) that weren't defined, (3) Make do_changename() in iplink.c require a kernel >= 2.4.0 -- the ifr structure in my environment doesn't have the ifr_name attribute. I've assumed this is a kernel dependency -- let me know if I ought to be checking something else. In the absence of the correct kernel, do_changename() always returns 0. Attached is a patch against the current CVS that will make these changes. -- Lars
2003-03-19Major coreutils update.Manuel Novoa III
2002-12-16Only included headers that are used.Glenn L McGrath
2002-11-28Cleanup error messagesGlenn L McGrath
2002-11-10IP applet by Bastian Blank <waldi@debian.org>Glenn L McGrath