Commit e3b5100
Add separate counter for server ID 0 in katran TPR
Summary:
This diff introduces a new counter `error_server_id_zero` to separately track server ID 0 cases in katran's TPR (TCP Packet Router) module, distinguishing them from other types of bad server IDs.
## Background
Currently, server ID 0 is treated as a "bad ID" and counted under `error_bad_id`. However, server ID 0 represents a special case that requires different debugging and handling compared to actual corrupted/invalid server IDs.
## Changes Made
1. **New Counter Added**: `error_server_id_zero` added to:
- `tcp_router_stats` struct in `TPRTypes.h`
- BPF `stats` struct in `tcp_pkt_router_structs.h`
- Output formatting in `operator<<`
2. **Stats Collection Updated**:
- `TPRStatsPoller.cpp` - Generic stats collection
- `MetaTcpPktRouter.cpp` - Meta-specific stats with timeseries
- `tpr_app.cpp` - App-level diff calculation
3. **BPF Logic Updated**: Replaced `stat->error_bad_id++` with `stat->error_server_id_zero++` for **server ID 0 specific cases only**:
- **Active handler**:
- Parse header option where server_id == 0 (line 50)
- Storage failure sending 0 to passive (line 105)
- No server_id received in established connection (line 142)
- **Passive handler**:
- Received server_id == 0 from peer (line 58)
4. **Preserved existing `error_bad_id` behavior**: Still tracks legitimate bad ID cases including:
- ID mismatches between header and storage (non-zero values)
- Wrong server_id during packet routing (misrouted packets)
- Storage inconsistencies with non-zero IDs
5. **Test Updates**: Updated `TcpPktRouterIntegrationTest.cpp` to reflect new counter behavior:
- Rogue sock_ops scenarios now expect `error_server_id_zero > 0`
- Normal scenarios expect both counters to be 0
- All 27 tests now pass
## Key Distinction
- **`error_server_id_zero`**: Counts cases where server_id is actually 0 (special case for debugging)
- **`error_bad_id`**: Counts cases where server_id is corrupted, mismatched, or invalid (actual errors)
## Benefits
- **Better observability**: Distinguish expected server ID 0 cases from unexpected bad IDs
- **Improved debugging**: Separate counters for different error conditions
- **Backward compatibility**: Existing `error_bad_id` counter remains functional
## Testing
- Built successfully: `fbcode//katran/tpr:proxy_tpr_lib` and `fbcode//katran/facebook/cpr/tpr:meta_katran_tpr_lib`
- **All 27 integration tests pass**: `fbcode//katran/facebook/cpr/tpr/test:tcp_pkt_router_test`
- All code properly formatted and linted
- Both counters will be exported to monitoring systems for comprehensive tracking
---
> 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=4cd8f5ba-81f2-11f0-b5ce-fd1edeb5e779&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=4cd8f5ba-81f2-11f0-b5ce-fd1edeb5e779&tab=Trace)
Reviewed By: pdubovitsky
Differential Revision: D80974570
fbshipit-source-id: 86e733d386c15f1fa461a5331c2f5f6eba0e73771 parent 1e4cd50 commit e3b5100
5 files changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
0 commit comments