chiark / gitweb /
Mobile sites: Require specification of whether we think we are mobile
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 20 Jul 2011 16:36:30 +0000 (17:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Aug 2011 22:14:54 +0000 (23:14 +0100)
We introduce a new config option "local-mobile" which must match our
peers' idea of whether we are mobile.  This is cross-checked with the
"site" entry for our own site, if there is one, to detect mistakes.

We do not transfer this data in the protocol because we don't want to
break compatibility with older secnets which do not understand mobile
peers at all.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README
site.c

diff --git a/README b/README
index 3736b89bbf5dfe1b8f81574d098e456709058e4e..7e40edf2024f109df94f4e9134db21927af82017 100644 (file)
--- a/README
+++ b/README
@@ -322,6 +322,12 @@ site: dict argument
   mobile-peer-expiry (integer): For "mobile" peers only, the length
     of time (in seconds) for which we will keep sending to multiple
     address/ports from which we have not seen incoming traffic. [120]
   mobile-peer-expiry (integer): For "mobile" peers only, the length
     of time (in seconds) for which we will keep sending to multiple
     address/ports from which we have not seen incoming traffic. [120]
+  local-mobile (bool): if True then other peers have been told we are
+    "mobile".  This should be True iff the peers' site configurations
+    for us have "mobile True" (and if we find a site configuration for
+    ourselves in the config, we insist on this).  The effect is to
+    check that there are no links both ends of which are allegedly
+    mobile (which is not supported, so those links are ignored). [false]
 
 ** transform
 
 
 ** transform
 
diff --git a/site.c b/site.c
index 9d09ebc1e53c92988004ec0feef14826b6eb87e8..8be55239f709a989a246cc91d226c991653a9b8a 100644 (file)
--- a/site.c
+++ b/site.c
@@ -1300,18 +1300,33 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context,
     dict=item->data.dict;
     st->localname=dict_read_string(dict, "local-name", True, "site", loc);
     st->remotename=dict_read_string(dict, "name", True, "site", loc);
     dict=item->data.dict;
     st->localname=dict_read_string(dict, "local-name", True, "site", loc);
     st->remotename=dict_read_string(dict, "name", True, "site", loc);
+
+    st->peer_mobile=dict_read_bool(dict,"mobile",False,"site",loc,False);
+    bool_t local_mobile=
+       dict_read_bool(dict,"local-mobile",False,"site",loc,False);
+
     /* Sanity check (which also allows the 'sites' file to include
        site() closures for all sites including our own): refuse to
        talk to ourselves */
     if (strcmp(st->localname,st->remotename)==0) {
        Message(M_DEBUG,"site %s: local-name==name -> ignoring this site\n",
                st->localname);
     /* Sanity check (which also allows the 'sites' file to include
        site() closures for all sites including our own): refuse to
        talk to ourselves */
     if (strcmp(st->localname,st->remotename)==0) {
        Message(M_DEBUG,"site %s: local-name==name -> ignoring this site\n",
                st->localname);
+       if (st->peer_mobile != local_mobile)
+           cfgfatal(loc,"site","site %s's peer-mobile=%d"
+                   " but our local-mobile=%d\n",
+                   st->localname, st->peer_mobile, local_mobile);
+       free(st);
+       return NULL;
+    }
+    if (st->peer_mobile && local_mobile) {
+       Message(M_WARNING,"site %s: site is mobile but so are we"
+               " -> ignoring this site\n", st->remotename);
        free(st);
        return NULL;
     }
        free(st);
        return NULL;
     }
+
     assert(index_sequence < 0xffffffffUL);
     st->index = ++index_sequence;
     assert(index_sequence < 0xffffffffUL);
     st->index = ++index_sequence;
-    st->peer_mobile=dict_read_bool(dict,"mobile",False,"site",loc,False);
     st->netlink=find_cl_if(dict,"link",CL_NETLINK,True,"site",loc);
     st->comm=find_cl_if(dict,"comm",CL_COMM,True,"site",loc);
     st->resolver=find_cl_if(dict,"resolver",CL_RESOLVER,True,"site",loc);
     st->netlink=find_cl_if(dict,"link",CL_NETLINK,True,"site",loc);
     st->comm=find_cl_if(dict,"comm",CL_COMM,True,"site",loc);
     st->resolver=find_cl_if(dict,"resolver",CL_RESOLVER,True,"site",loc);