From: Claudio-Daniel Freire Date: Mon, 23 May 2011 08:59:26 +0000 (+0200) Subject: pointopoint support X-Git-Tag: vsys-scripts-0.95-29~5 X-Git-Url: http://git.onelab.eu/?p=vsys-scripts.git;a=commitdiff_plain;h=31330532561406c882625a8efd9caa167505e7d0 pointopoint support --- diff --git a/exec/vif_up b/exec/vif_up index 39557df..b7a35d3 100755 --- a/exec/vif_up +++ b/exec/vif_up @@ -103,6 +103,7 @@ opt_txqueuelen = None opt_rp_filter = None opt_snat = None opt_ovs_dp = None +opt_pointopoint = None for optionline in options: @@ -129,11 +130,17 @@ for optionline in options: sys.exit(1) opt_txqueuelen = intval elif opt=="snat": - intval = int(val) - if val=="1": - opt_snat = True + intval = int(val) + if val=="1": + opt_snat = True + elif opt=="pointopoint": + opt_pointopoint = val.strip() + try: + socket.inet_aton(opt_pointopoint) + except socket.error,e: + print >>sys.stderr, "pointopoint: %s" % (e,) elif opt=="vswitch": - opt_ovs_dp = val + opt_ovs_dp = val else: print >>sys.stderr, "Unknown option: \"%s\"" % (opt) sys.exit(1) @@ -141,10 +148,16 @@ for optionline in options: ### Configure interface -if opt_txqueuelen is None: - cmd_ifconfig = "/sbin/ifconfig %s %s/%d" % (vif, vip, vmask) +cmd_ifconfig = "/sbin/ifconfig %s %s" % (vif, vip) +if opt_pointopoint is None: + cmd_ifconfig += "/%d" % (vmask,) else: - cmd_ifconfig = "/sbin/ifconfig %s %s/%d txqueuelen %d" % (vif, vip, vmask, opt_txqueuelen) + # point-to-point mask + cmd_ifconfig += " netmask 255.255.255.255" +if opt_txqueuelen is not None: + cmd_ifconfig += " txqueuelen %d" % (opt_txqueuelen,) +if opt_pointopoint is not None: + cmd_ifconfig += " pointopoint %s" % (opt_pointopoint,) os.system(cmd_ifconfig) @@ -171,6 +184,16 @@ if (opt_snat): #print cmd_iptables_del_pr #print cmd_iptables_pr +#if opt_pointopoint and vmask < 32: +# # Make target vnet masked address +# p2p_int = struct.unpack('!L', socket.inet_aton(opt_pointopoint))[0] +# vip_vnet = socket.inet_ntoa( +# struct.pack('!L', ((p2p_int>>(32-vmask))<<(32-vmask))) ) +# +# cmd_routing_p2p = "/sbin/route add -net %s/%d gw %s dev %s" % (vip_vnet, vmask, opt_pointopoint, vif) +# print >>sys.stderr, cmd_routing_p2p +# os.system(cmd_routing_p2p) + # Process additional options if opt_rp_filter is not None: rp_cmd = "/sbin/sysctl net.ipv4.conf.%s.rp_filter=%s" % (vif, opt_rp_filter) @@ -180,3 +203,4 @@ if opt_rp_filter is not None: if opt_ovs_dp is not None: cmd_ovs_addif = "ovs-dpctl add-if %s %s"%(opt_ovs_dp,vif) os.system(cmd_ovs_addif) +