Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IPV6]: Use bitfields for hop_limit and mcast_hops.

Save some bits for future extensions.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

+24 -4
+24 -4
include/linux/ipv6.h
··· 274 274 275 275 __be32 flow_label; 276 276 __u32 frag_size; 277 - __s16 hop_limit; 278 - __s16 mcast_hops; 277 + 278 + /* 279 + * Packed in 16bits. 280 + * Omit one shift by by putting the signed field at MSB. 281 + */ 282 + #if defined(__BIG_ENDIAN_BITFIELD) 283 + __s16 hop_limit:9; 284 + __u16 __unused_1:7; 285 + #else 286 + __u16 __unused_1:7; 287 + __s16 hop_limit:9; 288 + #endif 289 + 290 + #if defined(__BIG_ENDIAN_BITFIELD) 291 + /* Packed in 16bits. */ 292 + __s16 mcast_hops:9; 293 + __u16 __unused_2:6, 294 + mc_loop:1; 295 + #else 296 + __u16 mc_loop:1, 297 + __unused_2:6; 298 + __s16 mcast_hops:9; 299 + #endif 279 300 int mcast_oif; 280 301 281 302 /* pktoption flags */ ··· 319 298 } rxopt; 320 299 321 300 /* sockopt flags */ 322 - __u8 mc_loop:1, 323 - recverr:1, 301 + __u8 recverr:1, 324 302 sndflow:1, 325 303 pmtudisc:2, 326 304 ipv6only:1;