]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/if_netlink.c
Zebra.h header cleanup (#4444)
[mirror_frr.git] / zebra / if_netlink.c
index ce0834f19003d3c862207a86b363e394e043b1b9..df8d4bfe1541b1bd0a7e57da9be79ecb31983ac6 100644 (file)
@@ -1396,6 +1396,32 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        return 0;
 }
 
+int netlink_protodown(struct interface *ifp, bool down)
+{
+       struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
+
+       struct {
+               struct nlmsghdr n;
+               struct ifinfomsg ifa;
+               char buf[NL_PKT_BUF_SIZE];
+       } req;
+
+       memset(&req, 0, sizeof(req));
+
+       req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+       req.n.nlmsg_flags = NLM_F_REQUEST;
+       req.n.nlmsg_type = RTM_SETLINK;
+       req.n.nlmsg_pid = zns->netlink_cmd.snl.nl_pid;
+
+       req.ifa.ifi_index = ifp->ifindex;
+
+       addattr_l(&req.n, sizeof(req), IFLA_PROTO_DOWN, &down, 4);
+       addattr_l(&req.n, sizeof(req), IFLA_LINK, &ifp->ifindex, 4);
+
+       return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
+                           0);
+}
+
 /* Interface information read by netlink. */
 void interface_list(struct zebra_ns *zns)
 {