diff options
author | ajs <ajs> | 2004-12-28 21:43:17 +0000 |
---|---|---|
committer | ajs <ajs> | 2004-12-28 21:43:17 +0000 |
commit | 1d75c8c3b28db50bc53771d5fac37b809d37b614 (patch) | |
tree | 530ea967460e0f9978572b85e15666617a4b3f45 /lib | |
parent | af04bd7c102c3fc1a9c2e98337b0ab1fa824d080 (diff) |
2004-12-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* sockopt.c: (setsockopt_ipv4_ifindex) Improve error message.
When neither IP_PKTINFO nor IP_RECVIF is defined, make return value
deterministic (-1).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 6 | ||||
-rw-r--r-- | lib/sockopt.c | 13 |
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index cc5f8673..eaf459de 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,11 @@ 2004-12-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + * sockopt.c: (setsockopt_ipv4_ifindex) Improve error message. + When neither IP_PKTINFO nor IP_RECVIF is defined, make return value + deterministic (-1). + +2004-12-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + * thread.c: (funcname_thread_add_timer_msec) Reduce overflow risk. 2004-12-21 Paul Jakma <paul.jakma@sun.com> diff --git a/lib/sockopt.c b/lib/sockopt.c index 786e1528..3a8033cc 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -242,17 +242,20 @@ setsockopt_ipv4_ifindex (int sock, int val) int ret; #if defined (IP_PKTINFO) - ret = setsockopt (sock, IPPROTO_IP, IP_PKTINFO, &val, sizeof (val)); + if ((ret = setsockopt (sock, IPPROTO_IP, IP_PKTINFO, &val, sizeof (val))) < 0) + zlog_warn ("Can't set IP_PKTINFO option for fd %d to %d: %s", + sock,val,safe_strerror(errno)); #elif defined (IP_RECVIF) - ret = setsockopt (sock, IPPROTO_IP, IP_RECVIF, &val, sizeof (val)); + if ((ret = setsockopt (sock, IPPROTO_IP, IP_RECVIF, &val, sizeof (val))) < 0) + zlog_warn ("Can't set IP_RECVIF option for fd %d to %d: %s", + sock,val,safe_strerror(errno)); #else #warning "Neither IP_PKTINFO nor IP_RECVIF is available." #warning "Will not be able to receive link info." #warning "Things might be seriously broken.." + /* XXX Does this ever happen? Should there be a zlog_warn message here? */ + ret = -1; #endif - - if (ret < 0) - zlog_warn ("Can't set IP_PKTINFO option"); return ret; } |