Lines Matching refs:nh

172 static inline struct rtattr *rtattr_hdr(struct nlmsghdr *nh)  in rtattr_hdr()  argument
174 return (struct rtattr *)((char *)(nh) + RTA_ALIGN((nh)->nlmsg_len)); in rtattr_hdr()
177 static int rtattr_pack(struct nlmsghdr *nh, size_t req_sz, in rtattr_pack() argument
181 struct rtattr *attr = rtattr_hdr(nh); in rtattr_pack()
182 size_t nl_size = RTA_ALIGN(nh->nlmsg_len) + RTA_LENGTH(size); in rtattr_pack()
188 nh->nlmsg_len = nl_size; in rtattr_pack()
197 static struct rtattr *_rtattr_begin(struct nlmsghdr *nh, size_t req_sz, in _rtattr_begin() argument
200 struct rtattr *ret = rtattr_hdr(nh); in _rtattr_begin()
202 if (rtattr_pack(nh, req_sz, rta_type, payload, size)) in _rtattr_begin()
208 static inline struct rtattr *rtattr_begin(struct nlmsghdr *nh, size_t req_sz, in rtattr_begin() argument
211 return _rtattr_begin(nh, req_sz, rta_type, 0, 0); in rtattr_begin()
214 static inline void rtattr_end(struct nlmsghdr *nh, struct rtattr *attr) in rtattr_end() argument
216 char *nlmsg_end = (char *)nh + nh->nlmsg_len; in rtattr_end()
221 static int veth_pack_peerb(struct nlmsghdr *nh, size_t req_sz, in veth_pack_peerb() argument
231 peer_attr = _rtattr_begin(nh, req_sz, VETH_INFO_PEER, &pi, sizeof(pi)); in veth_pack_peerb()
235 if (rtattr_pack(nh, req_sz, IFLA_IFNAME, peer, strlen(peer))) in veth_pack_peerb()
238 if (rtattr_pack(nh, req_sz, IFLA_NET_NS_FD, &ns, sizeof(ns))) in veth_pack_peerb()
241 rtattr_end(nh, peer_attr); in veth_pack_peerb()
274 struct nlmsghdr nh; in veth_add() member
282 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in veth_add()
283 req.nh.nlmsg_type = RTM_NEWLINK; in veth_add()
284 req.nh.nlmsg_flags = flags; in veth_add()
285 req.nh.nlmsg_seq = seq; in veth_add()
289 if (rtattr_pack(&req.nh, sizeof(req), IFLA_IFNAME, peera, strlen(peera))) in veth_add()
292 if (rtattr_pack(&req.nh, sizeof(req), IFLA_NET_NS_FD, &ns_a, sizeof(ns_a))) in veth_add()
295 link_info = rtattr_begin(&req.nh, sizeof(req), IFLA_LINKINFO); in veth_add()
299 if (rtattr_pack(&req.nh, sizeof(req), IFLA_INFO_KIND, veth_type, sizeof(veth_type))) in veth_add()
302 info_data = rtattr_begin(&req.nh, sizeof(req), IFLA_INFO_DATA); in veth_add()
306 if (veth_pack_peerb(&req.nh, sizeof(req), peerb, ns_b)) in veth_add()
309 rtattr_end(&req.nh, info_data); in veth_add()
310 rtattr_end(&req.nh, link_info); in veth_add()
312 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in veth_add()
324 struct nlmsghdr nh; in ip4_addr_set() member
330 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in ip4_addr_set()
331 req.nh.nlmsg_type = RTM_NEWADDR; in ip4_addr_set()
332 req.nh.nlmsg_flags = flags; in ip4_addr_set()
333 req.nh.nlmsg_seq = seq; in ip4_addr_set()
348 if (rtattr_pack(&req.nh, sizeof(req), IFA_LOCAL, &addr, sizeof(addr))) in ip4_addr_set()
351 if (rtattr_pack(&req.nh, sizeof(req), IFA_ADDRESS, &addr, sizeof(addr))) in ip4_addr_set()
354 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in ip4_addr_set()
364 struct nlmsghdr nh; in link_set_up() member
370 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in link_set_up()
371 req.nh.nlmsg_type = RTM_NEWLINK; in link_set_up()
372 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in link_set_up()
373 req.nh.nlmsg_seq = seq; in link_set_up()
380 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in link_set_up()
391 struct nlmsghdr nh; in ip4_route_set() member
398 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.rt)); in ip4_route_set()
399 req.nh.nlmsg_type = RTM_NEWROUTE; in ip4_route_set()
400 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE; in ip4_route_set()
401 req.nh.nlmsg_seq = seq; in ip4_route_set()
409 if (rtattr_pack(&req.nh, sizeof(req), RTA_DST, &dst, sizeof(dst))) in ip4_route_set()
412 if (rtattr_pack(&req.nh, sizeof(req), RTA_PREFSRC, &src, sizeof(src))) in ip4_route_set()
415 if (rtattr_pack(&req.nh, sizeof(req), RTA_OIF, &index, sizeof(index))) in ip4_route_set()
418 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in ip4_route_set()
841 static int xfrm_state_pack_algo(struct nlmsghdr *nh, size_t req_sz, in xfrm_state_pack_algo() argument
903 if (rtattr_pack(nh, req_sz, type, &alg, sizeof(alg))) in xfrm_state_pack_algo()
918 if (rtattr_pack(nh, req_sz, type, &alg, sizeof(alg))) in xfrm_state_pack_algo()
934 struct nlmsghdr nh; in xfrm_state_add() member
940 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in xfrm_state_add()
941 req.nh.nlmsg_type = XFRM_MSG_NEWSA; in xfrm_state_add()
942 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_state_add()
943 req.nh.nlmsg_seq = seq; in xfrm_state_add()
969 if (xfrm_state_pack_algo(&req.nh, sizeof(req), desc)) in xfrm_state_add()
972 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_add()
1023 struct nlmsghdr nh; in xfrm_state_check() member
1027 struct nlmsghdr nh; in xfrm_state_check() member
1039 req.nh.nlmsg_len = NLMSG_LENGTH(0); in xfrm_state_check()
1040 req.nh.nlmsg_type = XFRM_MSG_GETSA; in xfrm_state_check()
1041 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; in xfrm_state_check()
1042 req.nh.nlmsg_seq = seq; in xfrm_state_check()
1051 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_ADDRESS_FILTER, in xfrm_state_check()
1055 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_check()
1065 if (answer.nh.nlmsg_type == NLMSG_ERROR) { in xfrm_state_check()
1069 } else if (answer.nh.nlmsg_type == NLMSG_DONE) { in xfrm_state_check()
1074 } else if (answer.nh.nlmsg_type == XFRM_MSG_NEWSA) { in xfrm_state_check()
1116 struct nlmsghdr nh; in xfrm_policy_add() member
1124 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in xfrm_policy_add()
1125 req.nh.nlmsg_type = XFRM_MSG_NEWPOLICY; in xfrm_policy_add()
1126 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_policy_add()
1127 req.nh.nlmsg_seq = seq; in xfrm_policy_add()
1156 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_TMPL, &tmpl, sizeof(tmpl))) in xfrm_policy_add()
1159 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_policy_add()
1191 struct nlmsghdr nh; in xfrm_policy_del() member
1197 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.id)); in xfrm_policy_del()
1198 req.nh.nlmsg_type = XFRM_MSG_DELPOLICY; in xfrm_policy_del()
1199 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_policy_del()
1200 req.nh.nlmsg_seq = seq; in xfrm_policy_del()
1210 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_policy_del()
1241 struct nlmsghdr nh; in xfrm_state_del() member
1248 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.id)); in xfrm_state_del()
1249 req.nh.nlmsg_type = XFRM_MSG_DELSA; in xfrm_state_del()
1250 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_state_del()
1251 req.nh.nlmsg_seq = seq; in xfrm_state_del()
1260 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_SRCADDR, &saddr, sizeof(saddr))) in xfrm_state_del()
1263 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_del()
1292 struct nlmsghdr nh; in xfrm_state_allocspi() member
1296 struct nlmsghdr nh; in xfrm_state_allocspi() member
1304 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.spi)); in xfrm_state_allocspi()
1305 req.nh.nlmsg_type = XFRM_MSG_ALLOCSPI; in xfrm_state_allocspi()
1306 req.nh.nlmsg_flags = NLM_F_REQUEST; in xfrm_state_allocspi()
1307 req.nh.nlmsg_seq = (*seq)++; in xfrm_state_allocspi()
1314 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_allocspi()
1322 } else if (answer.nh.nlmsg_type == XFRM_MSG_NEWSA) { in xfrm_state_allocspi()
1331 } else if (answer.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_state_allocspi()
1332 printk("expected NLMSG_ERROR, got %d", (int)answer.nh.nlmsg_type); in xfrm_state_allocspi()
1382 struct nlmsghdr nh; in xfrm_monitor_acquire() member
1397 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.acq)); in xfrm_monitor_acquire()
1398 req.nh.nlmsg_type = XFRM_MSG_ACQUIRE; in xfrm_monitor_acquire()
1399 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_monitor_acquire()
1400 req.nh.nlmsg_seq = (*seq)++; in xfrm_monitor_acquire()
1409 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_TMPL, &xfrm_tmpl, sizeof(xfrm_tmpl))) in xfrm_monitor_acquire()
1412 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_monitor_acquire()
1420 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_monitor_acquire()
1421 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_monitor_acquire()
1453 struct nlmsghdr nh; in xfrm_expire_state() member
1475 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.expire)); in xfrm_expire_state()
1476 req.nh.nlmsg_type = XFRM_MSG_EXPIRE; in xfrm_expire_state()
1477 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_expire_state()
1478 req.nh.nlmsg_seq = (*seq)++; in xfrm_expire_state()
1486 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_expire_state()
1494 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_expire_state()
1495 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_expire_state()
1525 struct nlmsghdr nh; in xfrm_expire_policy() member
1550 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.expire)); in xfrm_expire_policy()
1551 req.nh.nlmsg_type = XFRM_MSG_POLEXPIRE; in xfrm_expire_policy()
1552 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_expire_policy()
1553 req.nh.nlmsg_seq = (*seq)++; in xfrm_expire_policy()
1564 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_expire_policy()
1572 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_expire_policy()
1573 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_expire_policy()
1606 struct nlmsghdr nh; in xfrm_spdinfo_set_thresh() member
1616 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.unused)); in xfrm_spdinfo_set_thresh()
1617 req.nh.nlmsg_type = XFRM_MSG_NEWSPDINFO; in xfrm_spdinfo_set_thresh()
1618 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_spdinfo_set_thresh()
1619 req.nh.nlmsg_seq = (*seq)++; in xfrm_spdinfo_set_thresh()
1623 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_SPD_IPV4_HTHRESH, &thresh, sizeof(thresh))) in xfrm_spdinfo_set_thresh()
1628 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_SPD_IPV6_HTHRESH, &thresh, sizeof(thresh))) in xfrm_spdinfo_set_thresh()
1633 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_IF_ID, NULL, 0)) { in xfrm_spdinfo_set_thresh()
1639 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_spdinfo_set_thresh()
1647 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_spdinfo_set_thresh()
1648 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_spdinfo_set_thresh()
1663 struct nlmsghdr nh; in xfrm_spdinfo_attrs() member
1678 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.unused)); in xfrm_spdinfo_attrs()
1679 req.nh.nlmsg_type = XFRM_MSG_GETSPDINFO; in xfrm_spdinfo_attrs()
1680 req.nh.nlmsg_flags = NLM_F_REQUEST; in xfrm_spdinfo_attrs()
1681 req.nh.nlmsg_seq = (*seq)++; in xfrm_spdinfo_attrs()
1682 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_spdinfo_attrs()
1690 } else if (req.nh.nlmsg_type == XFRM_MSG_NEWSPDINFO) { in xfrm_spdinfo_attrs()
1691 size_t len = NLMSG_PAYLOAD(&req.nh, sizeof(req.unused)); in xfrm_spdinfo_attrs()
1721 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_spdinfo_attrs()
1722 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_spdinfo_attrs()