Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F135865169
D50103.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D50103.diff
View Options
diff --git a/sys/netinet/dccp.h b/sys/netinet/dccp.h
--- a/sys/netinet/dccp.h
+++ b/sys/netinet/dccp.h
@@ -64,7 +64,7 @@
uint8_t seq[6];
} longseq;
} d_seqno;
-};
+} __packed;
#define d_seqno_short d_seqno.shortseq;
#define d_seqno_long d_seqno.longseq.seq;
diff --git a/sys/netinet/ip.h b/sys/netinet/ip.h
--- a/sys/netinet/ip.h
+++ b/sys/netinet/ip.h
@@ -67,7 +67,7 @@
u_char ip_p; /* protocol */
u_short ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
-} __packed __aligned(2);
+} __packed;
#define IP_MAXPACKET 65535 /* maximum packet size */
@@ -187,7 +187,7 @@
uint32_t ipt_time; /* network format */
} ipt_ta[1];
} ipt_timestamp;
-};
+} __packed;
/* Flag bits for ipt_flg. */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -47,7 +47,7 @@
u_short ih_len; /* protocol length */
struct in_addr ih_src; /* source internet address */
struct in_addr ih_dst; /* destination internet address */
-};
+} __packed;
#ifdef _KERNEL
/*
diff --git a/sys/netinet/pim.h b/sys/netinet/pim.h
--- a/sys/netinet/pim.h
+++ b/sys/netinet/pim.h
@@ -71,7 +71,7 @@
#endif /* ! _PIM_VT */
uint8_t pim_reserved; /* Reserved */
uint16_t pim_cksum; /* IP-style checksum */
-};
+} __packed;
/* KAME-related name backward compatibility */
#define pim_ver pim_vers
#define pim_rsv pim_reserved
diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h
--- a/sys/netinet/tcp.h
+++ b/sys/netinet/tcp.h
@@ -77,7 +77,7 @@
u_short th_win; /* window */
u_short th_sum; /* checksum */
u_short th_urp; /* urgent pointer */
-};
+} __packed;
static __inline uint16_t
__tcp_get_flags(const struct tcphdr *th)
diff --git a/sys/netinet/udp.h b/sys/netinet/udp.h
--- a/sys/netinet/udp.h
+++ b/sys/netinet/udp.h
@@ -44,7 +44,7 @@
u_short uh_dport; /* destination port */
u_short uh_ulen; /* udp length */
u_short uh_sum; /* udp checksum */
-};
+} __packed;
/*
* User-settable options (used with setsockopt).
diff --git a/tests/sys/netinet/ip_reass_test.c b/tests/sys/netinet/ip_reass_test.c
--- a/tests/sys/netinet/ip_reass_test.c
+++ b/tests/sys/netinet/ip_reass_test.c
@@ -60,12 +60,16 @@
{
size_t i;
uint32_t cksum;
- uint16_t *cksump;
+ uint8_t *cksump;
+ uint16_t tmp;
ip->ip_sum = 0;
- cksump = (uint16_t *)ip;
- for (cksum = 0, i = 0; i < sizeof(*ip) / sizeof(*cksump); cksump++, i++)
- cksum += ntohs(*cksump);
+ cksump = (char *)ip;
+ for (cksum = 0, i = 0; i < sizeof(*ip) / sizeof(uint16_t); i++) {
+ tmp = *cksump++;
+ tmp = tmp << 8 | *cksump++;
+ cksum += ntohs(tmp);
+ }
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum = ~(cksum + (cksum >> 16));
ip->ip_sum = htons((uint16_t)cksum);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 14, 4:12 PM (5 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25292848
Default Alt Text
D50103.diff (2 KB)
Attached To
Mode
D50103: netinet: Decorate IPv4 structures used for byte buffer overlays as packed.
Attached
Detach File
Event Timeline
Log In to Comment