chiark / gitweb /
ipif: set interface names
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 Apr 2017 19:56:47 +0000 (20:56 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 Apr 2017 19:56:47 +0000 (20:56 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README.config
hippotat
hippotatd
hippotatlib/__init__.py

index 9c0e4fe..81f791d 100644 (file)
@@ -42,9 +42,9 @@ Exceptional settings:
      Command to run to create and communicate with local network
      interface.  Passed to sh -c.  Must speak SLIP on stdin/stdout.
      The following additional interpolations aare substituted:
-                       %(local)s      %(peer)s       %(rnet)s
-          on server    <vaddr>        <vrelay>       <vnetwork>
-          on client    <client>       <vaddr>        <vroutes>
+                       %(local)s  %(peer)s  %(rnet)s    %(ifname)s
+          on server    <vaddr>    <vrelay>  <vnetwork>  <ifname_server>
+          on client    <client>   <vaddr>   <vroutes>   <ifname_client>
      ["userv root ipif %(local)s,%(peer)s,%(mtu)s,slip %(rnets)s"]
 
      On server: applies to all clients; not looked up in
@@ -116,6 +116,12 @@ Ordinary settings, used by both, not client-specific:
   mtu
      Must match exactly.  (UNCHECKED) [1500 bytes]
 
+  ifname_server
+     Virtual interface name on the server.  [shippo%d]
+  ifname_client
+     Virtual interface name on the client.  [hippo%d]
+     Any %d is interpolated (by the kernel).
+
 Ordinary settings, used by client only:
 
   http_timeout_grace
index 18cd14e..379a184 100755 (executable)
--- a/hippotat
+++ b/hippotat
@@ -254,6 +254,12 @@ def process_cfg(_opts, putative_servers, putative_clients):
       c.max_queue_time  = srch(cfg.getint, 'max_queue_time')
       c.vroutes         = srch(cfg.get,    'vroutes')
 
+      def cfg_get_raw(*args, **kwargs):
+        return cfg.get(*args, raw=True, **kwargs)
+
+      try: c.ifname     = srch(cfg_get_raw, 'ifname_client')
+      except NoOptionError: pass
+
       try: c.url = srch(cfg.get,'url')
       except NoOptionError:
         cfg_process_saddrs(c, ss)
index fe10eec..666fc1b 100755 (executable)
--- a/hippotatd
+++ b/hippotatd
@@ -320,6 +320,9 @@ def process_cfg(_opts, putative_servers, putative_clients):
       c.vrelay = search
       break
 
+  try: c.ifname = cfg.get(c.server, 'ifname_server', raw=True)
+  except NoOptionError: pass
+
   cfg_process_ipif(c,
                    [c.server, 'DEFAULT'],
                    (('local','vaddr'),
index 16bba81..2a2a8ee 100644 (file)
@@ -136,9 +136,11 @@ max_batch_up = 4000
 http_retry = 5
 port = 80
 vroutes = ''
+ifname_client = hippo%%d
+ifname_server = shippo%%d
 
 #[server] or [<client>] overrides
-ipif = userv root ipif %(local)s,%(peer)s,%(mtu)s,slip %(rnets)s
+ipif = userv root ipif %(local)s,%(peer)s,%(mtu)s,slip,%(ifname)s %(rnets)s
 
 # relating to virtual network
 mtu = 1500