Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34680
b: refs/heads/master
c: 7198f8c
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Graf authored and David S. Miller committed Sep 22, 2006
1 parent 3aabe48 commit de2046f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 680a27a23af45307095ae432dd0bc859e1fbe219
refs/heads/master: 7198f8cec12ccec6d6f2e18c08ecc8c66c8aaf93
45 changes: 25 additions & 20 deletions trunk/net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2908,24 +2908,14 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
return inet6_addr_del(ifm->ifa_index, pfx, ifm->ifa_prefixlen);
}

static int
inet6_addr_modify(int ifindex, struct in6_addr *pfx,
__u32 prefered_lft, __u32 valid_lft)
static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 prefered_lft,
u32 valid_lft)
{
struct inet6_ifaddr *ifp = NULL;
struct net_device *dev;
int ifa_flags = 0;

if ((dev = __dev_get_by_index(ifindex)) == NULL)
return -ENODEV;

if (!valid_lft || (prefered_lft > valid_lft))
return -EINVAL;

ifp = ipv6_get_ifaddr(pfx, dev, 1);
if (ifp == NULL)
return -ENOENT;

if (valid_lft == INFINITY_LIFE_TIME)
ifa_flags = IFA_F_PERMANENT;
else if (valid_lft >= 0x7FFFFFFF/HZ)
Expand All @@ -2947,7 +2937,6 @@ inet6_addr_modify(int ifindex, struct in6_addr *pfx,
spin_unlock_bh(&ifp->lock);
if (!(ifp->flags&IFA_F_TENTATIVE))
ipv6_ifa_notify(0, ifp);
in6_ifa_put(ifp);

addrconf_verify(0);

Expand All @@ -2960,6 +2949,8 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct ifaddrmsg *ifm;
struct nlattr *tb[IFA_MAX+1];
struct in6_addr *pfx;
struct inet6_ifaddr *ifa;
struct net_device *dev;
u32 valid_lft, preferred_lft;
int err;

Expand All @@ -2983,15 +2974,29 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
valid_lft = INFINITY_LIFE_TIME;
}

if (nlh->nlmsg_flags & NLM_F_REPLACE) {
err = inet6_addr_modify(ifm->ifa_index, pfx,
preferred_lft, valid_lft);
if (err == 0 || !(nlh->nlmsg_flags & NLM_F_CREATE))
return err;
dev = __dev_get_by_index(ifm->ifa_index);
if (dev == NULL)
return -ENODEV;

ifa = ipv6_get_ifaddr(pfx, dev, 1);
if (ifa == NULL) {
/*
* It would be best to check for !NLM_F_CREATE here but
* userspace alreay relies on not having to provide this.
*/
return inet6_addr_add(ifm->ifa_index, pfx, ifm->ifa_prefixlen,
preferred_lft, valid_lft);
}

return inet6_addr_add(ifm->ifa_index, pfx, ifm->ifa_prefixlen,
preferred_lft, valid_lft);
if (nlh->nlmsg_flags & NLM_F_EXCL ||
!(nlh->nlmsg_flags & NLM_F_REPLACE))
err = -EEXIST;
else
err = inet6_addr_modify(ifa, preferred_lft, valid_lft);

in6_ifa_put(ifa);

return err;
}

static void put_ifaddrmsg(struct nlmsghdr *nlh, u8 prefixlen, u8 flags,
Expand Down

0 comments on commit de2046f

Please sign in to comment.