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

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Thomas Graf 2006-09-18 00:10:50 -07:00 коммит произвёл David S. Miller
Родитель b933f7166b
Коммит 1b29fc2c8b
1 изменённых файлов: 27 добавлений и 31 удалений

Просмотреть файл

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