summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ChangeLog6
-rw-r--r--lib/sockopt.c13
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;
}