X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=netlink.c;h=ecad16cb73e6d8cb18b724148912648a2482a219;hp=704dcf6d35a2287f1ccdf041abcc05b1243bcdfa;hb=20d324b6d71fdfbbe28479848c934ca3a1f69f16;hpb=ff05a229397c75142725f45cad191ce4a00625ce diff --git a/netlink.c b/netlink.c index 704dcf6..ecad16c 100644 --- a/netlink.c +++ b/netlink.c @@ -97,6 +97,7 @@ their use. */ +#include #include "secnet.h" #include "util.h" #include "ipaddr.h" @@ -147,30 +148,30 @@ static inline uint16_t ip_csum(uint8_t *iph,uint32_t count) static inline uint16_t ip_fast_csum(uint8_t *iph, uint32_t ihl) { uint32_t sum; - __asm__ __volatile__(" - movl (%1), %0 - subl $4, %2 - jbe 2f - addl 4(%1), %0 - adcl 8(%1), %0 - adcl 12(%1), %0 -1: adcl 16(%1), %0 - lea 4(%1), %1 - decl %2 - jne 1b - adcl $0, %0 - movl %0, %2 - shrl $16, %0 - addw %w2, %w0 - adcl $0, %0 - notl %0 -2: - " + __asm__ __volatile__( + "movl (%1), %0 ;\n" + "subl $4, %2 ;\n" + "jbe 2f ;\n" + "addl 4(%1), %0 ;\n" + "adcl 8(%1), %0 ;\n" + "adcl 12(%1), %0 ;\n" +"1: adcl 16(%1), %0 ;\n" + "lea 4(%1), %1 ;\n" + "decl %2 ;\n" + "jne 1b ;\n" + "adcl $0, %0 ;\n" + "movl %0, %2 ;\n" + "shrl $16, %0 ;\n" + "addw %w2, %w0 ;\n" + "adcl $0, %0 ;\n" + "notl %0 ;\n" +"2: ;\n" /* Since the input registers which are loaded with iph and ipl are modified, we must also specify them as outputs, or gcc will assume they contain their original values. */ : "=r" (sum), "=r" (iph), "=r" (ihl) - : "1" (iph), "2" (ihl)); + : "1" (iph), "2" (ihl) + : "memory"); return sum; } #else @@ -414,7 +415,7 @@ static void netlink_packet_deliver(struct netlink *st, BUF_ASSERT_USED(buf); if (dest==st->secnet_address) { - Message(M_ERR,"%s: trying to deliver a packet to myself!\n"); + Message(M_ERR,"%s: trying to deliver a packet to myself!\n",st->name); BUF_FREE(buf); return; } @@ -935,7 +936,7 @@ static list_t *netlink_inst_apply(closure_t *self, struct cloc loc, netlink_deliver_fn *netlink_init(struct netlink *st, void *dst, struct cloc loc, - dict_t *dict, string_t description, + dict_t *dict, cstring_t description, netlink_route_fn *set_routes, netlink_deliver_fn *to_host) { @@ -961,9 +962,10 @@ netlink_deliver_fn *netlink_init(struct netlink *st, if (l) st->networks=string_list_to_ipset(l,loc,st->name,"networks"); else { - Message(M_WARNING,"%s: no local networks (parameter \"networks\") " - "defined\n",st->name); - st->networks=ipset_new(); + struct ipset *empty; + empty=ipset_new(); + st->networks=ipset_complement(empty); + ipset_free(empty); } l=dict_lookup(dict,"remote-networks"); if (l) {