Commit 8991fd88 authored by Max Filippov's avatar Max Filippov Committed by Chris Zankel

xtensa: ISS: drop IP setup, clean up MAC setup

Without proper MAC setup network device doesn't work. IP setup is
redundant and may be done with 'ip=...' kernel parameter.
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Signed-off-by: default avatarChris Zankel <chris@zankel.net>
parent 358b1810
...@@ -81,9 +81,6 @@ struct iss_net_private { ...@@ -81,9 +81,6 @@ struct iss_net_private {
int index; int index;
int mtu; int mtu;
unsigned char mac[ETH_ALEN];
int have_mac;
struct { struct {
union { union {
struct tuntap_info tuntap; struct tuntap_info tuntap;
...@@ -123,44 +120,41 @@ static char *split_if_spec(char *str, ...) ...@@ -123,44 +120,41 @@ static char *split_if_spec(char *str, ...)
return str; return str;
} }
/* Set Ethernet address of the specified device. */
/* Return the IP address as a string for a given device. */ static void setup_etheraddr(struct net_device *dev, char *str)
static void dev_ip_addr(void *d, char *buf, char *bin_buf)
{ {
struct net_device *dev = d; unsigned char *addr = dev->dev_addr;
struct in_device *ip = dev->ip_ptr;
struct in_ifaddr *in;
__be32 addr;
if (ip == NULL || ip->ifa_list == NULL) { if (str == NULL)
pr_warn("Device not assigned an IP address!\n"); goto random;
return;
}
in = ip->ifa_list; if (!mac_pton(str, addr)) {
pr_err("%s: failed to parse '%s' as an ethernet address\n",
addr = in->ifa_address; dev->name, str);
sprintf(buf, "%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff, goto random;
(addr >> 16) & 0xff, addr >> 24);
if (bin_buf) {
bin_buf[0] = addr & 0xff;
bin_buf[1] = (addr >> 8) & 0xff;
bin_buf[2] = (addr >> 16) & 0xff;
bin_buf[3] = addr >> 24;
} }
} if (is_multicast_ether_addr(addr)) {
pr_err("%s: attempt to assign a multicast ethernet address\n",
/* Set Ethernet address of the specified device. */ dev->name);
goto random;
}
if (!is_valid_ether_addr(addr)) {
pr_err("%s: attempt to assign an invalid ethernet address\n",
dev->name);
goto random;
}
if (!is_local_ether_addr(addr))
pr_warn("%s: assigning a globally valid ethernet address\n",
dev->name);
return;
static inline void set_ether_mac(void *d, unsigned char *addr) random:
{ pr_info("%s: choosing a random ethernet address\n",
struct net_device *dev = d; dev->name);
memcpy(dev->dev_addr, addr, ETH_ALEN); eth_hw_addr_random(dev);
} }
/* ======================= TUNTAP TRANSPORT INTERFACE ====================== */ /* ======================= TUNTAP TRANSPORT INTERFACE ====================== */
static int tuntap_open(struct iss_net_private *lp) static int tuntap_open(struct iss_net_private *lp)
...@@ -232,6 +226,7 @@ static int tuntap_poll(struct iss_net_private *lp) ...@@ -232,6 +226,7 @@ static int tuntap_poll(struct iss_net_private *lp)
static int tuntap_probe(struct iss_net_private *lp, int index, char *init) static int tuntap_probe(struct iss_net_private *lp, int index, char *init)
{ {
struct net_device *dev = lp->dev;
char *dev_name = NULL, *mac_str = NULL, *rem = NULL; char *dev_name = NULL, *mac_str = NULL, *rem = NULL;
/* Transport should be 'tuntap': ethX=tuntap,mac,dev_name */ /* Transport should be 'tuntap': ethX=tuntap,mac,dev_name */
...@@ -259,6 +254,7 @@ static int tuntap_probe(struct iss_net_private *lp, int index, char *init) ...@@ -259,6 +254,7 @@ static int tuntap_probe(struct iss_net_private *lp, int index, char *init)
} else } else
strcpy(lp->tp.info.tuntap.dev_name, TRANSPORT_TUNTAP_NAME); strcpy(lp->tp.info.tuntap.dev_name, TRANSPORT_TUNTAP_NAME);
setup_etheraddr(dev, mac_str);
lp->mtu = TRANSPORT_TUNTAP_MTU; lp->mtu = TRANSPORT_TUNTAP_MTU;
...@@ -369,7 +365,6 @@ static void iss_net_timer(unsigned long priv) ...@@ -369,7 +365,6 @@ static void iss_net_timer(unsigned long priv)
static int iss_net_open(struct net_device *dev) static int iss_net_open(struct net_device *dev)
{ {
struct iss_net_private *lp = netdev_priv(dev); struct iss_net_private *lp = netdev_priv(dev);
char addr[sizeof("255.255.255.255\0")];
int err; int err;
spin_lock(&lp->lock); spin_lock(&lp->lock);
...@@ -378,11 +373,6 @@ static int iss_net_open(struct net_device *dev) ...@@ -378,11 +373,6 @@ static int iss_net_open(struct net_device *dev)
if (err < 0) if (err < 0)
goto out; goto out;
if (!lp->have_mac) {
dev_ip_addr(dev, addr, &lp->mac[2]);
set_ether_mac(dev, lp->mac);
}
netif_start_queue(dev); netif_start_queue(dev);
/* clear buffer - it can happen that the host side of the interface /* clear buffer - it can happen that the host side of the interface
...@@ -540,8 +530,6 @@ static int iss_net_configure(int index, char *init) ...@@ -540,8 +530,6 @@ static int iss_net_configure(int index, char *init)
.lock = __SPIN_LOCK_UNLOCKED(lp.lock), .lock = __SPIN_LOCK_UNLOCKED(lp.lock),
.dev = dev, .dev = dev,
.index = index, .index = index,
.mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0 },
.have_mac = 0,
}; };
/* /*
...@@ -561,10 +549,7 @@ static int iss_net_configure(int index, char *init) ...@@ -561,10 +549,7 @@ static int iss_net_configure(int index, char *init)
goto errout; goto errout;
} }
printk(KERN_INFO "Netdevice %d ", index); pr_info("Netdevice %d (%pM)\n", index, dev->dev_addr);
if (lp->have_mac)
printk("(%pM) ", lp->mac);
printk(": ");
/* sysfs register */ /* sysfs register */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment