From c63b1d0aa5a62651d7dddf0550ca3a9a94d05d98 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 18 Jan 2015 04:07:44 +0000 Subject: [PATCH] linux.c: Implement the return-code protocol described. It should return zero on success or -1 on failure, because it's an operation which attempts to return a value, and so might fail -- as opposed to a predicate asking a simple boolean question about the world. No actual harm done, because the code was correct to begin with, but potentially confusing later. --- linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux.c b/linux.c index 2c9a1d7..17a27a8 100644 --- a/linux.c +++ b/linux.c @@ -97,7 +97,7 @@ static int get_default_gw(int af, union addr *a) const struct rtattr *rta; const struct rtmsg *rtm; ssize_t n, nn; - int rc = 0; + int rc = -1; static unsigned long seq = 0x48b4aec4; /* Open a netlink socket for interrogating the kernel. */ @@ -163,7 +163,7 @@ static int get_default_gw(int af, union addr *a) if (rta->rta_type == RTA_GATEWAY) { assert(RTA_PAYLOAD(rta) <= sizeof(*a)); memcpy(a, RTA_DATA(rta), RTA_PAYLOAD(rta)); - rc = 1; + rc = 0; } } } @@ -201,7 +201,7 @@ void identify(struct query *q) * this may be a proxy connection from our NAT, so remember this, and don't * inspect the remote addresses in the TCP tables. */ - if (get_default_gw(q->ao->af, &s[0].addr) && + if (!get_default_gw(q->ao->af, &s[0].addr) && q->ao->addreq(&s[0].addr, &q->s[R].addr)) gwp = 1; -- 2.11.0