chiark / gitweb /
udp, polypath: Log destination address in `some success' messages
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Oct 2014 11:09:46 +0000 (12:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Oct 2014 17:13:43 +0000 (18:13 +0100)
Replace the boolean parameter with a pointer to the destination
address.  (Conveniently this means that the calls relating to
reception can remain unchanged and the ones relating to transmission
produce a compile error until converted.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
comm-common.h
polypath.c
udp.c

index b1cd9c0..4aa644a 100644 (file)
@@ -103,7 +103,7 @@ void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us);
 const char *af_name(int af);
 void udp_sock_experienced(struct log_if *lg, struct udpcommon *uc,
                          struct udpsocks *socks, struct udpsock *us,
-                         bool_t recvsend, int af /* 0 means any */,
+                         const union iaddr *dest, int af /* 0 means any */,
                          int r, int errnoval);
 
 void udp_socks_register(struct udpcommon *uc, struct udpsocks *socks,
index af52473..abbda21 100644 (file)
@@ -440,7 +440,7 @@ static bool_t polypath_sendmsg(void *commst, struct buffer_if *buf,
            int r=sendto(us->fd,buf->start,buf->size,
                         0,&dest->ia.sa,iaddr_socklen(&dest->ia));
            udp_sock_experienced(0,&st->uc,&interf->socks,us,
-                                1,af, r,errno);
+                                &dest->ia,af, r,errno);
            if (r>=0) {
                reasonable=True;
                break;
diff --git a/udp.c b/udp.c
index a2bb907..4119235 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -84,20 +84,23 @@ const char *af_name(int af)
 
 void udp_sock_experienced(struct log_if *lg, struct udpcommon *uc,
                          struct udpsocks *socks, struct udpsock *us,
-                         bool_t recvsend, int af,
+                         const union iaddr *dest, int af,
                          int r, int errnoval)
 {
     bool_t success=r>=0;
-    if (us->experienced[recvsend][af][success]++)
+    if (us->experienced[!!dest][af][success]++)
        return;
     lg_perror(lg, uc->cc.cl.description, &uc->cc.loc,
              success ? M_INFO : M_WARNING,
              success ? 0 : errnoval,
-             "%s %s experiencing some %s %s%s%s",
+             "%s %s experiencing some %s %s%s%s%s%s%s",
              socks->desc,iaddr_to_string(&us->addr),
              success?"success":"trouble",
-             recvsend?"transmitting":"receiving",
-             af?" ":"", af?af_name(af):"");
+             dest?"transmitting":"receiving",
+             af?" ":"", af?af_name(af):"",
+             dest?" (to ":"",
+             dest?iaddr_to_string(dest):"",
+             dest?")":"");
 }
 
 static void udp_socks_afterpoll(void *state, struct pollfd *fds, int nfds)
@@ -197,7 +200,7 @@ static bool_t udp_sendmsg(void *commst, struct buffer_if *buf,
        memcpy(sa+6,&dest->ia.sin.sin_port,2);
        int r=sendto(us->fd,sa,buf->size+8,0,&uc->proxy.sa,
               iaddr_socklen(&uc->proxy));
-       udp_sock_experienced(0,uc,socks,us, 1,0, r,errno);
+       udp_sock_experienced(0,uc,socks,us, &dest->ia,0, r,errno);
        buf_unprepend(buf,8);
     } else {
        int i,r;
@@ -210,7 +213,7 @@ static bool_t udp_sendmsg(void *commst, struct buffer_if *buf,
                continue;
            r=sendto(us->fd, buf->start, buf->size, 0,
                     &dest->ia.sa, iaddr_socklen(&dest->ia));
-           udp_sock_experienced(0,uc,socks,us, 1,af, r,errno);
+           udp_sock_experienced(0,uc,socks,us, &dest->ia,af, r,errno);
            if (r>=0) return True;
            if (!(errno==EAFNOSUPPORT || errno==ENETUNREACH))
                /* who knows what that error means? */