Commit 1b29fc2c authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[IPV6] address: Convert address lookup to new netlink api

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b933f716
...@@ -3234,58 +3234,54 @@ static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -3234,58 +3234,54 @@ static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb)
return inet6_dump_addr(skb, cb, type); return inet6_dump_addr(skb, cb, type);
} }
static int inet6_rtm_getaddr(struct sk_buff *in_skb, static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
struct nlmsghdr* nlh, void *arg) void *arg)
{ {
struct rtattr **rta = arg; struct ifaddrmsg *ifm;
struct ifaddrmsg *ifm = NLMSG_DATA(nlh); struct nlattr *tb[IFA_MAX+1];
struct in6_addr *addr = NULL; struct in6_addr *addr = NULL;
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct inet6_ifaddr *ifa; struct inet6_ifaddr *ifa;
struct sk_buff *skb; struct sk_buff *skb;
int size = NLMSG_SPACE(sizeof(struct ifaddrmsg) + INET6_IFADDR_RTA_SPACE); int payload = sizeof(struct ifaddrmsg) + INET6_IFADDR_RTA_SPACE;
int err; int err;
if (rta[IFA_ADDRESS-1]) { err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
if (RTA_PAYLOAD(rta[IFA_ADDRESS-1]) < sizeof(*addr)) if (err < 0)
return -EINVAL; goto errout;
addr = RTA_DATA(rta[IFA_ADDRESS-1]);
} addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL]);
if (rta[IFA_LOCAL-1]) { if (addr == NULL) {
if (RTA_PAYLOAD(rta[IFA_LOCAL-1]) < sizeof(*addr) || err = -EINVAL;
(addr && memcmp(addr, RTA_DATA(rta[IFA_LOCAL-1]), sizeof(*addr)))) goto errout;
return -EINVAL;
addr = RTA_DATA(rta[IFA_LOCAL-1]);
} }
if (addr == NULL)
return -EINVAL;
ifm = nlmsg_data(nlh);
if (ifm->ifa_index) if (ifm->ifa_index)
dev = __dev_get_by_index(ifm->ifa_index); dev = __dev_get_by_index(ifm->ifa_index);
if ((ifa = ipv6_get_ifaddr(addr, dev, 1)) == NULL) if ((ifa = ipv6_get_ifaddr(addr, dev, 1)) == NULL) {
return -EADDRNOTAVAIL; err = -EADDRNOTAVAIL;
goto errout;
}
if ((skb = alloc_skb(size, GFP_KERNEL)) == NULL) { if ((skb = nlmsg_new(nlmsg_total_size(payload), GFP_KERNEL)) == NULL) {
err = -ENOBUFS; err = -ENOBUFS;
goto out; goto errout_ifa;
} }
NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid, err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid,
nlh->nlmsg_seq, RTM_NEWADDR, 0); nlh->nlmsg_seq, RTM_NEWADDR, 0);
if (err < 0) { if (err < 0) {
err = -EMSGSIZE; kfree_skb(skb);
goto out_free; goto errout_ifa;
} }
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid); err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
out: errout_ifa:
in6_ifa_put(ifa); in6_ifa_put(ifa);
errout:
return err; return err;
out_free:
kfree_skb(skb);
goto out;
} }
static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa) static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
......
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