~ubuntu-branches/ubuntu/utopic/dnsmasq/utopic

« back to all changes in this revision

Viewing changes to src/dhcp.c

  • Committer: Package Import Robot
  • Author(s): Simon Kelley
  • Date: 2013-08-04 14:48:21 UTC
  • mfrom: (0.5.5) (12.2.13 sid)
  • Revision ID: package-import@ubuntu.com-20130804144821-53zdaugru2z9mgsp
Tags: 2.66-4
Update resolvconf script. (closes: #716908)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* dnsmasq is Copyright (c) 2000-2012 Simon Kelley
 
1
/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
65
65
  
66
66
  /* When bind-interfaces is set, there might be more than one dnmsasq
67
67
     instance binding port 67. That's OK if they serve different networks.
68
 
     Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
 
68
     Need to set REUSEADDR|REUSEPORT to make this posible.
 
69
     Handle the case that REUSEPORT is defined, but the kernel doesn't 
 
70
     support it. This handles the introduction of REUSEPORT on Linux. */
69
71
  if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
70
72
    {
 
73
      int rc = -1, porterr = 0;
 
74
 
71
75
#ifdef SO_REUSEPORT
72
 
      int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
73
 
#else
74
 
      int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
 
76
      if ((rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt))) == -1 && 
 
77
          errno != ENOPROTOOPT)
 
78
        porterr = 1;
75
79
#endif
 
80
      
 
81
      if (rc == -1 && !porterr)
 
82
        rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
 
83
      
76
84
      if (rc == -1)
77
85
        die(_("failed to set SO_REUSE{ADDR|PORT} on DHCP socket: %s"), NULL, EC_BADNET);
78
86
    }
252
260
    }
253
261
  
254
262
  for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
255
 
    if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
 
263
    if (tmp->name && wildcard_match(tmp->name, ifr.ifr_name))
256
264
      return;
257
265
  
258
266
  /* unlinked contexts are marked by context->current == context */
262
270
  parm.current = NULL;
263
271
  parm.ind = iface_index;
264
272
 
265
 
  if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name))
 
273
  if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL))
266
274
    {
267
275
      /* If we failed to match the primary address of the interface, see if we've got a --listen-address
268
276
         for a secondary */