summaryrefslogtreecommitdiffstats
path: root/tests/py/inet/meta.t.payload
blob: 7184fa0c0c9d19e8677dccd966112d8670e1f40a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# meta nfproto ipv4
ip test-ip4 input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]

# meta nfproto ipv6
ip test-ip4 input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x0000000a ]

# meta nfproto {ipv4, ipv6}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000002  : 0 [end]	element 0000000a  : 0 [end]
ip test-ip4 input
  [ meta load nfproto => reg 1 ]
  [ lookup reg 1 set __set%d ]

# meta nfproto != {ipv4, ipv6}
__set%d test-ip4 3
__set%d test-ip4 0
	element 00000002  : 0 [end]	element 0000000a  : 0 [end]
ip test-ip4 input
  [ meta load nfproto => reg 1 ]
  [ lookup reg 1 set __set%d 0x1 ]

# meta nfproto ipv6 tcp dport 22
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x0000000a ]
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00001600 ]

# meta nfproto ipv4 tcp dport 22
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00001600 ]

# meta nfproto ipv4 ip saddr 1.2.3.4
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ cmp eq reg 1 0x04030201 ]

# meta nfproto ipv6 meta l4proto tcp
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x0000000a ]
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]

# meta nfproto ipv4 counter ip saddr 1.2.3.4
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ counter pkts 0 bytes 0 ]
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ cmp eq reg 1 0x04030201 ]

# meta ipsec exists
inet test-inet input
  [ meta load secpath => reg 1 ]
  [ cmp eq reg 1 0x00000001 ]

# meta secpath missing
inet test-inet input
  [ meta load secpath => reg 1 ]
  [ cmp eq reg 1 0x00000000 ]

# meta mark set ct mark >> 8
inet test-inet input
  [ ct load mark => reg 1 ]
  [ bitwise reg 1 = ( reg 1 >> 0x00000008 ) ]
  [ meta set mark with reg 1 ]

# meta protocol ip udp dport 67
inet test-inet input
  [ meta load protocol => reg 1 ]
  [ cmp eq reg 1 0x00000008 ]
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000011 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00004300 ]

# meta protocol ip6 udp dport 67
inet test-inet input
  [ meta load protocol => reg 1 ]
  [ cmp eq reg 1 0x0000dd86 ]
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000011 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00004300 ]

# meta mark . tcp dport { 0x0000000a-0x00000014 . 80-90, 0x00100000-0x00100123 . 100-120 }
__set%d test-inet 87 size 1
__set%d test-inet 0
	element 0a000000 00005000  - 14000000 00005a00  : 0 [end]       element 00001000 00006400  - 23011000 00007800  : 0 [end]
ip test-inet input
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ meta load mark => reg 1 ]
  [ byteorder reg 1 = hton(reg 1, 4, 4) ]
  [ payload load 2b @ transport header + 2 => reg 9 ]
  [ lookup reg 1 set __set%d ]

# ip saddr . meta mark { 1.2.3.4 . 0x00000100 , 1.2.3.6-1.2.3.8 . 0x00000200-0x00000300 }
__set%d test-inet 87 size 2
__set%d test-inet 0
        element 04030201 00010000  - 04030201 00010000  : 0 [end]       element 06030201 00020000  - 08030201 00030000  : 0 [end]
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ meta load mark => reg 9 ]
  [ byteorder reg 9 = hton(reg 9, 4, 4) ]
  [ lookup reg 1 set __set%d ]

# ip saddr . meta mark { 1.2.3.4 . 0x00000100 , 5.6.7.8 . 0x00000200 }
__set%d test-inet 3 size 2
__set%d test-inet 0
        element 04030201 00000100  : 0 [end]    element 08070605 00000200  : 0 [end]
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ meta load mark => reg 9 ]
  [ lookup reg 1 set __set%d ]

# meta mark set ip dscp
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ payload load 1b @ network header + 1 => reg 1 ]
  [ bitwise reg 1 = ( reg 1 & 0x000000fc ) ^ 0x00000000 ]
  [ bitwise reg 1 = ( reg 1 >> 0x00000002 ) ]
  [ meta set mark with reg 1 ]

# meta mark set ip dscp | 0x40
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ payload load 1b @ network header + 1 => reg 1 ]
  [ bitwise reg 1 = ( reg 1 & 0x000000fc ) ^ 0x00000000 ]
  [ bitwise reg 1 = ( reg 1 >> 0x00000002 ) ]
  [ bitwise reg 1 = ( reg 1 & 0xffffffbf ) ^ 0x00000040 ]
  [ meta set mark with reg 1 ]

# meta mark set ip6 dscp
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x0000000a ]
  [ payload load 2b @ network header + 0 => reg 1 ]
  [ bitwise reg 1 = ( reg 1 & 0x0000c00f ) ^ 0x00000000 ]
  [ byteorder reg 1 = ntoh(reg 1, 2, 2) ]
  [ bitwise reg 1 = ( reg 1 >> 0x00000006 ) ]
  [ meta set mark with reg 1 ]

# meta mark set ip6 dscp | 0x40
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x0000000a ]
  [ payload load 2b @ network header + 0 => reg 1 ]
  [ bitwise reg 1 = ( reg 1 & 0x0000c00f ) ^ 0x00000000 ]
  [ byteorder reg 1 = ntoh(reg 1, 2, 2) ]
  [ bitwise reg 1 = ( reg 1 >> 0x00000006 ) ]
  [ bitwise reg 1 = ( reg 1 & 0xffffffbf ) ^ 0x00000040 ]
  [ meta set mark with reg 1 ]

# ip saddr . ether saddr . meta l4proto { 1.2.3.4 . aa:bb:cc:dd:ee:ff . 6 }
__set%d test-inet 3 size 1
__set%d test-inet 0
	element 04030201 ddccbbaa 0000ffee 00000006  : 0 [end]
inet test-inet input
  [ meta load nfproto => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]
  [ meta load iiftype => reg 1 ]
  [ cmp eq reg 1 0x00000001 ]
  [ payload load 4b @ network header + 12 => reg 1 ]
  [ payload load 6b @ link header + 6 => reg 9 ]
  [ meta load l4proto => reg 11 ]
  [ lookup reg 1 set __set%d ]