[Swan-dev] addconn: Fix for lsw#86

D. Hugh Redelmeier hugh at mimosa.com
Thu May 29 21:30:04 EEST 2014


| From: Paul Wouters <paul at vault.libreswan.fi>

| commit a31c9d9610b4755be9bdab766b75a8ffaf975762
| Author: Paul Wouters <pwouters at redhat.com>
| Date:   Thu May 29 12:23:40 2014 -0400
| 
|     addconn: Fix for lsw#86  left=%defaultroute does not work in a conn
|     
|     Various kind of combinations with or without left/right and leftnexthop
|     rightnexthop set to %defaultroute would give unexpected different results

This eliminates the only use of dnh in struct starter_config.  It was
never set.  So that's good.  I will delete it.

	ip_address dnh; /* next hop value */

But there is also:
	ip_address dr;  /* default route */
It looks as if that too is used but never set
lib/libipsecconf/starterwhack.c:141:
	case KH_DEFAULTROUTE:
                w->host_addr = cfg->dr;
	        if (addrtypeof(&w->host_addr) == 0)
			w->host_addr = *aftoinfo(l->addr_family)->any;
	        break;

The difference here is that this code notices that the value hasn't
been set (address type is 0, a kind of rough-and-ready-test) and then
sets it to any.

So I'll delete dr and eliminate its use.  And I think that the more
conventional code for setting w->host_addr to %any is
	anyaddr(l->addr_family, &w->host_addr);
Since this is just what case KH_IPHOSTNAME does, I'll move the case
label there.

struct starter_config also has
	bool got_default;
Which is never used.  Coincidentally, so does struct config_parsed.
I'll ditch them too.

Hunting around, I find some more fields that are never used:
include/ipsecconf/confread.h: struct starter_config:
	bool nocrsend;
	bool nat_traversal;
	bool force_busy;
	unsigned int keep_alive;
	char *virtual_private;
	bool strictcrlpolicy;

In struct starter_conn's enum called state, half the STATE_ values are
never used.  In the same struct, this isn't used:
	bool changed;

In struct starter_end, this is unused:
        bool has_id_wildcards;

I've eliminated all these and checked in the result.


More information about the Swan-dev mailing list