It also matches on the address offered as well as the server address.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 17, 2009
+.Dd February 27, 2009
.Dt DHCPCD 8 SMM
.Sh NAME
.Nm dhcpcd
.Op Fl O , -nooption Ar option
.Op Fl Q , -require Ar option
.Op Fl S , -static Ar value
-.Op Fl X , -blacklist Ar address
+.Op Fl X , -blacklist Ar address Ns Op Ar /cidr
.Op Fl Z , -denyinterfaces Ar pattern
.Op interface
.Op ...
.It Fl V, -variables
Display a list of option codes and the associated variable for use in
.Xr dhcpcd-run-hooks 8 .
-.It Fl X, -blacklist Ar address
+.It Fl X, -blacklist Ar address Ns Op Ar /cidr
Ignores all DHCP messages which have this
.Ar address
-as the server ID.
+as the server ID or offered address.
+If
+.Ar cidr
+is given then we match against that network as well.
This may be expanded in future releases to ignore all packets
matching either the IP or hardware
.Ar address .
struct dhcp_message *dhcp = *dhcpp;
struct dhcp_lease *lease = &state->lease;
uint8_t type, tmp;
- struct in_addr addr;
+ struct in_addr addr, addr2;
size_t i;
+ char *a;
/* reset the message counter */
state->interval = 0;
/* Ensure that it's not from a blacklisted server.
* We should expand this to check IP and/or hardware address
* at the packet level. */
- if (ifo->blacklist_len != 0 &&
- get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == 0)
- {
- for (i = 0; i < ifo->blacklist_len; i++) {
- if (ifo->blacklist[i] != addr.s_addr)
- continue;
- if (dhcp->servername[0])
- syslog(LOG_WARNING,
- "%s: ignoring blacklisted server %s `%s'",
- iface->name,
- inet_ntoa(addr), dhcp->servername);
- else
- syslog(LOG_WARNING,
- "%s: ignoring blacklisted server %s",
- iface->name, inet_ntoa(addr));
- return;
+ if (ifo->blacklist_len != 0) {
+ if (get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) != 0)
+ addr.s_addr = 0;
+ for (i = 0; i < ifo->blacklist_len; i += 2) {
+ if (ifo->blacklist[i] ==
+ (addr.s_addr & ifo->blacklist[i + 1]))
+ {
+ if (dhcp->servername[0])
+ syslog(LOG_WARNING,
+ "%s: blacklisted server %s `%s'",
+ iface->name,
+ inet_ntoa(addr), dhcp->servername);
+ else
+ syslog(LOG_WARNING,
+ "%s: blacklisted server %s",
+ iface->name, inet_ntoa(addr));
+ return;
+ }
+ if (ifo->blacklist[i] ==
+ (dhcp->yiaddr & ifo->blacklist[i + 1]))
+ {
+ addr2.s_addr = dhcp->yiaddr;
+ a = xstrdup(inet_ntoa(addr2));
+ if (dhcp->servername[0])
+ syslog(LOG_WARNING,
+ "%s: blacklisted offer"
+ " %s from %s `%s'",
+ iface->name, a,
+ inet_ntoa(addr), dhcp->servername);
+ else if (addr.s_addr)
+ syslog(LOG_WARNING,
+ "%s: blacklisted offer %s from %s",
+ iface->name, a, inet_ntoa(addr));
+ else
+ syslog(LOG_WARNING,
+ "%s: blacklisted offer %s",
+ iface->name, a);
+ free(a);
+ return;
+ }
}
}
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 28, 2009
+.Dd February 27, 2009
.Dt DHCPCD.CONF 5 SMM
.Sh NAME
.Nm dhcpcd.conf
Background immediately.
This is useful for startup scripts which don't disable link messages for
carrier status.
-.It Ic blacklist Ar address
+.It Ic blacklist Ar address Ns Op Ar /cidr
Ignores all DHCP messages which have this
.Ar address
-as the server ID.
+as the server ID or offered address.
+If
+.Ar cidr
+is given then we match against that network as well.
This may be expanded in future releases to ignore all packets
matching either the IP or hardware
.Ar address .
syslog(LOG_ERR, "`%s' is not a valid IP address", arg);
return -1;
}
+ if (p)
+ *--p = '/';
return 0;
}
int i;
char *p = NULL, *np;
ssize_t s;
- struct in_addr addr;
+ struct in_addr addr, addr2;
struct rt *rt;
switch(opt) {
}
break;
case 'X':
- if (!inet_aton(arg, &addr)) {
- syslog(LOG_ERR, "`%s' is not a valid IP address",
- arg);
+ addr2.s_addr = ~0U;
+ if (parse_addr(&addr, &addr2, arg) != 0)
return -1;
- }
ifo->blacklist = xrealloc(ifo->blacklist,
- sizeof(in_addr_t) * (ifo->blacklist_len + 1));
- ifo->blacklist[ifo->blacklist_len] = addr.s_addr;
- ifo->blacklist_len++;
+ sizeof(in_addr_t) * (ifo->blacklist_len + 2));
+ ifo->blacklist[ifo->blacklist_len++] = addr.s_addr;
+ ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr;
break;
case 'Z':
/* We only set this if we haven't got any interfaces */