Release 4.14 net/ipv4/ipconfig.c
// SPDX-License-Identifier: GPL-2.0
/*
* Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
* user-supplied information to configure own IP address and routes.
*
* Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*
* Derived from network configuration code in fs/nfs/nfsroot.c,
* originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.
*
* BOOTP rewritten to construct and analyse packets itself instead
* of misusing the IP layer. num_bugs_causing_wrong_arp_replies--;
* -- MJ, December 1998
*
* Fixed ip_auto_config_setup calling at startup in the new "Linker Magic"
* initialization scheme.
* - Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 08/11/1999
*
* DHCP support added. To users this looks like a whole separate
* protocol, but we know it's just a bag on the side of BOOTP.
* -- Chip Salzenberg <chip@valinux.com>, May 2000
*
* Ported DHCP support from 2.2.16 to 2.4.0-test4
* -- Eric Biederman <ebiederman@lnxi.com>, 30 Aug 2000
*
* Merged changes from 2.2.19 into 2.4.3
* -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
*
* Multiple Nameservers in /proc/net/pnp
* -- Josef Siemes <jsiemes@web.de>, Aug 2002
*/
#include <linux/types.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/random.h>
#include <linux/init.h>
#include <linux/utsname.h>
#include <linux/in.h>
#include <linux/if.h>
#include <linux/inet.h>
#include <linux/inetdevice.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
#include <linux/socket.h>
#include <linux/route.h>
#include <linux/udp.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/major.h>
#include <linux/root_dev.h>
#include <linux/delay.h>
#include <linux/nfs_fs.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <net/net_namespace.h>
#include <net/arp.h>
#include <net/dsa.h>
#include <net/ip.h>
#include <net/ipconfig.h>
#include <net/route.h>
#include <linux/uaccess.h>
#include <net/checksum.h>
#include <asm/processor.h>
#if defined(CONFIG_IP_PNP_DHCP)
#define IPCONFIG_DHCP
#endif
#if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_DHCP)
#define IPCONFIG_BOOTP
#endif
#if defined(CONFIG_IP_PNP_RARP)
#define IPCONFIG_RARP
#endif
#if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP)
#define IPCONFIG_DYNAMIC
#endif
/* Define the friendly delay before and after opening net devices */
#define CONF_POST_OPEN 10
/* After opening: 10 msecs */
#define CONF_CARRIER_TIMEOUT 120000
/* Wait for carrier timeout */
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
#define CONF_OPEN_RETRIES 2
/* (Re)open devices twice */
#define CONF_SEND_RETRIES 6
/* Send six requests per open */
#define CONF_BASE_TIMEOUT (HZ*2)
/* Initial timeout: 2 seconds */
#define CONF_TIMEOUT_RANDOM (HZ)
/* Maximum amount of randomization */
#define CONF_TIMEOUT_MULT *7/4
/* Rate of timeout growth */
#define CONF_TIMEOUT_MAX (HZ*30)
/* Maximum allowed timeout */
#define CONF_NAMESERVERS_MAX 3
/* Maximum number of nameservers
- '3' from resolv.h */
#define NONE cpu_to_be32(INADDR_NONE)
#define ANY cpu_to_be32(INADDR_ANY)
/*
* Public IP configuration
*/
/* This is used by platforms which might be able to set the ipconfig
* variables using firmware environment vars. If this is set, it will
* ignore such firmware variables.
*/
int ic_set_manually __initdata = 0;
/* IPconfig parameters set manually */
static int ic_enable __initdata;
/* IP config enabled? */
/* Protocol choice */
int ic_proto_enabled __initdata = 0
#ifdef IPCONFIG_BOOTP
| IC_BOOTP
#endif
#ifdef CONFIG_IP_PNP_DHCP
| IC_USE_DHCP
#endif
#ifdef IPCONFIG_RARP
| IC_RARP
#endif
;
static int ic_host_name_set __initdata;
/* Host name set by us? */
__be32 ic_myaddr = NONE;
/* My IP address */
static __be32 ic_netmask = NONE;
/* Netmask for local subnet */
__be32 ic_gateway = NONE;
/* Gateway IP address */
#ifdef IPCONFIG_DYNAMIC
static __be32 ic_addrservaddr = NONE;
/* IP Address of the IP addresses'server */
#endif
__be32 ic_servaddr = NONE;
/* Boot server IP address */
__be32 root_server_addr = NONE;
/* Address of NFS server */
u8 root_server_path[256] = { 0, };
/* Path to mount as root */
/* vendor class identifier */
static char vendor_class_identifier[253] __initdata;
#if defined(CONFIG_IP_PNP_DHCP)
static char dhcp_client_identifier[253] __initdata;
#endif
/* Persistent data: */
#ifdef IPCONFIG_DYNAMIC
static int ic_proto_used;
/* Protocol used, if any */
#else
#define ic_proto_used 0
#endif
static __be32 ic_nameservers[CONF_NAMESERVERS_MAX];
/* DNS Server IP addresses */
static u8 ic_domain[64];
/* DNS (not NIS) domain name */
/*
* Private state.
*/
/* Name of user-selected boot device */
static char user_dev_name[IFNAMSIZ] __initdata = { 0, };
/* Protocols supported by available interfaces */
static int ic_proto_have_if __initdata;
/* MTU for boot device */
static int ic_dev_mtu __initdata;
#ifdef IPCONFIG_DYNAMIC
static DEFINE_SPINLOCK(ic_recv_lock);
static volatile int ic_got_reply __initdata;
/* Proto(s) that replied */
#endif
#ifdef IPCONFIG_DHCP
static int ic_dhcp_msgtype __initdata;
/* DHCP msg type received */
#endif
/*
* Network devices
*/
struct ic_device {
struct ic_device *next;
struct net_device *dev;
unsigned short flags;
short able;
__be32 xid;
};
static struct ic_device *ic_first_dev __initdata;
/* List of open device */
static struct ic_device *ic_dev __initdata;
/* Selected device */
static bool __init ic_is_init_dev(struct net_device *dev)
{
if (dev->flags & IFF_LOOPBACK)
return false;
return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
(!(dev->flags & IFF_LOOPBACK) &&
(dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
strncmp(dev->name, "dummy", 5));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David S. Miller | 62 | 84.93% | 1 | 50.00% |
Micha Nelissen | 11 | 15.07% | 1 | 50.00% |
Total | 73 | 100.00% | 2 | 100.00% |
static int __init ic_open_devs(void)
{
struct ic_device *d, **last;
struct net_device *dev;
unsigned short oflags;
unsigned long start, next_msg;
last = &ic_first_dev;
rtnl_lock();
/* bring loopback and DSA master network devices up first */
for_each_netdev(&init_net, dev) {
if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
continue;
if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
pr_err("IP-Config: Failed to open %s\n", dev->name);
}
for_each_netdev(&init_net, dev) {
if (ic_is_init_dev(dev)) {
int able = 0;
if (dev->mtu >= 364)
able |= IC_BOOTP;
else
pr_warn("DHCP/BOOTP: Ignoring device %s, MTU %d too small\n",
dev->name, dev->mtu);
if (!(dev->flags & IFF_NOARP))
able |= IC_RARP;
able &= ic_proto_enabled;
if (ic_proto_enabled && !able)
continue;
oflags = dev->flags;
if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
pr_err("IP-Config: Failed to open %s\n",
dev->name);
continue;
}
if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
rtnl_unlock();
return -ENOMEM;
}
d->dev = dev;
*last = d;
last = &d->next;
d->flags = oflags;
d->able = able;
if (able & IC_BOOTP)
get_random_bytes(&d->xid, sizeof(__be32));
else
d->xid = 0;
ic_proto_have_if |= able;
pr_debug("IP-Config: %s UP (able=%d, xid=%08x)\n",
dev->name, able, d->xid);
}
}
/* no point in waiting if we could not bring up at least one device */
if (!ic_first_dev)
goto have_carrier;
/* wait for a carrier on at least one device */
start = jiffies;
next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
while (time_before(jiffies, start +
msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) {
int wait, elapsed;
for_each_netdev(&init_net, dev)
if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
goto have_carrier;
msleep(1);
if (time_before(jiffies, next_msg))
continue;
elapsed = jiffies_to_msecs(jiffies - start);
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
pr_info("Waiting up to %d more seconds for network.\n", wait);
next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
}
have_carrier:
rtnl_unlock();
*last = NULL;
if (!ic_first_dev) {
if (user_dev_name[0])
pr_err("IP-Config: Device `%s' not found\n",
user_dev_name);
else
pr_err("IP-Config: No network devices available\n");
return -ENODEV;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 228 | 49.03% | 5 | 21.74% |
Paul Gortmaker | 62 | 13.33% | 1 | 4.35% |
Micha Nelissen | 49 | 10.54% | 1 | 4.35% |
Linus Torvalds | 33 | 7.10% | 2 | 8.70% |
Eric W. Biedermann | 25 | 5.38% | 2 | 8.70% |
Hideaki Yoshifuji / 吉藤英明 | 18 | 3.87% | 1 | 4.35% |
Gerlando Falauto | 9 | 1.94% | 1 | 4.35% |
Joe Perches | 7 | 1.51% | 1 | 4.35% |
Florian Fainelli | 7 | 1.51% | 1 | 4.35% |
Bastian Stender | 5 | 1.08% | 1 | 4.35% |
François-Xavier Le Bail | 5 | 1.08% | 1 | 4.35% |
Himangi Saraogi | 5 | 1.08% | 1 | 4.35% |
Pavel Emelyanov | 4 | 0.86% | 1 | 4.35% |
Stephen Hemminger | 3 | 0.65% | 1 | 4.35% |
David S. Miller | 2 | 0.43% | 1 | 4.35% |
Daniel Lezcano | 2 | 0.43% | 1 | 4.35% |
Al Viro | 1 | 0.22% | 1 | 4.35% |
Total | 465 | 100.00% | 23 | 100.00% |
static void __init ic_close_devs(void)
{
struct ic_device *d, *next;
struct net_device *dev;
rtnl_lock();
next = ic_first_dev;
while ((d = next)) {
next = d->next;
dev = d->dev;
if (d != ic_dev && !netdev_uses_dsa(dev)) {
pr_debug("IP-Config: Downing %s\n", dev->name);
dev_change_flags(dev, d->flags);
}
kfree(d);
}
rtnl_unlock();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 80 | 87.91% | 5 | 55.56% |
Florian Fainelli | 6 | 6.59% | 1 | 11.11% |
Stephen Hemminger | 2 | 2.20% | 1 | 11.11% |
Bastian Stender | 2 | 2.20% | 1 | 11.11% |
Mark Rutland | 1 | 1.10% | 1 | 11.11% |
Total | 91 | 100.00% | 9 | 100.00% |
/*
* Interface to various network functions.
*/
static inline void
set_sockaddr(struct sockaddr_in *sin, __be32 addr, __be16 port)
{
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = addr;
sin->sin_port = port;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 36 | 94.74% | 1 | 50.00% |
Al Viro | 2 | 5.26% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
{
int res;
mm_segment_t oldfs = get_fs();
set_fs(get_ds());
res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
set_fs(oldfs);
return res;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Chris Friesen | 57 | 100.00% | 1 | 100.00% |
Total | 57 | 100.00% | 1 | 100.00% |
static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
{
int res;
mm_segment_t oldfs = get_fs();
set_fs(get_ds());
res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
set_fs(oldfs);
return res;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 47 | 82.46% | 2 | 40.00% |
Stephen Hemminger | 6 | 10.53% | 1 | 20.00% |
Denis V. Lunev | 3 | 5.26% | 1 | 20.00% |
Chris Friesen | 1 | 1.75% | 1 | 20.00% |
Total | 57 | 100.00% | 5 | 100.00% |
static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
{
int res;
mm_segment_t oldfs = get_fs();
set_fs(get_ds());
res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
set_fs(oldfs);
return res;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 48 | 85.71% | 2 | 50.00% |
Stephen Hemminger | 5 | 8.93% | 1 | 25.00% |
Denis V. Lunev | 3 | 5.36% | 1 | 25.00% |
Total | 56 | 100.00% | 4 | 100.00% |
/*
* Set up interface addresses and routes.
*/
static int __init ic_setup_if(void)
{
struct ifreq ir;
struct sockaddr_in *sin = (void *) &ir.ifr_ifru.ifru_addr;
int err;
memset(&ir, 0, sizeof(ir));
strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->dev->name);
set_sockaddr(sin, ic_myaddr, 0);
if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) {
pr_err("IP-Config: Unable to set interface address (%d)\n",
err);
return -1;
}
set_sockaddr(sin, ic_netmask, 0);
if ((err = ic_devinet_ioctl(SIOCSIFNETMASK, &ir)) < 0) {
pr_err("IP-Config: Unable to set interface netmask (%d)\n",
err);
return -1;
}
set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
if ((err = ic_devinet_ioctl(SIOCSIFBRDADDR, &ir)) < 0) {
pr_err("IP-Config: Unable to set interface broadcast address (%d)\n",
err);
return -1;
}
/* Handle the case where we need non-standard MTU on the boot link (a network
* using jumbo frames, for instance). If we can't set the mtu, don't error
* out, we'll try to muddle along.
*/
if (ic_dev_mtu != 0) {
strcpy(ir.ifr_name, ic_dev->dev->name);
ir.ifr_mtu = ic_dev_mtu;
if ((err = ic_dev_ioctl(SIOCSIFMTU, &ir)) < 0)
pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n",
ic_dev_mtu, err);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 169 | 72.53% | 2 | 40.00% |
Chris Friesen | 52 | 22.32% | 1 | 20.00% |
Joe Perches | 8 | 3.43% | 1 | 20.00% |
Uwe Kleine-König | 4 | 1.72% | 1 | 20.00% |
Total | 233 | 100.00% | 5 | 100.00% |
static int __init ic_setup_routes(void)
{
/* No need to setup device routes, only the default route... */
if (ic_gateway != NONE) {
struct rtentry rm;
int err;
memset(&rm, 0, sizeof(rm));
if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
pr_err("IP-Config: Gateway not on directly connected network\n");
return -1;
}
set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
set_sockaddr((struct sockaddr_in *) &rm.rt_genmask, 0, 0);
set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
rm.rt_flags = RTF_UP | RTF_GATEWAY;
if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) {
pr_err("IP-Config: Cannot add default route (%d)\n",
err);
return -1;
}
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 145 | 96.67% | 2 | 50.00% |
Joe Perches | 4 | 2.67% | 1 | 25.00% |
Al Viro | 1 | 0.67% | 1 | 25.00% |
Total | 150 | 100.00% | 4 | 100.00% |
/*
* Fill in default values for all missing parameters.
*/
static int __init ic_defaults(void)
{
/*
* At this point we have no userspace running so need not
* claim locks on system_utsname
*/
if (!ic_host_name_set)
sprintf(init_utsname()->nodename, "%pI4", &ic_myaddr);
if (root_server_addr == NONE)
root_server_addr = ic_servaddr;
if (ic_netmask == NONE) {
if (IN_CLASSA(ntohl(ic_myaddr)))
ic_netmask = htonl(IN_CLASSA_NET);
else if (IN_CLASSB(ntohl(ic_myaddr)))
ic_netmask = htonl(IN_CLASSB_NET);
else if (IN_CLASSC(ntohl(ic_myaddr)))
ic_netmask = htonl(IN_CLASSC_NET);
else {
pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
&ic_myaddr);
return -1;
}
pr_notice("IP-Config: Guessing netmask %pI4\n",
&ic_netmask);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 107 | 85.60% | 4 | 36.36% |
Harvey Harrison | 6 | 4.80% | 1 | 9.09% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 2.40% | 1 | 9.09% |
Serge E. Hallyn | 3 | 2.40% | 1 | 9.09% |
Al Viro | 2 | 1.60% | 1 | 9.09% |
Linus Torvalds | 2 | 1.60% | 1 | 9.09% |
Joe Perches | 1 | 0.80% | 1 | 9.09% |
Bastian Stender | 1 | 0.80% | 1 | 9.09% |
Total | 125 | 100.00% | 11 | 100.00% |
/*
* RARP support.
*/
#ifdef IPCONFIG_RARP
static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
static struct packet_type rarp_packet_type __initdata = {
.type = cpu_to_be16(ETH_P_RARP),
.func = ic_rarp_recv,
};
static inline void __init ic_rarp_init(void)
{
dev_add_pack(&rarp_packet_type);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 15 | 93.75% | 2 | 66.67% |
Sam Ravnborg | 1 | 6.25% | 1 | 33.33% |
Total | 16 | 100.00% | 3 | 100.00% |
static inline void __init ic_rarp_cleanup(void)
{
dev_remove_pack(&rarp_packet_type);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 15 | 93.75% | 2 | 66.67% |
Sam Ravnborg | 1 | 6.25% | 1 | 33.33% |
Total | 16 | 100.00% | 3 | 100.00% |
/*
* Process received RARP packet.
*/
static int __init
ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
{
struct arphdr *rarp;
unsigned char *rarp_ptr;
__be32 sip, tip;
unsigned char *tha; /* t for "target" */
struct ic_device *d;
if (!net_eq(dev_net(dev), &init_net))
goto drop;
skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
return NET_RX_DROP;
if (!pskb_may_pull(skb, sizeof(struct arphdr)))
goto drop;
/* Basic sanity checks can be done without the lock. */
rarp = (struct arphdr *)skb_transport_header(skb);
/* If this test doesn't pass, it's not IP, or we should
* ignore it anyway.
*/
if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd))
goto drop;
/* If it's not a RARP reply, delete it. */
if (rarp->ar_op != htons(ARPOP_RREPLY))
goto drop;
/* If it's not Ethernet, delete it. */
if (rarp->ar_pro != htons(ETH_P_IP))
goto drop;
if (!pskb_may_pull(skb, arp_hdr_len(dev)))
goto drop;
/* OK, it is all there and looks valid, process... */
rarp = (struct arphdr *)skb_transport_header(skb);
rarp_ptr = (unsigned char *) (rarp + 1);
/* One reply at a time, please. */
spin_lock(&ic_recv_lock);
/* If we already have a reply, just drop the packet */
if (ic_got_reply)
goto drop_unlock;
/* Find the ic_device that the packet arrived on */
d = ic_first_dev;
while (d && d->dev != dev)
d = d->next;
if (!d)
goto drop_unlock; /* should never happen */
/* Extract variable-width fields */
rarp_ptr += dev->addr_len;
memcpy(&sip, rarp_ptr, 4);
rarp_ptr += 4;
tha = rarp_ptr;
rarp_ptr += dev->addr_len;
memcpy(&tip, rarp_ptr, 4);
/* Discard packets which are not meant for us. */
if (memcmp(tha, dev->dev_addr, dev->addr_len))
goto drop_unlock;
/* Discard packets which are not from specified server. */
if (ic_servaddr != NONE && ic_servaddr != sip)
goto drop_unlock;
/* We have a winner! */
ic_dev = d;
if (ic_myaddr == NONE)
ic_myaddr = tip;
ic_servaddr = sip;
ic_addrservaddr = sip;
ic_got_reply = IC_RARP;
drop_unlock:
/* Show's over. Nothing to see here. */
spin_unlock(&ic_recv_lock);
drop:
/* Throw the packet out. */
kfree_skb(skb);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 195 | 51.32% | 4 | 20.00% |
David S. Miller | 125 | 32.89% | 3 | 15.00% |
Linus Torvalds | 21 | 5.53% | 2 | 10.00% |
Hideaki Yoshifuji / 吉藤英明 | 10 | 2.63% | 3 | 15.00% |
Eric W. Biedermann | 7 | 1.84% | 1 | 5.00% |
Arnaldo Carvalho de Melo | 6 | 1.58% | 1 | 5.00% |
Ian Morris | 5 | 1.32% | 1 | 5.00% |
Philippe De Muyter | 4 | 1.05% | 1 | 5.00% |
Al Viro | 3 | 0.79% | 1 | 5.00% |
Pavel Emelyanov | 2 | 0.53% | 1 | 5.00% |
Fabian Frederick | 1 | 0.26% | 1 | 5.00% |
Uwe Kleine-König | 1 | 0.26% | 1 | 5.00% |
Total | 380 | 100.00% | 20 | 100.00% |
/*
* Send RARP request packet over a single interface.
*/
static void __init ic_rarp_send_if(struct ic_device *d)
{
struct net_device *dev = d->dev;
arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0, dev, 0, NULL,
dev->dev_addr, dev->dev_addr);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 42 | 95.45% | 3 | 75.00% |
Linus Torvalds | 2 | 4.55% | 1 | 25.00% |
Total | 44 | 100.00% | 4 | 100.00% |
#endif
/*
* Predefine Nameservers
*/
static inline void __init ic_nameservers_predef(void)
{
int i;
for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
ic_nameservers[i] = NONE;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andy Shevchenko | 33 | 100.00% | 1 | 100.00% |
Total | 33 | 100.00% | 1 | 100.00% |
/*
* DHCP/BOOTP support.
*/
#ifdef IPCONFIG_BOOTP
struct bootp_pkt { /* BOOTP packet format */
struct iphdr iph; /* IP header */
struct udphdr udph; /* UDP header */
u8 op; /* 1=request, 2=reply */
u8 htype; /* HW address type */
u8 hlen; /* HW address length */
u8 hops; /* Used only by gateways */
__be32 xid; /* Transaction ID */
__be16 secs; /* Seconds since we started */
__be16 flags; /* Just what it says */
__be32 client_ip; /* Client's IP address if known */
__be32 your_ip; /* Assigned IP address */
__be32 server_ip; /* (Next, e.g. NFS) Server's IP address */
__be32 relay_ip; /* IP address of BOOTP relay */
u8 hw_addr[16]; /* Client's HW address */
u8 serv_name[64]; /* Server host name */
u8 boot_file[128]; /* Name of boot file */
u8 exten[312]; /* DHCP options / BOOTP vendor extensions */
};
/* packet ops */
#define BOOTP_REQUEST 1
#define BOOTP_REPLY 2
/* DHCP message types */
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCPDECLINE 4
#define DHCPACK 5
#define DHCPNAK 6
#define DHCPRELEASE 7
#define DHCPINFORM 8
static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
static struct packet_type bootp_packet_type __initdata = {
.type = cpu_to_be16(ETH_P_IP),
.func = ic_bootp_recv,
};
/*
* Initialize DHCP/BOOTP extension fields in the request.
*/
static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };
#ifdef IPCONFIG_DHCP
static void __init
ic_dhcp_init_options(u8 *options, struct ic_device *d)
{
u8 mt = ((ic_servaddr == NONE)
? DHCPDISCOVER : DHCPREQUEST);
u8 *e = options;
int len;
pr_debug("DHCP: Sending message type %d (%s)\n", mt, d->dev->name);
memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
e += 4;
*e++ = 53; /* DHCP message type */
*e++ = 1;
*e++ = mt;
if (mt == DHCPREQUEST) {
*e++ = 54; /* Server ID (IP address) */
*e++ = 4;
memcpy(e, &ic_servaddr, 4);
e += 4;
*e++ = 50; /* Requested IP address */
*e++ = 4;
memcpy(e, &ic_myaddr, 4);
e += 4;
}
/* always? */
{
static const u8 ic_req_params[] = {
1, /* Subnet mask */
3, /* Default gateway */
6, /* DNS server */
12, /* Host name */
15, /* Domain name */
17, /* Boot path */
26, /* MTU */
40, /* NIS domain name */
};
*e++ = 55; /* Parameter request list */
*e++ = sizeof(ic_req_params);
memcpy(e, ic_req_params, sizeof(ic_req_params));
e += sizeof(ic_req_params);
if (ic_host_name_set) {
*e++ = 12; /* host-name */
len = strlen(utsname()->nodename);
*e++ = len;
memcpy(e, utsname()->nodename, len);
e += len;
}
if (*vendor_class_identifier) {
pr_info("DHCP: sending class identifier \"%s\"\n",
vendor_class_identifier);
*e++ = 60; /* Class-identifier */
len = strlen(vendor_class_identifier);
*e++ = len;
memcpy(e, vendor_class_identifier, len);
e += len;
}
len = strlen(dhcp_client_identifier + 1);
/* the minimum length of identifier is 2, include 1 byte type,
* and can not be larger than the length of options
*/
if (len >= 1 && len < 312 - (e - options) - 1) {
*e++ = 61;
*e++ = len + 1;
memcpy(e, dhcp_client_identifier, len + 1);
e += len + 1;
}
}
*e++ = 255; /* End of the list */
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 179 | 47.23% | 1 | 9.09% |
Li RongQing | 61 | 16.09% | 1 | 9.09% |
Rainer Jochem | 49 | 12.93% | 1 | 9.09% |
Fengguang Wu | 45 | 11.87% | 1 | 9.09% |
Linus Torvalds (pre-git) | 27 | 7.12% | 2 | 18.18% |
Uwe Kleine-König | 12 | 3.17% | 1 | 9.09% |
Chris Friesen | 3 | 0.79% | 1 | 9.09% |
Joe Perches | 1 | 0.26% | 1 | 9.09% |
Al Viro | 1 | 0.26% | 1 | 9.09% |
Bastian Stender | 1 | 0.26% | 1 | 9.09% |
Total | 379 | 100.00% | 11 | 100.00% |
#endif /* IPCONFIG_DHCP */
static void __init ic_bootp_init_ext(u8 *e)
{
memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
e += 4;
*e++ = 1; /* Subnet mask request */
*e++ = 4;
e += 4;
*e++ = 3; /* Default gateway request */
*e++ = 4;
e += 4;
*e++ = 5; /* Name server request */
*e++ = 8;
e += 8;
*e++ = 12; /* Host name request */
*e++ = 32;
e += 32;