Revision 3a82ff41

b/nfdhcpd/nfdhcpd
130 130
    def_net = None
131 131

  
132 132
    for route in routes:
133
        match = re.match(r'^default.*via ([^\s]+).*dev ([^\s]+)', route)
134
        if match:
135
            def_gw, def_dev = match.groups()
136
            break
137

  
138
    for route in routes:
139 133
        # Find the least-specific connected route
140
        m = re.match("^([^\\s]+) dev %s" % def_dev, route)
134
        m = re.match("^([\S]+/[\S]+) dev ([\S]+)", route)
141 135
        if not m:
142 136
            continue
143 137

  
......
145 139
            # Skip link-local declarations in "main" table
146 140
            continue
147 141

  
148
        def_net = m.group(1)
142
        def_net, def_dev = m.groups()
149 143

  
150 144
        try:
151 145
            def_net = IPy.IP(def_net)
......
153 147
            logging.warn("Unable to parse default route entry %s: %s",
154 148
                         def_net, str(e))
155 149

  
150
    for route in routes:
151
        match = re.match(r'^default.*via ([\S]+).*dev ([\S]+)', route)
152
        if match:
153
            def_gw, def_dev = match.groups()
154
            break
155

  
156 156
    return Subnet(net=def_net, gw=def_gw, dev=def_dev)
157 157

  
158 158

  
......
379 379
        """ Send a raw packet using a layer-2 socket
380 380

  
381 381
        """
382
        logging.debug("%s", data)
382 383
        if isinstance(data, BasePacket):
383 384
            data = str(data)
384 385

  
......
527 528
        mac = resp.chaddr[:hlen].encode("hex")
528 529
        mac, _ = re.subn(r'([0-9a-fA-F]{2})', r'\1:', mac, hlen-1)
529 530

  
530
	logging.info("%s %s %s ", resp, hlen, mac)
531 531
        # Server responses are always BOOTREPLYs
532 532
        resp.op = "BOOTREPLY"
533 533
        del resp.payload
......
576 576
            dhcp_options += [
577 577
                 ("hostname", binding.hostname),
578 578
                 ("domain", binding.hostname.split('.', 1)[-1]),
579
                 ("router", subnet.gw),
580 579
                 ("broadcast_address", str(subnet.broadcast)),
581 580
                 ("subnet_mask", str(subnet.netmask)),
582 581
                 ("renewal_time", self.lease_renewal),
583 582
                 ("lease_time", self.lease_lifetime),
584 583
            ]
584
            if subnet.gw:
585
              dhcp_options += [("router", subnet.gw)]
585 586
            dhcp_options += [("name_server", x) for x in self.dhcp_nameservers]
586 587

  
587 588
        elif req_type == DHCPINFORM:

Also available in: Unified diff