diff options
author | Christoph Hellwig <hch@lst.de> | 2020-05-18 08:28:07 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-18 17:35:02 -0700 |
commit | a50049235483b0337d129e2878e99750e4da3ac2 (patch) | |
tree | 51b1a086c91d3c673d14da9538d736daef508c08 /net/appletalk/ddp.c | |
parent | 3986912f6a9aae50945fc9d3513c621381eba1aa (diff) |
appletalk: factor out a atrtr_ioctl_addrt helper
Add a helper than can be shared with the upcoming compat ioctl handler.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/appletalk/ddp.c')
-rw-r--r-- | net/appletalk/ddp.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index b41375d4d295..4177a74f6543 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -867,6 +867,24 @@ static int atif_ioctl(int cmd, void __user *arg) return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0; } +static int atrtr_ioctl_addrt(struct rtentry *rt) +{ + struct net_device *dev = NULL; + + if (rt->rt_dev) { + char name[IFNAMSIZ]; + + if (copy_from_user(name, rt->rt_dev, IFNAMSIZ-1)) + return -EFAULT; + name[IFNAMSIZ-1] = '\0'; + + dev = __dev_get_by_name(&init_net, name); + if (!dev) + return -ENODEV; + } + return atrtr_create(rt, dev); +} + /* Routing ioctl() calls */ static int atrtr_ioctl(unsigned int cmd, void __user *arg) { @@ -882,19 +900,8 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg) return atrtr_delete(&((struct sockaddr_at *) &rt.rt_dst)->sat_addr); - case SIOCADDRT: { - struct net_device *dev = NULL; - if (rt.rt_dev) { - char name[IFNAMSIZ]; - if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) - return -EFAULT; - name[IFNAMSIZ-1] = '\0'; - dev = __dev_get_by_name(&init_net, name); - if (!dev) - return -ENODEV; - } - return atrtr_create(&rt, dev); - } + case SIOCADDRT: + return atrtr_ioctl_addrt(&rt); } return -EINVAL; } |