kernel-pfroute: split /0 routes to avoid conflict with default route
authorMartin Willi <martin@revosec.ch>
Fri, 19 Apr 2013 10:17:25 +0000 (12:17 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 6 May 2013 14:10:13 +0000 (16:10 +0200)
src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c

index 2fda4ae..f8d3f2c 100644 (file)
@@ -897,6 +897,21 @@ static status_t manage_route(private_kernel_pfroute_net_t *this, int op,
        host_t *dst;
        int type;
 
+       if (prefixlen == 0 && dst_net.len)
+       {
+               status_t status;
+               chunk_t half;
+
+               half = chunk_clonea(dst_net);
+               half.ptr[0] |= 0x80;
+               prefixlen = 1;
+               status = manage_route(this, op, half, prefixlen, gateway, if_name);
+               if (status != SUCCESS)
+               {
+                       return status;
+               }
+       }
+
        dst = host_create_from_chunk(AF_UNSPEC, dst_net, 0);
        if (!dst)
        {