aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/net_kern.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/net_kern.c')
-rw-r--r--arch/um/drivers/net_kern.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 721e2601a75d..fe865d9a3721 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -96,7 +96,6 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
96static int uml_net_open(struct net_device *dev) 96static int uml_net_open(struct net_device *dev)
97{ 97{
98 struct uml_net_private *lp = dev->priv; 98 struct uml_net_private *lp = dev->priv;
99 char addr[sizeof("255.255.255.255\0")];
100 int err; 99 int err;
101 100
102 spin_lock(&lp->lock); 101 spin_lock(&lp->lock);
@@ -107,7 +106,7 @@ static int uml_net_open(struct net_device *dev)
107 } 106 }
108 107
109 if(!lp->have_mac){ 108 if(!lp->have_mac){
110 dev_ip_addr(dev, addr, &lp->mac[2]); 109 dev_ip_addr(dev, &lp->mac[2]);
111 set_ether_mac(dev, lp->mac); 110 set_ether_mac(dev, lp->mac);
112 } 111 }
113 112
@@ -664,8 +663,6 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
664 void *ptr) 663 void *ptr)
665{ 664{
666 struct in_ifaddr *ifa = ptr; 665 struct in_ifaddr *ifa = ptr;
667 u32 addr = ifa->ifa_address;
668 u32 netmask = ifa->ifa_mask;
669 struct net_device *dev = ifa->ifa_dev->dev; 666 struct net_device *dev = ifa->ifa_dev->dev;
670 struct uml_net_private *lp; 667 struct uml_net_private *lp;
671 void (*proc)(unsigned char *, unsigned char *, void *); 668 void (*proc)(unsigned char *, unsigned char *, void *);
@@ -685,14 +682,8 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
685 break; 682 break;
686 } 683 }
687 if(proc != NULL){ 684 if(proc != NULL){
688 addr_buf[0] = addr & 0xff; 685 memcpy(addr_buf, &ifa->ifa_address, sizeof(addr_buf));
689 addr_buf[1] = (addr >> 8) & 0xff; 686 memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf));
690 addr_buf[2] = (addr >> 16) & 0xff;
691 addr_buf[3] = addr >> 24;
692 netmask_buf[0] = netmask & 0xff;
693 netmask_buf[1] = (netmask >> 8) & 0xff;
694 netmask_buf[2] = (netmask >> 16) & 0xff;
695 netmask_buf[3] = netmask >> 24;
696 (*proc)(addr_buf, netmask_buf, &lp->user); 687 (*proc)(addr_buf, netmask_buf, &lp->user);
697 } 688 }
698 return(NOTIFY_DONE); 689 return(NOTIFY_DONE);
@@ -774,27 +765,18 @@ int setup_etheraddr(char *str, unsigned char *addr)
774 return(1); 765 return(1);
775} 766}
776 767
777void dev_ip_addr(void *d, char *buf, char *bin_buf) 768void dev_ip_addr(void *d, unsigned char *bin_buf)
778{ 769{
779 struct net_device *dev = d; 770 struct net_device *dev = d;
780 struct in_device *ip = dev->ip_ptr; 771 struct in_device *ip = dev->ip_ptr;
781 struct in_ifaddr *in; 772 struct in_ifaddr *in;
782 u32 addr;
783 773
784 if((ip == NULL) || ((in = ip->ifa_list) == NULL)){ 774 if((ip == NULL) || ((in = ip->ifa_list) == NULL)){
785 printk(KERN_WARNING "dev_ip_addr - device not assigned an " 775 printk(KERN_WARNING "dev_ip_addr - device not assigned an "
786 "IP address\n"); 776 "IP address\n");
787 return; 777 return;
788 } 778 }
789 addr = in->ifa_address; 779 memcpy(bin_buf, &in->ifa_address, sizeof(in->ifa_address));
790 sprintf(buf, "%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff,
791 (addr >> 16) & 0xff, addr >> 24);
792 if(bin_buf){
793 bin_buf[0] = addr & 0xff;
794 bin_buf[1] = (addr >> 8) & 0xff;
795 bin_buf[2] = (addr >> 16) & 0xff;
796 bin_buf[3] = addr >> 24;
797 }
798} 780}
799 781
800void set_ether_mac(void *d, unsigned char *addr) 782void set_ether_mac(void *d, unsigned char *addr)
@@ -829,14 +811,8 @@ void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *,
829 if(ip == NULL) return; 811 if(ip == NULL) return;
830 in = ip->ifa_list; 812 in = ip->ifa_list;
831 while(in != NULL){ 813 while(in != NULL){
832 address[0] = in->ifa_address & 0xff; 814 memcpy(address, &in->ifa_address, sizeof(address));
833 address[1] = (in->ifa_address >> 8) & 0xff; 815 memcpy(netmask, &in->ifa_mask, sizeof(netmask));
834 address[2] = (in->ifa_address >> 16) & 0xff;
835 address[3] = in->ifa_address >> 24;
836 netmask[0] = in->ifa_mask & 0xff;
837 netmask[1] = (in->ifa_mask >> 8) & 0xff;
838 netmask[2] = (in->ifa_mask >> 16) & 0xff;
839 netmask[3] = in->ifa_mask >> 24;
840 (*cb)(address, netmask, arg); 816 (*cb)(address, netmask, arg);
841 in = in->ifa_next; 817 in = in->ifa_next;
842 } 818 }