}
 }
 
+static void rtnl_net_notifyid(struct net *net, struct net *peer, int cmd,
+                             int id);
 static int alloc_netid(struct net *net, struct net *peer, int reqid)
 {
-       int min = 0, max = 0;
+       int min = 0, max = 0, id;
 
        ASSERT_RTNL();
 
                max = reqid + 1;
        }
 
-       return idr_alloc(&net->netns_ids, peer, min, max, GFP_KERNEL);
+       id = idr_alloc(&net->netns_ids, peer, min, max, GFP_KERNEL);
+       if (id >= 0)
+               rtnl_net_notifyid(net, peer, RTM_NEWNSID, id);
+
+       return id;
 }
 
 /* This function is used by idr_for_each(). If net is equal to peer, the
                for_each_net(tmp) {
                        int id = __peernet2id(tmp, net, false);
 
-                       if (id >= 0)
+                       if (id >= 0) {
+                               rtnl_net_notifyid(tmp, net, RTM_DELNSID, id);
                                idr_remove(&tmp->netns_ids, id);
+                       }
                }
                idr_destroy(&net->netns_ids);
 
 }
 
 static int rtnl_net_fill(struct sk_buff *skb, u32 portid, u32 seq, int flags,
-                        int cmd, struct net *net, struct net *peer)
+                        int cmd, struct net *net, struct net *peer,
+                        int nsid)
 {
        struct nlmsghdr *nlh;
        struct rtgenmsg *rth;
        rth = nlmsg_data(nlh);
        rth->rtgen_family = AF_UNSPEC;
 
-       id = __peernet2id(net, peer, false);
-       if  (id < 0)
-               id = NETNSA_NSID_NOT_ASSIGNED;
+       if (nsid >= 0) {
+               id = nsid;
+       } else {
+               id = __peernet2id(net, peer, false);
+               if  (id < 0)
+                       id = NETNSA_NSID_NOT_ASSIGNED;
+       }
        if (nla_put_s32(skb, NETNSA_NSID, id))
                goto nla_put_failure;
 
        }
 
        err = rtnl_net_fill(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 0,
-                           RTM_GETNSID, net, peer);
+                           RTM_GETNSID, net, peer, -1);
        if (err < 0)
                goto err_out;
 
        return err;
 }
 
+static void rtnl_net_notifyid(struct net *net, struct net *peer, int cmd,
+                             int id)
+{
+       struct sk_buff *msg;
+       int err = -ENOMEM;
+
+       msg = nlmsg_new(rtnl_net_get_size(), GFP_KERNEL);
+       if (!msg)
+               goto out;
+
+       err = rtnl_net_fill(msg, 0, 0, 0, cmd, net, peer, id);
+       if (err < 0)
+               goto err_out;
+
+       rtnl_notify(msg, net, 0, RTNLGRP_NSID, NULL, 0);
+       return;
+
+err_out:
+       nlmsg_free(msg);
+out:
+       rtnl_set_sk_err(net, RTNLGRP_NSID, err);
+}
+
 static int __init net_ns_init(void)
 {
        struct net_generic *ng;