Lines Matching refs:nh

210 static inline struct rtattr *rtattr_hdr(struct nlmsghdr *nh)  in rtattr_hdr()  argument
212 return (struct rtattr *)((char *)(nh) + RTA_ALIGN((nh)->nlmsg_len)); in rtattr_hdr()
215 static int rtattr_pack(struct nlmsghdr *nh, size_t req_sz, in rtattr_pack() argument
219 struct rtattr *attr = rtattr_hdr(nh); in rtattr_pack()
220 size_t nl_size = RTA_ALIGN(nh->nlmsg_len) + RTA_LENGTH(size); in rtattr_pack()
226 nh->nlmsg_len = nl_size; in rtattr_pack()
235 static struct rtattr *_rtattr_begin(struct nlmsghdr *nh, size_t req_sz, in _rtattr_begin() argument
238 struct rtattr *ret = rtattr_hdr(nh); in _rtattr_begin()
240 if (rtattr_pack(nh, req_sz, rta_type, payload, size)) in _rtattr_begin()
246 static inline struct rtattr *rtattr_begin(struct nlmsghdr *nh, size_t req_sz, in rtattr_begin() argument
249 return _rtattr_begin(nh, req_sz, rta_type, 0, 0); in rtattr_begin()
252 static inline void rtattr_end(struct nlmsghdr *nh, struct rtattr *attr) in rtattr_end() argument
254 char *nlmsg_end = (char *)nh + nh->nlmsg_len; in rtattr_end()
259 static int veth_pack_peerb(struct nlmsghdr *nh, size_t req_sz, in veth_pack_peerb() argument
269 peer_attr = _rtattr_begin(nh, req_sz, VETH_INFO_PEER, &pi, sizeof(pi)); in veth_pack_peerb()
273 if (rtattr_pack(nh, req_sz, IFLA_IFNAME, peer, strlen(peer))) in veth_pack_peerb()
276 if (rtattr_pack(nh, req_sz, IFLA_NET_NS_FD, &ns, sizeof(ns))) in veth_pack_peerb()
279 rtattr_end(nh, peer_attr); in veth_pack_peerb()
312 struct nlmsghdr nh; in veth_add() member
320 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in veth_add()
321 req.nh.nlmsg_type = RTM_NEWLINK; in veth_add()
322 req.nh.nlmsg_flags = flags; in veth_add()
323 req.nh.nlmsg_seq = seq; in veth_add()
327 if (rtattr_pack(&req.nh, sizeof(req), IFLA_IFNAME, peera, strlen(peera))) in veth_add()
330 if (rtattr_pack(&req.nh, sizeof(req), IFLA_NET_NS_FD, &ns_a, sizeof(ns_a))) in veth_add()
333 link_info = rtattr_begin(&req.nh, sizeof(req), IFLA_LINKINFO); in veth_add()
337 if (rtattr_pack(&req.nh, sizeof(req), IFLA_INFO_KIND, veth_type, sizeof(veth_type))) in veth_add()
340 info_data = rtattr_begin(&req.nh, sizeof(req), IFLA_INFO_DATA); in veth_add()
344 if (veth_pack_peerb(&req.nh, sizeof(req), peerb, ns_b)) in veth_add()
347 rtattr_end(&req.nh, info_data); in veth_add()
348 rtattr_end(&req.nh, link_info); in veth_add()
350 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in veth_add()
362 struct nlmsghdr nh; in ip4_addr_set() member
368 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in ip4_addr_set()
369 req.nh.nlmsg_type = RTM_NEWADDR; in ip4_addr_set()
370 req.nh.nlmsg_flags = flags; in ip4_addr_set()
371 req.nh.nlmsg_seq = seq; in ip4_addr_set()
386 if (rtattr_pack(&req.nh, sizeof(req), IFA_LOCAL, &addr, sizeof(addr))) in ip4_addr_set()
389 if (rtattr_pack(&req.nh, sizeof(req), IFA_ADDRESS, &addr, sizeof(addr))) in ip4_addr_set()
392 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in ip4_addr_set()
402 struct nlmsghdr nh; in link_set_up() member
408 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in link_set_up()
409 req.nh.nlmsg_type = RTM_NEWLINK; in link_set_up()
410 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in link_set_up()
411 req.nh.nlmsg_seq = seq; in link_set_up()
418 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in link_set_up()
429 struct nlmsghdr nh; in ip4_route_set() member
436 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.rt)); in ip4_route_set()
437 req.nh.nlmsg_type = RTM_NEWROUTE; in ip4_route_set()
438 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE; in ip4_route_set()
439 req.nh.nlmsg_seq = seq; in ip4_route_set()
447 if (rtattr_pack(&req.nh, sizeof(req), RTA_DST, &dst, sizeof(dst))) in ip4_route_set()
450 if (rtattr_pack(&req.nh, sizeof(req), RTA_PREFSRC, &src, sizeof(src))) in ip4_route_set()
453 if (rtattr_pack(&req.nh, sizeof(req), RTA_OIF, &index, sizeof(index))) in ip4_route_set()
456 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { in ip4_route_set()
826 static int xfrm_state_pack_algo(struct nlmsghdr *nh, size_t req_sz, in xfrm_state_pack_algo() argument
888 if (rtattr_pack(nh, req_sz, type, &alg, sizeof(alg))) in xfrm_state_pack_algo()
903 if (rtattr_pack(nh, req_sz, type, &alg, sizeof(alg))) in xfrm_state_pack_algo()
919 struct nlmsghdr nh; in xfrm_state_add() member
925 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in xfrm_state_add()
926 req.nh.nlmsg_type = XFRM_MSG_NEWSA; in xfrm_state_add()
927 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_state_add()
928 req.nh.nlmsg_seq = seq; in xfrm_state_add()
954 if (xfrm_state_pack_algo(&req.nh, sizeof(req), desc)) in xfrm_state_add()
957 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_add()
1008 struct nlmsghdr nh; in xfrm_state_check() member
1012 struct nlmsghdr nh; in xfrm_state_check() member
1024 req.nh.nlmsg_len = NLMSG_LENGTH(0); in xfrm_state_check()
1025 req.nh.nlmsg_type = XFRM_MSG_GETSA; in xfrm_state_check()
1026 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; in xfrm_state_check()
1027 req.nh.nlmsg_seq = seq; in xfrm_state_check()
1036 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_ADDRESS_FILTER, in xfrm_state_check()
1040 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_check()
1050 if (answer.nh.nlmsg_type == NLMSG_ERROR) { in xfrm_state_check()
1054 } else if (answer.nh.nlmsg_type == NLMSG_DONE) { in xfrm_state_check()
1059 } else if (answer.nh.nlmsg_type == XFRM_MSG_NEWSA) { in xfrm_state_check()
1101 struct nlmsghdr nh; in xfrm_policy_add() member
1109 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in xfrm_policy_add()
1110 req.nh.nlmsg_type = XFRM_MSG_NEWPOLICY; in xfrm_policy_add()
1111 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_policy_add()
1112 req.nh.nlmsg_seq = seq; in xfrm_policy_add()
1141 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_TMPL, &tmpl, sizeof(tmpl))) in xfrm_policy_add()
1144 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_policy_add()
1176 struct nlmsghdr nh; in xfrm_policy_del() member
1182 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.id)); in xfrm_policy_del()
1183 req.nh.nlmsg_type = XFRM_MSG_DELPOLICY; in xfrm_policy_del()
1184 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_policy_del()
1185 req.nh.nlmsg_seq = seq; in xfrm_policy_del()
1195 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_policy_del()
1226 struct nlmsghdr nh; in xfrm_state_del() member
1233 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.id)); in xfrm_state_del()
1234 req.nh.nlmsg_type = XFRM_MSG_DELSA; in xfrm_state_del()
1235 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_state_del()
1236 req.nh.nlmsg_seq = seq; in xfrm_state_del()
1245 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_SRCADDR, &saddr, sizeof(saddr))) in xfrm_state_del()
1248 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_del()
1277 struct nlmsghdr nh; in xfrm_state_allocspi() member
1281 struct nlmsghdr nh; in xfrm_state_allocspi() member
1289 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.spi)); in xfrm_state_allocspi()
1290 req.nh.nlmsg_type = XFRM_MSG_ALLOCSPI; in xfrm_state_allocspi()
1291 req.nh.nlmsg_flags = NLM_F_REQUEST; in xfrm_state_allocspi()
1292 req.nh.nlmsg_seq = (*seq)++; in xfrm_state_allocspi()
1299 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_state_allocspi()
1307 } else if (answer.nh.nlmsg_type == XFRM_MSG_NEWSA) { in xfrm_state_allocspi()
1316 } else if (answer.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_state_allocspi()
1317 printk("expected NLMSG_ERROR, got %d", (int)answer.nh.nlmsg_type); in xfrm_state_allocspi()
1367 struct nlmsghdr nh; in xfrm_monitor_acquire() member
1382 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.acq)); in xfrm_monitor_acquire()
1383 req.nh.nlmsg_type = XFRM_MSG_ACQUIRE; in xfrm_monitor_acquire()
1384 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_monitor_acquire()
1385 req.nh.nlmsg_seq = (*seq)++; in xfrm_monitor_acquire()
1394 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_TMPL, &xfrm_tmpl, sizeof(xfrm_tmpl))) in xfrm_monitor_acquire()
1397 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_monitor_acquire()
1405 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_monitor_acquire()
1406 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_monitor_acquire()
1438 struct nlmsghdr nh; in xfrm_expire_state() member
1460 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.expire)); in xfrm_expire_state()
1461 req.nh.nlmsg_type = XFRM_MSG_EXPIRE; in xfrm_expire_state()
1462 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_expire_state()
1463 req.nh.nlmsg_seq = (*seq)++; in xfrm_expire_state()
1471 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_expire_state()
1479 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_expire_state()
1480 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_expire_state()
1510 struct nlmsghdr nh; in xfrm_expire_policy() member
1535 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.expire)); in xfrm_expire_policy()
1536 req.nh.nlmsg_type = XFRM_MSG_POLEXPIRE; in xfrm_expire_policy()
1537 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_expire_policy()
1538 req.nh.nlmsg_seq = (*seq)++; in xfrm_expire_policy()
1549 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_expire_policy()
1557 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_expire_policy()
1558 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_expire_policy()
1591 struct nlmsghdr nh; in xfrm_spdinfo_set_thresh() member
1601 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.unused)); in xfrm_spdinfo_set_thresh()
1602 req.nh.nlmsg_type = XFRM_MSG_NEWSPDINFO; in xfrm_spdinfo_set_thresh()
1603 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in xfrm_spdinfo_set_thresh()
1604 req.nh.nlmsg_seq = (*seq)++; in xfrm_spdinfo_set_thresh()
1608 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_SPD_IPV4_HTHRESH, &thresh, sizeof(thresh))) in xfrm_spdinfo_set_thresh()
1613 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_SPD_IPV6_HTHRESH, &thresh, sizeof(thresh))) in xfrm_spdinfo_set_thresh()
1618 if (rtattr_pack(&req.nh, sizeof(req), XFRMA_IF_ID, NULL, 0)) { in xfrm_spdinfo_set_thresh()
1624 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_spdinfo_set_thresh()
1632 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_spdinfo_set_thresh()
1633 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_spdinfo_set_thresh()
1648 struct nlmsghdr nh; in xfrm_spdinfo_attrs() member
1663 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.unused)); in xfrm_spdinfo_attrs()
1664 req.nh.nlmsg_type = XFRM_MSG_GETSPDINFO; in xfrm_spdinfo_attrs()
1665 req.nh.nlmsg_flags = NLM_F_REQUEST; in xfrm_spdinfo_attrs()
1666 req.nh.nlmsg_seq = (*seq)++; in xfrm_spdinfo_attrs()
1667 if (send(xfrm_sock, &req, req.nh.nlmsg_len, 0) < 0) { in xfrm_spdinfo_attrs()
1675 } else if (req.nh.nlmsg_type == XFRM_MSG_NEWSPDINFO) { in xfrm_spdinfo_attrs()
1676 size_t len = NLMSG_PAYLOAD(&req.nh, sizeof(req.unused)); in xfrm_spdinfo_attrs()
1706 } else if (req.nh.nlmsg_type != NLMSG_ERROR) { in xfrm_spdinfo_attrs()
1707 printk("expected NLMSG_ERROR, got %d", (int)req.nh.nlmsg_type); in xfrm_spdinfo_attrs()