+static int system_neigh(struct device *dev, struct device_neighbor *neighbor, int cmd)
+{
+ int alen = ((neighbor->flags & DEVADDR_FAMILY) == DEVADDR_INET4) ? 4 : 16;
+ unsigned int flags = 0;
+ struct ndmsg ndm = {
+ .ndm_family = (alen == 4) ? AF_INET : AF_INET6,
+ .ndm_ifindex = dev->ifindex,
+ .ndm_state = NUD_PERMANENT,
+ .ndm_flags = (neighbor->proxy ? NTF_PROXY : 0) | (neighbor->router ? NTF_ROUTER : 0),
+ };
+ struct nl_msg *msg;
+
+ if (!dev)
+ return 1;
+
+ if (cmd == RTM_NEWNEIGH)
+ flags |= NLM_F_CREATE | NLM_F_REPLACE;
+
+ msg = nlmsg_alloc_simple(cmd, flags);
+
+ if (!msg)
+ return -1;
+
+ nlmsg_append(msg, &ndm, sizeof(ndm), 0);
+
+ nla_put(msg, NDA_DST, alen, &neighbor->addr);
+ if (neighbor->flags & DEVNEIGH_MAC)
+ nla_put(msg, NDA_LLADDR, sizeof(neighbor->macaddr), &neighbor->macaddr);
+
+
+ return system_rtnl_call(msg);
+}
+
+int system_add_neighbor(struct device *dev, struct device_neighbor *neighbor)
+{
+ return system_neigh(dev, neighbor, RTM_NEWNEIGH);
+}
+
+int system_del_neighbor(struct device *dev, struct device_neighbor *neighbor)
+{
+ int rval = system_neigh(dev, neighbor, RTM_DELNEIGH);
+ netifd_log_message(L_NOTICE,"return delete %d", rval);
+ return rval;
+}
+