[PATCH 13/21] netlink: Break out netlink_host_deliver

Ian Jackson ijackson at chiark.greenend.org.uk
Thu Apr 24 02:37:32 BST 2014


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 <ijackson at chiark.greenend.org.uk>
---
 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);
 	}
-- 
1.7.10.4




More information about the sgo-software-discuss mailing list