From f928f0694ff6b90d5fc429cfe910eaba9fdd3fd0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 13 Apr 2014 15:33:50 +0100 Subject: [PATCH] netlink: Break out netlink_host_deliver Provide a helper function for calling deliver_to_host, and use it at the two call sites. A side effect is that packets which came via point-to-point links are properly counted. Signed-off-by: Ian Jackson --- netlink.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/netlink.c b/netlink.c index 6241f70..97e1af9 100644 --- a/netlink.c +++ b/netlink.c @@ -445,6 +445,16 @@ static void netlink_client_deliver(struct netlink *st, client->outcount++; } +/* Deliver a packet to the host; used after we have decided that that + * is what to do with it. */ +static void netlink_host_deliver(struct netlink *st, + uint32_t source, uint32_t dest, + struct buffer_if *buf) +{ + st->deliver_to_host(st->dst,buf); + st->outcount++; +} + /* Deliver a packet. "client" is the _origin_ of the packet, not its destination, and is NULL for packets from the host and packets generated internally in secnet. */ @@ -524,8 +534,7 @@ static void netlink_packet_deliver(struct netlink *st, /* The packet's not going down a tunnel. It might (ought to) be for the host. */ if (ipset_contains_addr(st->networks,dest)) { - st->deliver_to_host(st->dst,buf); - st->outcount++; + netlink_host_deliver(st,source,dest,buf); BUF_ASSERT_FREE(buf); } else { string_t s,d; @@ -713,7 +722,7 @@ static void netlink_incoming(struct netlink *st, struct netlink_client *client, address validity and generate ICMP, etc. */ if (st->ptp) { if (client) { - st->deliver_to_host(st->dst,buf); + netlink_host_deliver(st,source,dest,buf); } else { netlink_client_deliver(st,st->clients,source,dest,buf); } -- 2.11.0