* Start a nested netlink attribute. * It must be followed later by a call to tap_nlattr_nested_finish(). * * @param[in, out] msg * The netlink message where to edit the nested_tails metadata. * @param[in] type * The nested attribute type to append. * * @return * -1 if adding a nested netlink attribute failed, 0 otherwise. */
| 367 | * -1 if adding a nested netlink attribute failed, 0 otherwise. |
| 368 | */ |
| 369 | int |
| 370 | tap_nlattr_nested_start(struct nlmsg *msg, uint16_t type) |
| 371 | { |
| 372 | struct nested_tail *tail; |
| 373 | |
| 374 | tail = rte_zmalloc(NULL, sizeof(struct nested_tail), 0); |
| 375 | if (!tail) { |
| 376 | TAP_LOG(ERR, |
| 377 | "Couldn't allocate memory for nested netlink attribute"); |
| 378 | return -1; |
| 379 | } |
| 380 | |
| 381 | tail->tail = (struct rtattr *)NLMSG_TAIL(&msg->nh); |
| 382 | |
| 383 | tap_nlattr_add(&msg->nh, type, 0, NULL); |
| 384 | |
| 385 | tail->prev = msg->nested_tails; |
| 386 | |
| 387 | msg->nested_tails = tail; |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * End a nested netlink attribute. |
no test coverage detected