|
11 | 11 | /* |
12 | 12 | * Bind rule is matched with socket fields accessible to cgroup/bind{4,6} hook |
13 | 13 | * through bpf_sock_addr struct. |
14 | | - * address_family is expected to be one of AF_UNSPEC, AF_INET or AF_INET6. |
| 14 | + * 'address_family' is expected to be one of AF_UNSPEC, AF_INET or AF_INET6. |
15 | 15 | * Matching by family is bypassed for rules with AF_UNSPEC set, which makes the |
16 | 16 | * rest of a rule applicable for both IPv4 and IPv6 addresses. |
17 | 17 | * If matching by family is either successful or bypassed, a rule and a socket |
18 | | - * are matched by ports. |
19 | | - * nr_ports and port_min fields specify a set of ports to match a user port |
| 18 | + * are matched by ip protocol. |
| 19 | + * If 'protocol' is 0, matching is bypassed. |
| 20 | + * 'nr_ports' and 'port_min' fields specify a set of ports to match a user port |
20 | 21 | * with. |
21 | | - * If nr_ports is 0, matching by port is bypassed, making that rule applicable |
| 22 | + * If 'nr_ports' is 0, matching by port is bypassed, making that rule applicable |
22 | 23 | * for all possible ports, e.g. [1, 65535] range. Thus a rule with |
23 | | - * address_family and nr_ports equal to AF_UNSPEC and 0 correspondingly forms |
24 | | - * 'allow any' or 'deny any' cases. |
25 | | - * For positive nr_ports, a user_port lying in a range from port_min to |
26 | | - * port_min + nr_ports exclusively is considered to be a match. nr_ports |
| 24 | + * 'address_family', 'protocol' and 'nr_ports' equal to AF_UNSPEC, 0 and 0 |
| 25 | + * correspondingly forms 'allow any' or 'deny any' cases. |
| 26 | + * For positive 'nr_ports', a user_port lying in a range from 'port_min' to' |
| 27 | + * 'port_min' + 'nr_ports' exclusively is considered to be a match. 'nr_ports' |
27 | 28 | * equalling to 1 forms a rule for a single port. |
28 | 29 | * Ports are in host order. |
29 | 30 | * |
30 | 31 | * Examples: |
31 | | - * AF_UNSPEC, 1, 7777: match IPv4 and IPv6 addresses with 7777 user port; |
| 32 | + * AF_UNSPEC, 1, 0, 7777: match IPv4 and IPv6 addresses with 7777 user port; |
32 | 33 | * |
33 | | - * AF_INET, 1023, 1: match IPv4 addresses with user port in [1, 1023] |
| 34 | + * AF_INET, 1023, 0, 1: match IPv4 addresses with user port in [1, 1023] |
34 | 35 | * range inclusively; |
35 | 36 | * |
36 | | - * AF_INET6, 0, 0: match IPv6 addresses; |
| 37 | + * AF_INET6, 0, 0, 0: match IPv6 addresses; |
37 | 38 | * |
38 | | - * AF_UNSPEC, 0, 0: match IPv4 and IPv6 addresses. |
| 39 | + * AF_UNSPEC, 0, 0, 0: match IPv4 and IPv6 addresses; |
| 40 | + * |
| 41 | + * AF_INET6, IPPROTO_TCP, 0, 0: match IPv6/TCP addresses. |
39 | 42 | */ |
40 | 43 |
|
41 | 44 | struct socket_bind_rule { |
42 | 45 | __u32 address_family; |
| 46 | + __u32 protocol; |
43 | 47 | __u16 nr_ports; |
44 | 48 | __u16 port_min; |
45 | 49 | }; |
|
0 commit comments