diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-21 23:48:38 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-21 23:48:38 +0000 |
commit | a771e7c0057d0f506f8cdf67be39268e1c9f0735 (patch) | |
tree | bef7afb1304b3510d4857148a50e162a0578c363 /networking/libiproute | |
parent | e6b10ef0a7a5761c4cd0fe5f48bad953aa92240e (diff) |
*: remove check for errors on getsockaddr in cases we know they can't happen
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
Diffstat (limited to 'networking/libiproute')
-rw-r--r-- | networking/libiproute/iplink.c | 8 | ||||
-rw-r--r-- | networking/libiproute/libnetlink.c | 9 | ||||
-rw-r--r-- | networking/libiproute/libnetlink.h | 3 |
3 files changed, 10 insertions, 10 deletions
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 1e7ee07d2..de7d6407e 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c @@ -112,11 +112,11 @@ static int get_address(char *dev, int *htype) me.sll_ifindex = ifr.ifr_ifindex; me.sll_protocol = htons(ETH_P_LOOP); xbind(s, (struct sockaddr*)&me, sizeof(me)); - alen = sizeof(me); - if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) { - bb_perror_msg_and_die("getsockname"); - } + getsockname(s, (struct sockaddr*)&me, &alen); + //never happens: + //if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) + // bb_perror_msg_and_die("getsockname"); close(s); *htype = me.sll_hatype; return me.sll_halen; diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 6d51d8deb..7ad2de9fa 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c @@ -26,22 +26,23 @@ int FAST_FUNC xrtnl_open(struct rtnl_handle *rth/*, unsigned subscriptions*/) { socklen_t addr_len; - memset(rth, 0, sizeof(rth)); - + memset(rth, 0, sizeof(*rth)); rth->fd = xsocket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - - memset(&rth->local, 0, sizeof(rth->local)); rth->local.nl_family = AF_NETLINK; /*rth->local.nl_groups = subscriptions;*/ xbind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)); addr_len = sizeof(rth->local); + getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len); + +/* too much paranoia if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) bb_perror_msg_and_die("getsockname"); if (addr_len != sizeof(rth->local)) bb_error_msg_and_die("wrong address length %d", addr_len); if (rth->local.nl_family != AF_NETLINK) bb_error_msg_and_die("wrong address family %d", rth->local.nl_family); +*/ rth->seq = time(NULL); return 0; } diff --git a/networking/libiproute/libnetlink.h b/networking/libiproute/libnetlink.h index e5fee4dd8..11a4a100a 100644 --- a/networking/libiproute/libnetlink.h +++ b/networking/libiproute/libnetlink.h @@ -10,8 +10,7 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN -struct rtnl_handle -{ +struct rtnl_handle { int fd; struct sockaddr_nl local; struct sockaddr_nl peer; |