1 /* 2 * netlink-private/types.h Netlink Types (Private) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation version 2.1 7 * of the License. 8 * 9 * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch> 10 * Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com> 11 */ 12 13 #ifndef NETLINK_LOCAL_TYPES_H_ 14 #define NETLINK_LOCAL_TYPES_H_ 15 16 #include <netlink/list.h> 17 #include <netlink/route/link.h> 18 #include <netlink/route/qdisc.h> 19 #include <netlink/route/rtnl.h> 20 #include <netlink/route/route.h> 21 #include <netlink/idiag/idiagnl.h> 22 #include <netlink/netfilter/ct.h> 23 #include <netlink-private/object-api.h> 24 #include <netlink-private/route/tc-api.h> 25 #include <netlink-private/route/link/sriov.h> 26 #include <netlink-private/route/nexthop-encap.h> 27 #include <linux/netlink.h> 28 #include <linux/rtnetlink.h> 29 #include <linux/genetlink.h> 30 #include <linux/tc_act/tc_mirred.h> 31 #include <linux/tc_act/tc_skbedit.h> 32 #include <linux/tc_act/tc_gact.h> 33 #include <linux/tc_act/tc_vlan.h> 34 #include <linux/sock_diag.h> 35 #include <linux/fib_rules.h> 36 37 #define NL_SOCK_PASSCRED (1<<1) 38 #define NL_OWN_PORT (1<<2) 39 #define NL_MSG_PEEK (1<<3) 40 #define NL_MSG_PEEK_EXPLICIT (1<<4) 41 #define NL_NO_AUTO_ACK (1<<5) 42 43 #define NL_MSG_CRED_PRESENT 1 44 45 struct nl_cache_ops; 46 struct nl_sock; 47 struct nl_object; 48 struct nl_hash_table; 49 struct nl_vf_vlans; 50 51 struct nl_cb 52 { 53 nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1]; 54 void * cb_args[NL_CB_TYPE_MAX+1]; 55 56 nl_recvmsg_err_cb_t cb_err; 57 void * cb_err_arg; 58 59 /** May be used to replace nl_recvmsgs with your own implementation 60 * in all internal calls to nl_recvmsgs. */ 61 int (*cb_recvmsgs_ow)(struct nl_sock *, 62 struct nl_cb *); 63 64 /** Overwrite internal calls to nl_recv, must return the number of 65 * octets read and allocate a buffer for the received data. */ 66 int (*cb_recv_ow)(struct nl_sock *, 67 struct sockaddr_nl *, 68 unsigned char **, 69 struct ucred **); 70 71 /** Overwrites internal calls to nl_send, must send the netlink 72 * message. */ 73 int (*cb_send_ow)(struct nl_sock *, 74 struct nl_msg *); 75 76 int cb_refcnt; 77 /** indicates the callback that is currently active */ 78 enum nl_cb_type cb_active; 79 }; 80 81 struct nl_sock 82 { 83 struct sockaddr_nl s_local; 84 struct sockaddr_nl s_peer; 85 int s_fd; 86 int s_proto; 87 unsigned int s_seq_next; 88 unsigned int s_seq_expect; 89 int s_flags; 90 struct nl_cb * s_cb; 91 size_t s_bufsize; 92 }; 93 94 struct nl_cache 95 { 96 struct nl_list_head c_items; 97 int c_nitems; 98 int c_iarg1; 99 int c_iarg2; 100 int c_refcnt; 101 unsigned int c_flags; 102 struct nl_hash_table * hashtable; 103 struct nl_cache_ops * c_ops; 104 }; 105 106 struct nl_cache_assoc 107 { 108 struct nl_cache * ca_cache; 109 change_func_t ca_change; 110 change_func_v2_t ca_change_v2; 111 void * ca_change_data; 112 }; 113 114 struct nl_cache_mngr 115 { 116 int cm_protocol; 117 int cm_flags; 118 int cm_nassocs; 119 struct nl_sock * cm_sock; 120 struct nl_sock * cm_sync_sock; 121 struct nl_cache_assoc * cm_assocs; 122 }; 123 124 struct nl_parser_param; 125 126 #define LOOSE_COMPARISON 1 127 #define ID_COMPARISON 2 128 129 #define NL_OBJ_MARK 1 130 131 struct nl_data 132 { 133 size_t d_size; 134 void * d_data; 135 }; 136 137 struct nl_addr 138 { 139 int a_family; 140 unsigned int a_maxsize; 141 unsigned int a_len; 142 int a_prefixlen; 143 int a_refcnt; 144 char a_addr[0]; 145 }; 146 147 struct nl_msg 148 { 149 int nm_protocol; 150 int nm_flags; 151 struct sockaddr_nl nm_src; 152 struct sockaddr_nl nm_dst; 153 struct ucred nm_creds; 154 struct nlmsghdr * nm_nlh; 155 size_t nm_size; 156 int nm_refcnt; 157 }; 158 159 struct rtnl_link_map 160 { 161 uint64_t lm_mem_start; 162 uint64_t lm_mem_end; 163 uint64_t lm_base_addr; 164 uint16_t lm_irq; 165 uint8_t lm_dma; 166 uint8_t lm_port; 167 }; 168 169 struct rtnl_link_vf 170 { 171 struct nl_list_head vf_list; 172 int ce_refcnt; 173 uint32_t ce_mask; 174 uint32_t vf_index; 175 uint64_t vf_guid_node; 176 uint64_t vf_guid_port; 177 uint32_t vf_linkstate; 178 struct nl_addr * vf_lladdr; 179 uint32_t vf_max_tx_rate; 180 uint32_t vf_min_tx_rate; 181 uint32_t vf_rate; 182 uint32_t vf_rss_query_en; 183 uint32_t vf_spoofchk; 184 uint64_t vf_stats[RTNL_LINK_VF_STATS_MAX+1]; 185 uint32_t vf_trust; 186 struct nl_vf_vlans * vf_vlans; 187 }; 188 189 #define IFQDISCSIZ 32 190 191 struct rtnl_link 192 { 193 NLHDR_COMMON 194 195 char l_name[IFNAMSIZ]; 196 uint32_t l_family; 197 uint32_t l_arptype; 198 uint32_t l_index; 199 uint32_t l_flags; 200 uint32_t l_change; 201 uint32_t l_mtu; 202 uint32_t l_link; 203 int32_t l_link_netnsid; 204 uint32_t l_txqlen; 205 uint32_t l_weight; 206 uint32_t l_master; 207 struct nl_addr * l_addr; 208 struct nl_addr * l_bcast; 209 char l_qdisc[IFQDISCSIZ]; 210 struct rtnl_link_map l_map; 211 uint64_t l_stats[RTNL_LINK_STATS_MAX+1]; 212 uint32_t l_flag_mask; 213 uint32_t l_num_vf; 214 uint8_t l_operstate; 215 uint8_t l_linkmode; 216 /* 2 byte hole */ 217 char * l_info_kind; 218 char * l_info_slave_kind; 219 struct rtnl_link_info_ops * l_info_ops; 220 void * l_af_data[AF_MAX]; 221 void * l_info; 222 char * l_ifalias; 223 uint32_t l_promiscuity; 224 uint32_t l_num_tx_queues; 225 uint32_t l_num_rx_queues; 226 uint32_t l_gso_max_segs; 227 uint32_t l_gso_max_size; 228 uint32_t l_group; 229 uint8_t l_carrier; 230 /* 3 byte hole */ 231 uint32_t l_carrier_changes; 232 struct rtnl_link_af_ops * l_af_ops; 233 struct nl_data * l_phys_port_id; 234 char l_phys_port_name[IFNAMSIZ]; 235 struct nl_data * l_phys_switch_id; 236 int l_ns_fd; 237 pid_t l_ns_pid; 238 struct rtnl_link_vf * l_vf_list; 239 }; 240 241 struct rtnl_ncacheinfo 242 { 243 uint32_t nci_confirmed; /**< Time since neighbour validty was last confirmed */ 244 uint32_t nci_used; /**< Time since neighbour entry was last ued */ 245 uint32_t nci_updated; /**< Time since last update */ 246 uint32_t nci_refcnt; /**< Reference counter */ 247 }; 248 249 250 struct rtnl_neigh 251 { 252 NLHDR_COMMON 253 uint32_t n_family; 254 uint32_t n_ifindex; 255 uint16_t n_state; 256 uint8_t n_flags; 257 uint8_t n_type; 258 struct nl_addr *n_lladdr; 259 struct nl_addr *n_dst; 260 uint32_t n_probes; 261 struct rtnl_ncacheinfo n_cacheinfo; 262 uint32_t n_state_mask; 263 uint32_t n_flag_mask; 264 uint32_t n_master; 265 uint16_t n_vlan; 266 }; 267 268 269 struct rtnl_addr_cacheinfo 270 { 271 /* Preferred lifetime in seconds, ticking from when the message gets constructed */ 272 uint32_t aci_prefered; 273 274 /* Valid lifetime in seconds, ticking from when the message gets constructed */ 275 uint32_t aci_valid; 276 277 /* Timestamp of creation in 1/100s since boottime, clock_gettime(CLOCK_MONOTONIC) */ 278 uint32_t aci_cstamp; 279 280 /* Timestamp of last update in 1/100s since boottime, clock_gettime(CLOCK_MONOTONIC) */ 281 uint32_t aci_tstamp; 282 }; 283 284 struct rtnl_addr 285 { 286 NLHDR_COMMON 287 288 uint8_t a_family; 289 uint8_t a_prefixlen; 290 uint8_t a_scope; 291 uint32_t a_flags; 292 uint32_t a_ifindex; 293 294 struct nl_addr *a_peer; 295 struct nl_addr *a_local; 296 struct nl_addr *a_bcast; 297 struct nl_addr *a_anycast; 298 struct nl_addr *a_multicast; 299 300 struct rtnl_addr_cacheinfo a_cacheinfo; 301 302 char a_label[IFNAMSIZ]; 303 uint32_t a_flag_mask; 304 struct rtnl_link *a_link; 305 }; 306 307 struct rtnl_nh_encap 308 { 309 struct nh_encap_ops *ops; 310 void *priv; /* private data for encap type */ 311 }; 312 313 struct rtnl_nexthop 314 { 315 uint8_t rtnh_flags; 316 uint8_t rtnh_flag_mask; 317 uint8_t rtnh_weight; 318 /* 1 byte spare */ 319 uint32_t rtnh_ifindex; 320 struct nl_addr * rtnh_gateway; 321 uint32_t ce_mask; /* HACK to support attr macros */ 322 struct nl_list_head rtnh_list; 323 uint32_t rtnh_realms; 324 struct nl_addr * rtnh_newdst; 325 struct nl_addr * rtnh_via; 326 struct rtnl_nh_encap * rtnh_encap; 327 }; 328 329 struct rtnl_route 330 { 331 NLHDR_COMMON 332 333 uint8_t rt_family; 334 uint8_t rt_dst_len; 335 uint8_t rt_src_len; 336 uint8_t rt_tos; 337 uint8_t rt_protocol; 338 uint8_t rt_scope; 339 uint8_t rt_type; 340 uint8_t rt_nmetrics; 341 uint8_t rt_ttl_propagate; 342 uint32_t rt_flags; 343 struct nl_addr * rt_dst; 344 struct nl_addr * rt_src; 345 uint32_t rt_table; 346 uint32_t rt_iif; 347 uint32_t rt_prio; 348 uint32_t rt_metrics[RTAX_MAX]; 349 uint32_t rt_metrics_mask; 350 uint32_t rt_nr_nh; 351 struct nl_addr * rt_pref_src; 352 struct nl_list_head rt_nexthops; 353 struct rtnl_rtcacheinfo rt_cacheinfo; 354 uint32_t rt_flag_mask; 355 }; 356 357 struct rtnl_rule 358 { 359 NLHDR_COMMON 360 uint8_t r_family; 361 uint8_t r_action; 362 uint8_t r_dsfield; /* ipv4 only */ 363 uint8_t r_l3mdev; 364 uint8_t r_protocol; /* protocol that installed rule */ 365 uint8_t r_ip_proto; /* IP/IPv6 protocol */ 366 uint32_t r_table; 367 uint32_t r_flags; 368 uint32_t r_prio; 369 uint32_t r_mark; 370 uint32_t r_mask; 371 uint32_t r_goto; 372 uint32_t r_flow; /* ipv4 only */ 373 struct nl_addr *r_src; 374 struct nl_addr *r_dst; 375 char r_iifname[IFNAMSIZ]; 376 char r_oifname[IFNAMSIZ]; 377 378 struct fib_rule_port_range r_sport; 379 struct fib_rule_port_range r_dport; 380 }; 381 382 struct rtnl_neightbl_parms 383 { 384 /** 385 * Interface index of the device this parameter set is assigned 386 * to or 0 for the default set. 387 */ 388 uint32_t ntp_ifindex; 389 390 /** 391 * Number of references to this parameter set. 392 */ 393 uint32_t ntp_refcnt; 394 395 /** 396 * Queue length for pending arp requests, i.e. the number of 397 * packets which are accepted from other layers while the 398 * neighbour address is still being resolved 399 */ 400 uint32_t ntp_queue_len; 401 402 /** 403 * Number of requests to send to the user level ARP daemon. 404 * Specify 0 to disable. 405 */ 406 uint32_t ntp_app_probes; 407 408 /** 409 * Maximum number of retries for unicast solicitation. 410 */ 411 uint32_t ntp_ucast_probes; 412 413 /** 414 * Maximum number of retries for multicast solicitation. 415 */ 416 uint32_t ntp_mcast_probes; 417 418 /** 419 * Base value in milliseconds to ompute reachable time, see RFC2461. 420 */ 421 uint64_t ntp_base_reachable_time; 422 423 /** 424 * Actual reachable time (read-only) 425 */ 426 uint64_t ntp_reachable_time; /* secs */ 427 428 /** 429 * The time in milliseconds between retransmitted Neighbor 430 * Solicitation messages. 431 */ 432 uint64_t ntp_retrans_time; 433 434 /** 435 * Interval in milliseconds to check for stale neighbour 436 * entries. 437 */ 438 uint64_t ntp_gc_stale_time; /* secs */ 439 440 /** 441 * Delay in milliseconds for the first time probe if 442 * the neighbour is reachable. 443 */ 444 uint64_t ntp_probe_delay; /* secs */ 445 446 /** 447 * Maximum delay in milliseconds of an answer to a neighbour 448 * solicitation message. 449 */ 450 uint64_t ntp_anycast_delay; 451 452 /** 453 * Minimum age in milliseconds before a neighbour entry 454 * may be replaced. 455 */ 456 uint64_t ntp_locktime; 457 458 /** 459 * Delay in milliseconds before answering to an ARP request 460 * for which a proxy ARP entry exists. 461 */ 462 uint64_t ntp_proxy_delay; 463 464 /** 465 * Queue length for the delayed proxy arp requests. 466 */ 467 uint32_t ntp_proxy_qlen; 468 469 /** 470 * Mask of available parameter attributes 471 */ 472 uint32_t ntp_mask; 473 }; 474 475 #define NTBLNAMSIZ 32 476 477 /** 478 * Neighbour table 479 * @ingroup neightbl 480 */ 481 struct rtnl_neightbl 482 { 483 NLHDR_COMMON 484 485 char nt_name[NTBLNAMSIZ]; 486 uint32_t nt_family; 487 uint32_t nt_gc_thresh1; 488 uint32_t nt_gc_thresh2; 489 uint32_t nt_gc_thresh3; 490 uint64_t nt_gc_interval; 491 struct ndt_config nt_config; 492 struct rtnl_neightbl_parms nt_parms; 493 struct ndt_stats nt_stats; 494 }; 495 496 struct rtnl_ratespec 497 { 498 uint64_t rs_rate64; 499 uint16_t rs_overhead; 500 int16_t rs_cell_align; 501 uint16_t rs_mpu; 502 uint8_t rs_cell_log; 503 }; 504 505 struct rtnl_tstats 506 { 507 struct { 508 uint64_t bytes; 509 uint64_t packets; 510 } tcs_basic; 511 512 struct { 513 uint32_t bps; 514 uint32_t pps; 515 } tcs_rate_est; 516 517 struct { 518 uint32_t qlen; 519 uint32_t backlog; 520 uint32_t drops; 521 uint32_t requeues; 522 uint32_t overlimits; 523 } tcs_queue; 524 }; 525 526 #define TCKINDSIZ 32 527 528 #define NL_TC_GENERIC(pre) \ 529 NLHDR_COMMON \ 530 uint32_t pre ##_family; \ 531 uint32_t pre ##_ifindex; \ 532 uint32_t pre ##_handle; \ 533 uint32_t pre ##_parent; \ 534 uint32_t pre ##_info; \ 535 uint32_t pre ##_mtu; \ 536 uint32_t pre ##_mpu; \ 537 uint32_t pre ##_overhead; \ 538 uint32_t pre ##_linktype; \ 539 char pre ##_kind[TCKINDSIZ]; \ 540 struct nl_data * pre ##_opts; \ 541 uint64_t pre ##_stats[RTNL_TC_STATS_MAX+1]; \ 542 struct nl_data * pre ##_xstats; \ 543 struct nl_data * pre ##_subdata; \ 544 struct rtnl_link * pre ##_link; \ 545 struct rtnl_tc_ops * pre ##_ops; \ 546 enum rtnl_tc_type pre ##_type; \ 547 uint32_t pre ##_chain 548 549 struct rtnl_tc 550 { 551 NL_TC_GENERIC(tc); 552 }; 553 554 struct rtnl_qdisc 555 { 556 NL_TC_GENERIC(q); 557 }; 558 559 struct rtnl_class 560 { 561 NL_TC_GENERIC(c); 562 }; 563 564 struct rtnl_cls 565 { 566 NL_TC_GENERIC(c); 567 uint16_t c_prio; 568 uint16_t c_protocol; 569 }; 570 571 struct rtnl_act 572 { 573 NL_TC_GENERIC(c); 574 struct rtnl_act * a_next; 575 }; 576 577 struct rtnl_mirred 578 { 579 struct tc_mirred m_parm; 580 }; 581 582 struct rtnl_skbedit 583 { 584 struct tc_skbedit s_parm; 585 uint32_t s_flags; 586 uint32_t s_mark; 587 uint32_t s_prio; 588 uint16_t s_queue_mapping; 589 }; 590 591 struct rtnl_gact 592 { 593 struct tc_gact g_parm; 594 }; 595 596 struct rtnl_u32 597 { 598 uint32_t cu_divisor; 599 uint32_t cu_hash; 600 uint32_t cu_classid; 601 uint32_t cu_link; 602 struct nl_data * cu_pcnt; 603 struct nl_data * cu_selector; 604 struct nl_data * cu_mark; 605 struct rtnl_act* cu_act; 606 struct nl_data * cu_police; 607 char cu_indev[IFNAMSIZ]; 608 int cu_mask; 609 }; 610 611 struct rtnl_mall 612 { 613 uint32_t m_classid; 614 uint32_t m_flags; 615 struct rtnl_act *m_act; 616 int m_mask; 617 }; 618 619 struct rtnl_cgroup 620 { 621 struct rtnl_ematch_tree *cg_ematch; 622 int cg_mask; 623 }; 624 625 struct rtnl_fw 626 { 627 uint32_t cf_classid; 628 struct nl_data * cf_act; 629 struct nl_data * cf_police; 630 char cf_indev[IFNAMSIZ]; 631 uint32_t cf_fwmask; 632 int cf_mask; 633 }; 634 635 struct rtnl_ematch 636 { 637 uint16_t e_id; 638 uint16_t e_kind; 639 uint16_t e_flags; 640 uint16_t e_index; 641 size_t e_datalen; 642 643 struct nl_list_head e_childs; 644 struct nl_list_head e_list; 645 struct rtnl_ematch_ops *e_ops; 646 647 void * e_data; 648 }; 649 650 struct rtnl_ematch_tree 651 { 652 uint16_t et_progid; 653 struct nl_list_head et_list; 654 655 }; 656 657 struct rtnl_dsmark_qdisc 658 { 659 uint16_t qdm_indices; 660 uint16_t qdm_default_index; 661 uint32_t qdm_set_tc_index; 662 uint32_t qdm_mask; 663 }; 664 665 struct rtnl_dsmark_class 666 { 667 uint8_t cdm_bmask; 668 uint8_t cdm_value; 669 uint32_t cdm_mask; 670 }; 671 672 struct rtnl_fifo 673 { 674 uint32_t qf_limit; 675 uint32_t qf_mask; 676 }; 677 678 struct rtnl_prio 679 { 680 uint32_t qp_bands; 681 uint8_t qp_priomap[TC_PRIO_MAX+1]; 682 uint32_t qp_mask; 683 }; 684 685 struct rtnl_mqprio 686 { 687 uint8_t qm_num_tc; 688 uint8_t qm_prio_map[TC_QOPT_BITMASK + 1]; 689 uint8_t qm_hw; 690 uint16_t qm_count[TC_QOPT_MAX_QUEUE]; 691 uint16_t qm_offset[TC_QOPT_MAX_QUEUE]; 692 uint16_t qm_mode; 693 uint16_t qm_shaper; 694 uint64_t qm_min_rate[TC_QOPT_MAX_QUEUE]; 695 uint64_t qm_max_rate[TC_QOPT_MAX_QUEUE]; 696 uint32_t qm_mask; 697 }; 698 699 struct rtnl_tbf 700 { 701 uint32_t qt_limit; 702 struct rtnl_ratespec qt_rate; 703 uint32_t qt_rate_bucket; 704 uint32_t qt_rate_txtime; 705 struct rtnl_ratespec qt_peakrate; 706 uint32_t qt_peakrate_bucket; 707 uint32_t qt_peakrate_txtime; 708 uint32_t qt_mask; 709 }; 710 711 struct rtnl_sfq 712 { 713 uint32_t qs_quantum; 714 uint32_t qs_perturb; 715 uint32_t qs_limit; 716 uint32_t qs_divisor; 717 uint32_t qs_flows; 718 uint32_t qs_mask; 719 }; 720 721 struct rtnl_netem_corr 722 { 723 uint32_t nmc_delay; 724 uint32_t nmc_loss; 725 uint32_t nmc_duplicate; 726 }; 727 728 struct rtnl_netem_reo 729 { 730 uint32_t nmro_probability; 731 uint32_t nmro_correlation; 732 }; 733 734 struct rtnl_netem_crpt 735 { 736 uint32_t nmcr_probability; 737 uint32_t nmcr_correlation; 738 }; 739 740 struct rtnl_netem_dist 741 { 742 int16_t * dist_data; 743 size_t dist_size; 744 }; 745 746 struct rtnl_netem 747 { 748 uint32_t qnm_latency; 749 uint32_t qnm_limit; 750 uint32_t qnm_loss; 751 uint32_t qnm_gap; 752 uint32_t qnm_duplicate; 753 uint32_t qnm_jitter; 754 uint32_t qnm_mask; 755 struct rtnl_netem_corr qnm_corr; 756 struct rtnl_netem_reo qnm_ro; 757 struct rtnl_netem_crpt qnm_crpt; 758 struct rtnl_netem_dist qnm_dist; 759 }; 760 761 struct rtnl_htb_qdisc 762 { 763 uint32_t qh_rate2quantum; 764 uint32_t qh_defcls; 765 uint32_t qh_mask; 766 uint32_t qh_direct_pkts; 767 }; 768 769 struct rtnl_htb_class 770 { 771 uint32_t ch_prio; 772 struct rtnl_ratespec ch_rate; 773 struct rtnl_ratespec ch_ceil; 774 uint32_t ch_rbuffer; 775 uint32_t ch_cbuffer; 776 uint32_t ch_quantum; 777 uint32_t ch_mask; 778 uint32_t ch_level; 779 }; 780 781 struct rtnl_cbq 782 { 783 struct tc_cbq_lssopt cbq_lss; 784 struct tc_ratespec cbq_rate; 785 struct tc_cbq_wrropt cbq_wrr; 786 struct tc_cbq_ovl cbq_ovl; 787 struct tc_cbq_fopt cbq_fopt; 788 struct tc_cbq_police cbq_police; 789 }; 790 791 struct rtnl_red 792 { 793 uint32_t qr_limit; 794 uint32_t qr_qth_min; 795 uint32_t qr_qth_max; 796 uint8_t qr_flags; 797 uint8_t qr_wlog; 798 uint8_t qr_plog; 799 uint8_t qr_scell_log; 800 uint32_t qr_mask; 801 }; 802 803 struct rtnl_plug 804 { 805 int action; 806 uint32_t limit; 807 }; 808 809 struct rtnl_fq_codel 810 { 811 int fq_limit; 812 uint32_t fq_target; 813 uint32_t fq_interval; 814 int fq_flows; 815 uint32_t fq_quantum; 816 int fq_ecn; 817 uint32_t fq_mask; 818 }; 819 820 struct rtnl_hfsc_qdisc 821 { 822 uint32_t qh_defcls; 823 uint32_t qh_mask; 824 }; 825 826 struct rtnl_hfsc_class 827 { 828 struct tc_service_curve ch_rsc; 829 struct tc_service_curve ch_fsc; 830 struct tc_service_curve ch_usc; 831 uint32_t ch_mask; 832 }; 833 834 struct flnl_request 835 { 836 NLHDR_COMMON 837 838 struct nl_addr * lr_addr; 839 uint32_t lr_fwmark; 840 uint8_t lr_tos; 841 uint8_t lr_scope; 842 uint8_t lr_table; 843 }; 844 845 846 struct flnl_result 847 { 848 NLHDR_COMMON 849 850 struct flnl_request * fr_req; 851 uint8_t fr_table_id; 852 uint8_t fr_prefixlen; 853 uint8_t fr_nh_sel; 854 uint8_t fr_type; 855 uint8_t fr_scope; 856 uint32_t fr_error; 857 }; 858 859 #define GENL_OP_HAS_POLICY 1 860 #define GENL_OP_HAS_DOIT 2 861 #define GENL_OP_HAS_DUMPIT 4 862 863 struct genl_family_op 864 { 865 uint32_t o_id; 866 uint32_t o_flags; 867 868 struct nl_list_head o_list; 869 }; 870 871 struct genl_family_grp { 872 struct genl_family *family; /* private */ 873 struct nl_list_head list; /* private */ 874 char name[GENL_NAMSIZ]; 875 u_int32_t id; 876 }; 877 878 struct genl_family 879 { 880 NLHDR_COMMON 881 882 uint16_t gf_id; 883 char gf_name[GENL_NAMSIZ]; 884 uint32_t gf_version; 885 uint32_t gf_hdrsize; 886 uint32_t gf_maxattr; 887 888 struct nl_list_head gf_ops; 889 struct nl_list_head gf_mc_grps; 890 }; 891 892 union nfnl_ct_proto 893 { 894 struct { 895 uint16_t src; 896 uint16_t dst; 897 } port; 898 struct { 899 uint16_t id; 900 uint8_t type; 901 uint8_t code; 902 } icmp; 903 }; 904 905 struct nfnl_ct_dir { 906 struct nl_addr * src; 907 struct nl_addr * dst; 908 union nfnl_ct_proto proto; 909 uint64_t packets; 910 uint64_t bytes; 911 }; 912 913 union nfnl_ct_protoinfo { 914 struct { 915 uint8_t state; 916 } tcp; 917 }; 918 919 struct nfnl_ct { 920 NLHDR_COMMON 921 922 uint8_t ct_family; 923 uint8_t ct_proto; 924 union nfnl_ct_protoinfo ct_protoinfo; 925 926 uint32_t ct_status; 927 uint32_t ct_status_mask; 928 uint32_t ct_timeout; 929 uint32_t ct_mark; 930 uint32_t ct_use; 931 uint32_t ct_id; 932 uint16_t ct_zone; 933 934 struct nfnl_ct_dir ct_orig; 935 struct nfnl_ct_dir ct_repl; 936 937 struct nfnl_ct_timestamp ct_tstamp; 938 }; 939 940 union nfnl_exp_protodata { 941 struct { 942 uint16_t src; 943 uint16_t dst; 944 } port; 945 struct { 946 uint16_t id; 947 uint8_t type; 948 uint8_t code; 949 } icmp; 950 }; 951 952 // Allow for different master/expect l4 protocols 953 struct nfnl_exp_proto 954 { 955 uint8_t l4protonum; 956 union nfnl_exp_protodata l4protodata; 957 }; 958 959 struct nfnl_exp_dir { 960 struct nl_addr * src; 961 struct nl_addr * dst; 962 struct nfnl_exp_proto proto; 963 }; 964 965 struct nfnl_exp { 966 NLHDR_COMMON 967 968 uint8_t exp_family; 969 uint32_t exp_timeout; 970 uint32_t exp_id; 971 uint16_t exp_zone; 972 uint32_t exp_class; 973 uint32_t exp_flags; 974 char * exp_helper_name; 975 char * exp_fn; 976 uint8_t exp_nat_dir; 977 978 struct nfnl_exp_dir exp_expect; 979 struct nfnl_exp_dir exp_master; 980 struct nfnl_exp_dir exp_mask; 981 struct nfnl_exp_dir exp_nat; 982 }; 983 984 struct nfnl_log { 985 NLHDR_COMMON 986 987 uint16_t log_group; 988 uint8_t log_copy_mode; 989 uint32_t log_copy_range; 990 uint32_t log_flush_timeout; 991 uint32_t log_alloc_size; 992 uint32_t log_queue_threshold; 993 uint32_t log_flags; 994 uint32_t log_flag_mask; 995 }; 996 997 struct nfnl_log_msg { 998 NLHDR_COMMON 999 1000 uint8_t log_msg_family; 1001 uint8_t log_msg_hook; 1002 uint16_t log_msg_hwproto; 1003 uint32_t log_msg_mark; 1004 struct timeval log_msg_timestamp; 1005 uint32_t log_msg_indev; 1006 uint32_t log_msg_outdev; 1007 uint32_t log_msg_physindev; 1008 uint32_t log_msg_physoutdev; 1009 uint8_t log_msg_hwaddr[8]; 1010 int log_msg_hwaddr_len; 1011 void * log_msg_payload; 1012 int log_msg_payload_len; 1013 char * log_msg_prefix; 1014 uint32_t log_msg_uid; 1015 uint32_t log_msg_gid; 1016 uint32_t log_msg_seq; 1017 uint32_t log_msg_seq_global; 1018 }; 1019 1020 struct nfnl_queue { 1021 NLHDR_COMMON 1022 1023 uint16_t queue_group; 1024 uint32_t queue_maxlen; 1025 uint32_t queue_copy_range; 1026 uint8_t queue_copy_mode; 1027 }; 1028 1029 struct nfnl_queue_msg { 1030 NLHDR_COMMON 1031 1032 uint16_t queue_msg_group; 1033 uint8_t queue_msg_family; 1034 uint8_t queue_msg_hook; 1035 uint16_t queue_msg_hwproto; 1036 uint32_t queue_msg_packetid; 1037 uint32_t queue_msg_mark; 1038 struct timeval queue_msg_timestamp; 1039 uint32_t queue_msg_indev; 1040 uint32_t queue_msg_outdev; 1041 uint32_t queue_msg_physindev; 1042 uint32_t queue_msg_physoutdev; 1043 uint8_t queue_msg_hwaddr[8]; 1044 int queue_msg_hwaddr_len; 1045 void * queue_msg_payload; 1046 int queue_msg_payload_len; 1047 uint32_t queue_msg_verdict; 1048 }; 1049 1050 struct ematch_quoted { 1051 char * data; 1052 size_t len; 1053 int index; 1054 }; 1055 1056 struct idiagnl_meminfo { 1057 NLHDR_COMMON 1058 1059 uint32_t idiag_rmem; 1060 uint32_t idiag_wmem; 1061 uint32_t idiag_fmem; 1062 uint32_t idiag_tmem; 1063 }; 1064 1065 struct idiagnl_vegasinfo { 1066 NLHDR_COMMON 1067 1068 uint32_t tcpv_enabled; 1069 uint32_t tcpv_rttcnt; 1070 uint32_t tcpv_rtt; 1071 uint32_t tcpv_minrtt; 1072 }; 1073 1074 struct idiagnl_msg { 1075 NLHDR_COMMON 1076 1077 uint8_t idiag_family; 1078 uint8_t idiag_state; 1079 uint8_t idiag_timer; 1080 uint8_t idiag_retrans; 1081 uint16_t idiag_sport; 1082 uint16_t idiag_dport; 1083 struct nl_addr * idiag_src; 1084 struct nl_addr * idiag_dst; 1085 uint32_t idiag_ifindex; 1086 uint32_t idiag_expires; 1087 uint32_t idiag_rqueue; 1088 uint32_t idiag_wqueue; 1089 uint32_t idiag_uid; 1090 uint32_t idiag_inode; 1091 1092 uint8_t idiag_tos; 1093 uint8_t idiag_tclass; 1094 uint8_t idiag_shutdown; 1095 char * idiag_cong; 1096 struct idiagnl_meminfo * idiag_meminfo; 1097 struct idiagnl_vegasinfo * idiag_vegasinfo; 1098 struct tcp_info idiag_tcpinfo; 1099 uint32_t idiag_skmeminfo[SK_MEMINFO_VARS]; 1100 }; 1101 1102 struct idiagnl_req { 1103 NLHDR_COMMON 1104 1105 uint8_t idiag_family; 1106 uint8_t idiag_ext; 1107 struct nl_addr * idiag_src; 1108 struct nl_addr * idiag_dst; 1109 uint32_t idiag_ifindex; 1110 uint32_t idiag_states; 1111 uint32_t idiag_dbs; 1112 }; 1113 1114 // XFRM related definitions 1115 1116 /* Selector, used as selector both on policy rules (SPD) and SAs. */ 1117 struct xfrmnl_sel { 1118 uint32_t refcnt; 1119 struct nl_addr* daddr; 1120 struct nl_addr* saddr; 1121 uint16_t dport; 1122 uint16_t dport_mask; 1123 uint16_t sport; 1124 uint16_t sport_mask; 1125 uint16_t family; 1126 uint8_t prefixlen_d; 1127 uint8_t prefixlen_s; 1128 uint8_t proto; 1129 int32_t ifindex; 1130 uint32_t user; 1131 }; 1132 1133 /* Lifetime configuration, used for both policy rules (SPD) and SAs. */ 1134 struct xfrmnl_ltime_cfg { 1135 uint32_t refcnt; 1136 uint64_t soft_byte_limit; 1137 uint64_t hard_byte_limit; 1138 uint64_t soft_packet_limit; 1139 uint64_t hard_packet_limit; 1140 uint64_t soft_add_expires_seconds; 1141 uint64_t hard_add_expires_seconds; 1142 uint64_t soft_use_expires_seconds; 1143 uint64_t hard_use_expires_seconds; 1144 }; 1145 1146 /* Current lifetime, used for both policy rules (SPD) and SAs. */ 1147 struct xfrmnl_lifetime_cur { 1148 uint64_t bytes; 1149 uint64_t packets; 1150 uint64_t add_time; 1151 uint64_t use_time; 1152 }; 1153 1154 struct xfrmnl_replay_state { 1155 uint32_t oseq; 1156 uint32_t seq; 1157 uint32_t bitmap; 1158 }; 1159 1160 struct xfrmnl_replay_state_esn { 1161 uint32_t bmp_len; 1162 uint32_t oseq; 1163 uint32_t seq; 1164 uint32_t oseq_hi; 1165 uint32_t seq_hi; 1166 uint32_t replay_window; 1167 uint32_t bmp[0]; 1168 }; 1169 1170 struct xfrmnl_mark { 1171 uint32_t v; /* value */ 1172 uint32_t m; /* mask */ 1173 }; 1174 1175 /* XFRM AE related definitions */ 1176 1177 struct xfrmnl_sa_id { 1178 struct nl_addr* daddr; 1179 uint32_t spi; 1180 uint16_t family; 1181 uint8_t proto; 1182 }; 1183 1184 struct xfrmnl_ae { 1185 NLHDR_COMMON 1186 1187 struct xfrmnl_sa_id sa_id; 1188 struct nl_addr* saddr; 1189 uint32_t flags; 1190 uint32_t reqid; 1191 struct xfrmnl_mark mark; 1192 struct xfrmnl_lifetime_cur lifetime_cur; 1193 uint32_t replay_maxage; 1194 uint32_t replay_maxdiff; 1195 struct xfrmnl_replay_state replay_state; 1196 struct xfrmnl_replay_state_esn* replay_state_esn; 1197 }; 1198 1199 /* XFRM SA related definitions */ 1200 1201 struct xfrmnl_id { 1202 struct nl_addr* daddr; 1203 uint32_t spi; 1204 uint8_t proto; 1205 }; 1206 1207 struct xfrmnl_stats { 1208 uint32_t replay_window; 1209 uint32_t replay; 1210 uint32_t integrity_failed; 1211 }; 1212 1213 struct xfrmnl_algo_aead { 1214 char alg_name[64]; 1215 uint32_t alg_key_len; /* in bits */ 1216 uint32_t alg_icv_len; /* in bits */ 1217 char alg_key[0]; 1218 }; 1219 1220 struct xfrmnl_algo_auth { 1221 char alg_name[64]; 1222 uint32_t alg_key_len; /* in bits */ 1223 uint32_t alg_trunc_len; /* in bits */ 1224 char alg_key[0]; 1225 }; 1226 1227 struct xfrmnl_algo { 1228 char alg_name[64]; 1229 uint32_t alg_key_len; /* in bits */ 1230 char alg_key[0]; 1231 }; 1232 1233 struct xfrmnl_encap_tmpl { 1234 uint16_t encap_type; 1235 uint16_t encap_sport; 1236 uint16_t encap_dport; 1237 struct nl_addr* encap_oa; 1238 }; 1239 1240 struct xfrmnl_sa { 1241 NLHDR_COMMON 1242 1243 struct xfrmnl_sel* sel; 1244 struct xfrmnl_id id; 1245 struct nl_addr* saddr; 1246 struct xfrmnl_ltime_cfg* lft; 1247 struct xfrmnl_lifetime_cur curlft; 1248 struct xfrmnl_stats stats; 1249 uint32_t seq; 1250 uint32_t reqid; 1251 uint16_t family; 1252 uint8_t mode; /* XFRM_MODE_xxx */ 1253 uint8_t replay_window; 1254 uint8_t flags; 1255 struct xfrmnl_algo_aead* aead; 1256 struct xfrmnl_algo_auth* auth; 1257 struct xfrmnl_algo* crypt; 1258 struct xfrmnl_algo* comp; 1259 struct xfrmnl_encap_tmpl* encap; 1260 uint32_t tfcpad; 1261 struct nl_addr* coaddr; 1262 struct xfrmnl_mark mark; 1263 struct xfrmnl_user_sec_ctx* sec_ctx; 1264 uint32_t replay_maxage; 1265 uint32_t replay_maxdiff; 1266 struct xfrmnl_replay_state replay_state; 1267 struct xfrmnl_replay_state_esn* replay_state_esn; 1268 uint8_t hard; 1269 }; 1270 1271 struct xfrmnl_usersa_flush { 1272 uint8_t proto; 1273 }; 1274 1275 1276 /* XFRM SP related definitions */ 1277 1278 struct xfrmnl_userpolicy_id { 1279 struct xfrmnl_sel sel; 1280 uint32_t index; 1281 uint8_t dir; 1282 }; 1283 1284 struct xfrmnl_user_sec_ctx { 1285 uint16_t len; 1286 uint16_t exttype; 1287 uint8_t ctx_alg; 1288 uint8_t ctx_doi; 1289 uint16_t ctx_len; 1290 char ctx[0]; 1291 }; 1292 1293 struct xfrmnl_userpolicy_type { 1294 uint8_t type; 1295 uint16_t reserved1; 1296 uint16_t reserved2; 1297 }; 1298 1299 struct xfrmnl_user_tmpl { 1300 struct xfrmnl_id id; 1301 uint16_t family; 1302 struct nl_addr* saddr; 1303 uint32_t reqid; 1304 uint8_t mode; 1305 uint8_t share; 1306 uint8_t optional; 1307 uint32_t aalgos; 1308 uint32_t ealgos; 1309 uint32_t calgos; 1310 struct nl_list_head utmpl_list; 1311 }; 1312 1313 struct xfrmnl_sp { 1314 NLHDR_COMMON 1315 1316 struct xfrmnl_sel* sel; 1317 struct xfrmnl_ltime_cfg* lft; 1318 struct xfrmnl_lifetime_cur curlft; 1319 uint32_t priority; 1320 uint32_t index; 1321 uint8_t dir; 1322 uint8_t action; 1323 uint8_t flags; 1324 uint8_t share; 1325 struct xfrmnl_user_sec_ctx* sec_ctx; 1326 struct xfrmnl_userpolicy_type uptype; 1327 uint32_t nr_user_tmpl; 1328 struct nl_list_head usertmpl_list; 1329 struct xfrmnl_mark mark; 1330 }; 1331 1332 struct rtnl_vlan 1333 { 1334 struct tc_vlan v_parm; 1335 uint16_t v_vid; 1336 uint16_t v_proto; 1337 uint8_t v_prio; 1338 uint32_t v_flags; 1339 }; 1340 1341 #endif 1342