Skip to content

Commit a20ebf4

Browse files
tagrawal03meta-codesync[bot]
authored andcommitted
Fix TPR byte-order handling for cross-architecture compatibility
Summary: TPR feature reads server_id from TCP options using raw memory cast, which works on x86_64 (little-endian) but would fail on ARM or other big-endian architectures. The wire format is little-endian but the parsing code didn't account for host byte order differences. - On little-endian systems (x86_64): No change. - On big-endian systems (ARM): Automatic byte-swap via __builtin_bswap32() This diff should be No-op Reviewed By: frankfeir Differential Revision: D86576924 fbshipit-source-id: 472440efed0e760b1bd96fcb206521cbcce68307
1 parent 3dbd06d commit a20ebf4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

katran/lib/bpf/pckt_parsing.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ __attribute__((__always_inline__)) int parse_hdr_opt_raw(
201201
return -1;
202202
}
203203

204+
// TPR wire format is little-endian. Read the value and convert to host
205+
// byte order if needed for cross-architecture compatibility.
204206
state->server_id = *(__u32*)&tcp_opt[2];
207+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
208+
// TODO (T244373617): Add stats for this case
209+
state->server_id = __builtin_bswap32(state->server_id);
210+
#endif
205211
return 1;
206212
}
207213

0 commit comments

Comments
 (0)