From 673b9e09cfee02c4782c9e9cf30f383c8042e7d9 Mon Sep 17 00:00:00 2001 From: rd235 Date: Tue, 30 Jun 2009 06:45:19 +0000 Subject: [PATCH] ipn_node: dev renamed as netdev, new chrdev field added git-svn-id: https://vde.svn.sourceforge.net/svnroot/vde/trunk@371 d37a7db1-d92d-0410-89df-f68f52f87b57 --- ipn/af_ipn.c | 23 ++++++++++++----------- ipn/af_ipn.h | 3 ++- ipn/ipn_chrdev.c | 26 ++++---------------------- ipn/ipn_netdev.c | 24 ++++++++++++------------ 4 files changed, 30 insertions(+), 46 deletions(-) diff --git a/ipn/af_ipn.c b/ipn/af_ipn.c index 5643f3c..7587950 100644 --- a/ipn/af_ipn.c +++ b/ipn/af_ipn.c @@ -251,7 +251,8 @@ struct ipn_node *ipn_node_create(struct net *net) ipn_node->descr[0]=0; ipn_node->portno=IPN_PORTNO_ANY; ipn_node->net=net; - ipn_node->dev=NULL; + ipn_node->netdev=NULL; + ipn_node->chrdev=0; ipn_node->proto_private=NULL; ipn_node->totmsgcount=0; ipn_node->oobmsgcount=0; @@ -397,7 +398,7 @@ static int ipn_terminate_node(struct ipn_node *ipn_node) (ipn_node->shutdown & SEND_SHUTDOWN)?0:-1); ipn_node->shutdown = SHUTDOWN_XMASK; up(&ipnn->ipnn_mutex); - if (ipn_node->dev) + if (ipn_node->netdev) ipn_netdev_close(ipn_node); /* No more network elements */ ipnn->refcnt--; @@ -484,7 +485,7 @@ static int _ipn_setpersist(struct ipn_node *ipn_node, int persist) static int ipn_setpersist(struct ipn_node *ipn_node, int persist) { int rv=0; - if (ipn_node->dev == NULL) + if (ipn_node->netdev == NULL) return -ENODEV; if (down_interruptible(&ipn_glob_mutex)) return -ERESTARTSYS; @@ -1013,8 +1014,8 @@ static int ipn_connect_netdev(struct socket *sock,struct ifreq *ifr) up(&ipn_glob_mutex); return -ERESTARTSYS; } - ipn_node->dev=ipn_netdev_alloc(ipn_node->net,ifr->ifr_flags,ifr->ifr_name,&err); - if (ipn_node->dev) { + ipn_node->netdev=ipn_netdev_alloc(ipn_node->net,ifr->ifr_flags,ifr->ifr_name,&err); + if (ipn_node->netdev) { int portno; portno = ipn_protocol_table[ipnn->protocol]->ipn_p_newport(ipn_node); if (portno >= 0 && portnomaxports) { @@ -1026,7 +1027,7 @@ static int ipn_connect_netdev(struct socket *sock,struct ifreq *ifr) if (err) { sock->state = SS_UNCONNECTED; ipn_protocol_table[ipnn->protocol]->ipn_p_delport(ipn_node); - ipn_node->dev=NULL; + ipn_node->netdev=NULL; ipn_node->portno= -1; ipn_node->flags &= ~IPN_NODEFLAG_DEVMASK; ipnn->connport[portno]=NULL; @@ -1038,7 +1039,7 @@ static int ipn_connect_netdev(struct socket *sock,struct ifreq *ifr) } else { ipn_netdev_close(ipn_node); err=-EADDRNOTAVAIL; - ipn_node->dev=NULL; + ipn_node->netdev=NULL; } } else err=-EINVAL; @@ -1180,8 +1181,8 @@ static int ipn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { case SIOCSIFHWADDR: if (capable(CAP_NET_ADMIN)) return -EPERM; - if (ipn_node->dev && (ipn_node->flags &IPN_NODEFLAG_TAP)) - return dev_set_mac_address(ipn_node->dev, &ifr.ifr_hwaddr); + if (ipn_node->netdev && (ipn_node->flags &IPN_NODEFLAG_TAP)) + return dev_set_mac_address(ipn_node->netdev, &ifr.ifr_hwaddr); else return -EADDRNOTAVAIL; } @@ -1312,7 +1313,7 @@ static int ipn_sendmsg(struct kiocb *kiocb, struct socket *sock, void ipn_proto_sendmsg(struct ipn_node *to, struct msgpool_item *msg) { if (to) { - if (to->dev) { + if (to->netdev) { ipn_netdev_sendmsg(to,msg); } else { /* socket send */ @@ -1343,7 +1344,7 @@ void ipn_proto_sendmsg(struct ipn_node *to, struct msgpool_item *msg) void ipn_proto_oobsendmsg(struct ipn_node *to, struct msgpool_item *msg) { if (to) { - if (!to->dev) { /* no oob to netdev */ + if (!to->netdev) { /* no oob to netdev */ struct msgitem *msgitem; struct ipn_network *ipnn=to->ipn; spin_lock(&to->msglock); diff --git a/ipn/af_ipn.h b/ipn/af_ipn.h index 701a763..cde82fa 100644 --- a/ipn/af_ipn.h +++ b/ipn/af_ipn.h @@ -139,7 +139,8 @@ struct ipn_node { struct list_head oobmsgqueue; wait_queue_head_t read_wait; struct net *net; - struct net_device *dev; + struct net_device *netdev; + dev_t chrdev; struct ipn_network *ipn; struct pre_bind_parms *pbp; void *proto_private; diff --git a/ipn/ipn_chrdev.c b/ipn/ipn_chrdev.c index 4670dc2..a2abddf 100644 --- a/ipn/ipn_chrdev.c +++ b/ipn/ipn_chrdev.c @@ -69,30 +69,12 @@ static int ipn_chrdev_open(struct inode *inode, struct file *filp) if ((mustshutdown & RCV_SHUTDOWN) && (mustshutdown & SEND_SHUTDOWN)) return -EACCES; -#if 0 - ipnn=ipn_chrdev_to_ipnn(inode->i_cdev); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) - ipn_node=ipn_node_create(NULL); -#else - ipn_node=ipn_node_create(&init_net); -#endif + err=ipn_node_create_connect(&ipn_node, ipn_chrdev_to_ipnn, inode->i_cdev); + filp->private_data=ipn_node; if (ipn_node) { - ipn_node->ipn = ipnn; - ipn_node->protocol=ipnn->protocol; - ipn_node->shutdown=mustshutdown; - filp->private_data = ipn_node; - - if ((err=ipn_node_connect(ipn_node)) != 0) - ipn_node_release(ipn_node); - return err; - } else - return -ENOMEM; -#endif - err=ipn_node_create_connect(&ipn_node, - ipn_chrdev_to_ipnn, inode->i_cdev); - if (ipn_node) ipn_node->shutdown=mustshutdown; - filp->private_data=ipn_node; + ipn_node->chrdev=inode->i_rdev; + } return err; } diff --git a/ipn/ipn_netdev.c b/ipn/ipn_netdev.c index 6a5ce31..167c10c 100644 --- a/ipn/ipn_netdev.c +++ b/ipn/ipn_netdev.c @@ -164,11 +164,11 @@ int ipn_netdev_activate(struct ipn_node *ipn_node) switch (ipn_node->flags & IPN_NODEFLAG_DEVMASK) { case IPN_NODEFLAG_TAP: { - struct ipntap *ipntap=netdev_priv(ipn_node->dev); + struct ipntap *ipntap=netdev_priv(ipn_node->netdev); ipntap->ipn_node=ipn_node; rtnl_lock(); - if ((rv=register_netdevice(ipn_node->dev)) == 0) - rcu_assign_pointer(ipn_node->dev->ipn_port, + if ((rv=register_netdevice(ipn_node->netdev)) == 0) + rcu_assign_pointer(ipn_node->netdev->ipn_port, #ifdef IPN_STEALING (void *) #endif @@ -176,18 +176,18 @@ int ipn_netdev_activate(struct ipn_node *ipn_node) rtnl_unlock(); if (rv) {/* error! */ ipn_node->flags &= ~IPN_NODEFLAG_DEVMASK; - free_netdev(ipn_node->dev); + free_netdev(ipn_node->netdev); } } break; case IPN_NODEFLAG_GRAB: rtnl_lock(); - rcu_assign_pointer(ipn_node->dev->ipn_port, + rcu_assign_pointer(ipn_node->netdev->ipn_port, #ifdef IPN_STEALING (void *) #endif ipn_node); - dev_set_promiscuity(ipn_node->dev,1); + dev_set_promiscuity(ipn_node->netdev,1); rtnl_unlock(); rv=0; break; @@ -201,16 +201,16 @@ void ipn_netdev_close(struct ipn_node *ipn_node) case IPN_NODEFLAG_TAP: ipn_node->flags &= ~IPN_NODEFLAG_DEVMASK; rtnl_lock(); - rcu_assign_pointer(ipn_node->dev->ipn_port, NULL); - unregister_netdevice(ipn_node->dev); + rcu_assign_pointer(ipn_node->netdev->ipn_port, NULL); + unregister_netdevice(ipn_node->netdev); rtnl_unlock(); - free_netdev(ipn_node->dev); + free_netdev(ipn_node->netdev); break; case IPN_NODEFLAG_GRAB: ipn_node->flags &= ~IPN_NODEFLAG_DEVMASK; rtnl_lock(); - rcu_assign_pointer(ipn_node->dev->ipn_port, NULL); - dev_set_promiscuity(ipn_node->dev,-1); + rcu_assign_pointer(ipn_node->netdev->ipn_port, NULL); + dev_set_promiscuity(ipn_node->netdev,-1); rtnl_unlock(); break; } @@ -219,7 +219,7 @@ void ipn_netdev_close(struct ipn_node *ipn_node) void ipn_netdev_sendmsg(struct ipn_node *to,struct msgpool_item *msg) { struct sk_buff *skb; - struct net_device *dev=to->dev; + struct net_device *dev=to->netdev; struct ipntap *ipntap=netdev_priv(dev); if (msg->len > dev->mtu) -- 2.11.4.GIT