ipconfig.c (57b8628bb0ac4e47c806e45c5bbd89282e93869b) ipconfig.c (e87cc4728f0e2fb663e592a1141742b1d6c63256)
1/*
2 * Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
3 * user-supplied information to configure own IP address and routes.
4 *
5 * Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 *
7 * Derived from network configuration code in fs/nfs/nfsroot.c,
8 * originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.

--- 941 unchanged lines hidden (view full) ---

950 b = (struct bootp_pkt *)skb_network_header(skb);
951 h = &b->iph;
952
953 if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
954 goto drop;
955
956 /* Fragments are not supported */
957 if (ip_is_fragment(h)) {
1/*
2 * Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
3 * user-supplied information to configure own IP address and routes.
4 *
5 * Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 *
7 * Derived from network configuration code in fs/nfs/nfsroot.c,
8 * originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.

--- 941 unchanged lines hidden (view full) ---

950 b = (struct bootp_pkt *)skb_network_header(skb);
951 h = &b->iph;
952
953 if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
954 goto drop;
955
956 /* Fragments are not supported */
957 if (ip_is_fragment(h)) {
958 if (net_ratelimit())
959 pr_err("DHCP/BOOTP: Ignoring fragmented reply\n");
958 net_err_ratelimited("DHCP/BOOTP: Ignoring fragmented reply\n");
960 goto drop;
961 }
962
963 if (skb->len < ntohs(h->tot_len))
964 goto drop;
965
966 if (ip_fast_csum((char *) h, h->ihl))
967 goto drop;

--- 31 unchanged lines hidden (view full) ---

999 while (d && d->dev != dev)
1000 d = d->next;
1001 if (!d)
1002 goto drop_unlock; /* should never happen */
1003
1004 /* Is it a reply to our BOOTP request? */
1005 if (b->op != BOOTP_REPLY ||
1006 b->xid != d->xid) {
959 goto drop;
960 }
961
962 if (skb->len < ntohs(h->tot_len))
963 goto drop;
964
965 if (ip_fast_csum((char *) h, h->ihl))
966 goto drop;

--- 31 unchanged lines hidden (view full) ---

998 while (d && d->dev != dev)
999 d = d->next;
1000 if (!d)
1001 goto drop_unlock; /* should never happen */
1002
1003 /* Is it a reply to our BOOTP request? */
1004 if (b->op != BOOTP_REPLY ||
1005 b->xid != d->xid) {
1007 if (net_ratelimit())
1008 pr_err("DHCP/BOOTP: Reply not for us, op[%x] xid[%x]\n",
1009 b->op, b->xid);
1006 net_err_ratelimited("DHCP/BOOTP: Reply not for us, op[%x] xid[%x]\n",
1007 b->op, b->xid);
1010 goto drop_unlock;
1011 }
1012
1013 /* Is it a reply for the device we are configuring? */
1014 if (b->xid != ic_dev_xid) {
1008 goto drop_unlock;
1009 }
1010
1011 /* Is it a reply for the device we are configuring? */
1012 if (b->xid != ic_dev_xid) {
1015 if (net_ratelimit())
1016 pr_err("DHCP/BOOTP: Ignoring delayed packet\n");
1013 net_err_ratelimited("DHCP/BOOTP: Ignoring delayed packet\n");
1017 goto drop_unlock;
1018 }
1019
1020 /* Parse extensions */
1021 if (ext_len >= 4 &&
1022 !memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
1023 u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
1024 u8 *ext;

--- 168 unchanged lines hidden (view full) ---

1193 ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
1194 (do_bootp && do_rarp) ? " and " : "",
1195 do_rarp ? "RARP" : "");
1196
1197 start_jiffies = jiffies;
1198 d = ic_first_dev;
1199 retries = CONF_SEND_RETRIES;
1200 get_random_bytes(&timeout, sizeof(timeout));
1014 goto drop_unlock;
1015 }
1016
1017 /* Parse extensions */
1018 if (ext_len >= 4 &&
1019 !memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
1020 u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
1021 u8 *ext;

--- 168 unchanged lines hidden (view full) ---

1190 ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
1191 (do_bootp && do_rarp) ? " and " : "",
1192 do_rarp ? "RARP" : "");
1193
1194 start_jiffies = jiffies;
1195 d = ic_first_dev;
1196 retries = CONF_SEND_RETRIES;
1197 get_random_bytes(&timeout, sizeof(timeout));
1201 timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM);
1198 timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned int) CONF_TIMEOUT_RANDOM);
1202 for (;;) {
1203 /* Track the device we are configuring */
1204 ic_dev_xid = d->xid;
1205
1206#ifdef IPCONFIG_BOOTP
1207 if (do_bootp && (d->able & IC_BOOTP))
1208 ic_bootp_send_if(d, jiffies - start_jiffies);
1209#endif

--- 438 unchanged lines hidden ---
1199 for (;;) {
1200 /* Track the device we are configuring */
1201 ic_dev_xid = d->xid;
1202
1203#ifdef IPCONFIG_BOOTP
1204 if (do_bootp && (d->able & IC_BOOTP))
1205 ic_bootp_send_if(d, jiffies - start_jiffies);
1206#endif

--- 438 unchanged lines hidden ---