Skip to content

Commit 003c941

Browse files
Shannon Nelsondavem330
authored andcommitted
tcp: fix tcp_fastopen unaligned access complaints on sparc
Fix up a data alignment issue on sparc by swapping the order of the cookie byte array field with the length field in struct tcp_fastopen_cookie, and making it a proper union to clean up the typecasting. This addresses log complaints like these: log_unaligned: 113 callbacks suppressed Kernel unaligned access at TPC[976490] tcp_try_fastopen+0x2d0/0x360 Kernel unaligned access at TPC[9764ac] tcp_try_fastopen+0x2ec/0x360 Kernel unaligned access at TPC[9764c8] tcp_try_fastopen+0x308/0x360 Kernel unaligned access at TPC[9764e4] tcp_try_fastopen+0x324/0x360 Kernel unaligned access at TPC[976490] tcp_try_fastopen+0x2d0/0x360 Cc: Eric Dumazet <[email protected]> Signed-off-by: Shannon Nelson <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fa79581 commit 003c941

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/linux/tcp.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb)
6262

6363
/* TCP Fast Open Cookie as stored in memory */
6464
struct tcp_fastopen_cookie {
65+
union {
66+
u8 val[TCP_FASTOPEN_COOKIE_MAX];
67+
#if IS_ENABLED(CONFIG_IPV6)
68+
struct in6_addr addr;
69+
#endif
70+
};
6571
s8 len;
66-
u8 val[TCP_FASTOPEN_COOKIE_MAX];
6772
bool exp; /* In RFC6994 experimental option format */
6873
};
6974

net/ipv4/tcp_fastopen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static bool tcp_fastopen_cookie_gen(struct request_sock *req,
113113
struct tcp_fastopen_cookie tmp;
114114

115115
if (__tcp_fastopen_cookie_gen(&ip6h->saddr, &tmp)) {
116-
struct in6_addr *buf = (struct in6_addr *) tmp.val;
116+
struct in6_addr *buf = &tmp.addr;
117117
int i;
118118

119119
for (i = 0; i < 4; i++)

0 commit comments

Comments
 (0)