int event;
unsigned int flags;
int netnsid;
+ int ifindex;
enum addr_type_t type;
};
static int inet6_valid_dump_ifaddr_req(const struct nlmsghdr *nlh,
struct inet6_fill_args *fillargs,
struct net **tgt_net, struct sock *sk,
- struct netlink_ext_ack *extack)
+ struct netlink_callback *cb)
{
+ struct netlink_ext_ack *extack = cb->extack;
struct nlattr *tb[IFA_MAX+1];
struct ifaddrmsg *ifm;
int err, i;
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for address dump request");
return -EINVAL;
}
- if (ifm->ifa_index) {
- NL_SET_ERR_MSG_MOD(extack, "Filter by device index not supported for address dump");
- return -EINVAL;
+
+ fillargs->ifindex = ifm->ifa_index;
+ if (fillargs->ifindex) {
+ cb->answer_flags |= NLM_F_DUMP_FILTERED;
+ fillargs->flags |= NLM_F_DUMP_FILTERED;
}
err = nlmsg_parse_strict(nlh, sizeof(*ifm), tb, IFA_MAX,
int err;
err = inet6_valid_dump_ifaddr_req(nlh, &fillargs, &tgt_net,
- skb->sk, cb->extack);
+ skb->sk, cb);
if (err < 0)
return err;
+
+ if (fillargs.ifindex) {
+ dev = __dev_get_by_index(tgt_net, fillargs.ifindex);
+ if (!dev)
+ return -ENODEV;
+ idev = __in6_dev_get(dev);
+ if (idev) {
+ err = in6_dump_addrs(idev, skb, cb, s_ip_idx,
+ &fillargs);
+ }
+ goto put_tgt_net;
+ }
}
rcu_read_lock();
rcu_read_unlock();
cb->args[0] = h;
cb->args[1] = idx;
+put_tgt_net:
if (fillargs.netnsid >= 0)
put_net(tgt_net);