Commit 71136e5
Add server_id_fallback mechanism to prevent false mismatch reports during server ID transitions
Summary:
During server ID transitions, existing connections continue using old server IDs in TCP header options while new connections use new server IDs. This causes BPF comparison logic to report false mismatches for correctly routed existing connections.
Confirmed the issue within a shiv test backend.
<idle>-0 [008] ..s.1 563303.012647: bpf_trace_printk: [op=PASSIVE_ESTABLISHED_CB rport=34390 remote_ip4=100663423] passive estab received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.012755: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.013949: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.014361: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.014435: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.015225: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.015266: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
<idle>-0 [008] ..s.1 563303.015268: bpf_trace_printk: [op=PARSE_HDR_OPT_CB rport=34390 remote_ip4=100663423] passive received wrong server id: option=7274496, server=46451
This diff introduces a server_id_fallback mechanism to handle server ID transitions gracefully:
**Core Implementation:**
- Add `server_id_fallback` field to `server_info` struct in BPF and C++
- Add `fallbackV6Id_` field to `TcpPktRouter` class for server ID v2 format
- Route server IDs based on format: IDs ≥131072 (2<<16) → fallbackV6Id_, IDs <131072 → v6Id_
- Update BPF packet validation to accept packets matching either primary OR fallback server ID
- Use fallback server ID in TCP headers when primary server ID is 0
**API Enhancements:**
- Add `getFallbackServerIdV6()` method to access fallback server ID
- Update `getServerIdV6()` to return primary ID when available, fallback otherwise
- Enhanced `updateServerInfo()` to populate both fields in BPF map
**BPF Logic Updates:**
- `handle_passive_write_hdr_opt()`: Use server_id_fallback when server_id is 0
- `handle_passive_parse_hdr()` and `handle_passive_estab()`: Accept packets with either server ID
- Enhanced logging shows both primary and fallback server ID values
**Comprehensive Testing:**
- 3 unit tests validating server ID routing, BPF map population, and field preservation
- 3 integration tests covering server ID v2 functionality, seamless transitions, and format validation
- Extended test infrastructure with flexible server ID management
This eliminates false mismatch reports during server ID transitions while maintaining full backward compatibility.
---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?session_id=14e196ac-8842-11f0-a62e-b9c865999367&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=14e196ac-8842-11f0-a62e-b9c865999367&tab=Trace)
Reviewed By: avasylev
Differential Revision: D81549160
fbshipit-source-id: 7e69d3e3b0c1f834c62a25c5ed2834af21a3091c1 parent 16dc8c0 commit 71136e5
5 files changed
Lines changed: 59 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
115 | | - | |
116 | | - | |
117 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
118 | 130 | | |
119 | | - | |
120 | 131 | | |
121 | 132 | | |
122 | 133 | | |
| |||
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
| 165 | + | |
| 166 | + | |
154 | 167 | | |
155 | | - | |
156 | | - | |
157 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
158 | 174 | | |
159 | 175 | | |
160 | 176 | | |
161 | 177 | | |
| 178 | + | |
162 | 179 | | |
163 | 180 | | |
164 | 181 | | |
165 | 182 | | |
166 | 183 | | |
167 | 184 | | |
168 | | - | |
| 185 | + | |
| 186 | + | |
169 | 187 | | |
170 | 188 | | |
171 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
106 | | - | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
| 70 | + | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
| |||
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
126 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
132 | | - | |
| 142 | + | |
133 | 143 | | |
134 | | - | |
| 144 | + | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
0 commit comments