aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-05-02 19:26:16 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-02 19:26:16 -0400
commitd3e2ce3bcdbf4319dea308c79b5f72a8ecc8015c (patch)
treeaa83f30213ecb17a653fe16c55e3bc5449aa2d7c /net
parent83985319393973f280ca2a797047780a7955cf19 (diff)
net: use get/put_unaligned_* helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_stp_bpdu.c4
-rw-r--r--net/core/filter.c4
-rw-r--r--net/ipv4/cipso_ipv4.c18
-rw-r--r--net/ipv4/tcp_input.c18
4 files changed, 21 insertions, 23 deletions
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 8deab645ef75..ddeb6e5d45d6 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -58,12 +58,12 @@ static inline void br_set_ticks(unsigned char *dest, int j)
58{ 58{
59 unsigned long ticks = (STP_HZ * j)/ HZ; 59 unsigned long ticks = (STP_HZ * j)/ HZ;
60 60
61 put_unaligned(htons(ticks), (__be16 *)dest); 61 put_unaligned_be16(ticks, dest);
62} 62}
63 63
64static inline int br_get_ticks(const unsigned char *src) 64static inline int br_get_ticks(const unsigned char *src)
65{ 65{
66 unsigned long ticks = ntohs(get_unaligned((__be16 *)src)); 66 unsigned long ticks = get_unaligned_be16(src);
67 67
68 return DIV_ROUND_UP(ticks * HZ, STP_HZ); 68 return DIV_ROUND_UP(ticks * HZ, STP_HZ);
69} 69}
diff --git a/net/core/filter.c b/net/core/filter.c
index f5f3cf603064..4f8369729a4e 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -213,7 +213,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
213load_w: 213load_w:
214 ptr = load_pointer(skb, k, 4, &tmp); 214 ptr = load_pointer(skb, k, 4, &tmp);
215 if (ptr != NULL) { 215 if (ptr != NULL) {
216 A = ntohl(get_unaligned((__be32 *)ptr)); 216 A = get_unaligned_be32(ptr);
217 continue; 217 continue;
218 } 218 }
219 break; 219 break;
@@ -222,7 +222,7 @@ load_w:
222load_h: 222load_h:
223 ptr = load_pointer(skb, k, 2, &tmp); 223 ptr = load_pointer(skb, k, 2, &tmp);
224 if (ptr != NULL) { 224 if (ptr != NULL) {
225 A = ntohs(get_unaligned((__be16 *)ptr)); 225 A = get_unaligned_be16(ptr);
226 continue; 226 continue;
227 } 227 }
228 break; 228 break;
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 4637ded3dba8..05afb576d935 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -983,7 +983,7 @@ static int cipso_v4_map_cat_enum_valid(const struct cipso_v4_doi *doi_def,
983 return -EFAULT; 983 return -EFAULT;
984 984
985 for (iter = 0; iter < enumcat_len; iter += 2) { 985 for (iter = 0; iter < enumcat_len; iter += 2) {
986 cat = ntohs(get_unaligned((__be16 *)&enumcat[iter])); 986 cat = get_unaligned_be16(&enumcat[iter]);
987 if (cat <= cat_prev) 987 if (cat <= cat_prev)
988 return -EFAULT; 988 return -EFAULT;
989 cat_prev = cat; 989 cat_prev = cat;
@@ -1052,7 +1052,7 @@ static int cipso_v4_map_cat_enum_ntoh(const struct cipso_v4_doi *doi_def,
1052 1052
1053 for (iter = 0; iter < net_cat_len; iter += 2) { 1053 for (iter = 0; iter < net_cat_len; iter += 2) {
1054 ret_val = netlbl_secattr_catmap_setbit(secattr->attr.mls.cat, 1054 ret_val = netlbl_secattr_catmap_setbit(secattr->attr.mls.cat,
1055 ntohs(get_unaligned((__be16 *)&net_cat[iter])), 1055 get_unaligned_be16(&net_cat[iter]),
1056 GFP_ATOMIC); 1056 GFP_ATOMIC);
1057 if (ret_val != 0) 1057 if (ret_val != 0)
1058 return ret_val; 1058 return ret_val;
@@ -1086,10 +1086,9 @@ static int cipso_v4_map_cat_rng_valid(const struct cipso_v4_doi *doi_def,
1086 return -EFAULT; 1086 return -EFAULT;
1087 1087
1088 for (iter = 0; iter < rngcat_len; iter += 4) { 1088 for (iter = 0; iter < rngcat_len; iter += 4) {
1089 cat_high = ntohs(get_unaligned((__be16 *)&rngcat[iter])); 1089 cat_high = get_unaligned_be16(&rngcat[iter]);
1090 if ((iter + 4) <= rngcat_len) 1090 if ((iter + 4) <= rngcat_len)
1091 cat_low = ntohs( 1091 cat_low = get_unaligned_be16(&rngcat[iter + 2]);
1092 get_unaligned((__be16 *)&rngcat[iter + 2]));
1093 else 1092 else
1094 cat_low = 0; 1093 cat_low = 0;
1095 1094
@@ -1188,10 +1187,9 @@ static int cipso_v4_map_cat_rng_ntoh(const struct cipso_v4_doi *doi_def,
1188 u16 cat_high; 1187 u16 cat_high;
1189 1188
1190 for (net_iter = 0; net_iter < net_cat_len; net_iter += 4) { 1189 for (net_iter = 0; net_iter < net_cat_len; net_iter += 4) {
1191 cat_high = ntohs(get_unaligned((__be16 *)&net_cat[net_iter])); 1190 cat_high = get_unaligned_be16(&net_cat[net_iter]);
1192 if ((net_iter + 4) <= net_cat_len) 1191 if ((net_iter + 4) <= net_cat_len)
1193 cat_low = ntohs( 1192 cat_low = get_unaligned_be16(&net_cat[net_iter + 2]);
1194 get_unaligned((__be16 *)&net_cat[net_iter + 2]));
1195 else 1193 else
1196 cat_low = 0; 1194 cat_low = 0;
1197 1195
@@ -1562,7 +1560,7 @@ int cipso_v4_validate(unsigned char **option)
1562 } 1560 }
1563 1561
1564 rcu_read_lock(); 1562 rcu_read_lock();
1565 doi_def = cipso_v4_doi_search(ntohl(get_unaligned((__be32 *)&opt[2]))); 1563 doi_def = cipso_v4_doi_search(get_unaligned_be32(&opt[2]));
1566 if (doi_def == NULL) { 1564 if (doi_def == NULL) {
1567 err_offset = 2; 1565 err_offset = 2;
1568 goto validate_return_locked; 1566 goto validate_return_locked;
@@ -1843,7 +1841,7 @@ static int cipso_v4_getattr(const unsigned char *cipso,
1843 if (cipso_v4_cache_check(cipso, cipso[1], secattr) == 0) 1841 if (cipso_v4_cache_check(cipso, cipso[1], secattr) == 0)
1844 return 0; 1842 return 0;
1845 1843
1846 doi = ntohl(get_unaligned((__be32 *)&cipso[2])); 1844 doi = get_unaligned_be32(&cipso[2]);
1847 rcu_read_lock(); 1845 rcu_read_lock();
1848 doi_def = cipso_v4_doi_search(doi); 1846 doi_def = cipso_v4_doi_search(doi);
1849 if (doi_def == NULL) 1847 if (doi_def == NULL)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0298f80681f2..eda4f4a233f3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1172,8 +1172,8 @@ static int tcp_check_dsack(struct tcp_sock *tp, struct sk_buff *ack_skb,
1172 struct tcp_sack_block_wire *sp, int num_sacks, 1172 struct tcp_sack_block_wire *sp, int num_sacks,
1173 u32 prior_snd_una) 1173 u32 prior_snd_una)
1174{ 1174{
1175 u32 start_seq_0 = ntohl(get_unaligned(&sp[0].start_seq)); 1175 u32 start_seq_0 = get_unaligned_be32(&sp[0].start_seq);
1176 u32 end_seq_0 = ntohl(get_unaligned(&sp[0].end_seq)); 1176 u32 end_seq_0 = get_unaligned_be32(&sp[0].end_seq);
1177 int dup_sack = 0; 1177 int dup_sack = 0;
1178 1178
1179 if (before(start_seq_0, TCP_SKB_CB(ack_skb)->ack_seq)) { 1179 if (before(start_seq_0, TCP_SKB_CB(ack_skb)->ack_seq)) {
@@ -1181,8 +1181,8 @@ static int tcp_check_dsack(struct tcp_sock *tp, struct sk_buff *ack_skb,
1181 tcp_dsack_seen(tp); 1181 tcp_dsack_seen(tp);
1182 NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV); 1182 NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV);
1183 } else if (num_sacks > 1) { 1183 } else if (num_sacks > 1) {
1184 u32 end_seq_1 = ntohl(get_unaligned(&sp[1].end_seq)); 1184 u32 end_seq_1 = get_unaligned_be32(&sp[1].end_seq);
1185 u32 start_seq_1 = ntohl(get_unaligned(&sp[1].start_seq)); 1185 u32 start_seq_1 = get_unaligned_be32(&sp[1].start_seq);
1186 1186
1187 if (!after(end_seq_0, end_seq_1) && 1187 if (!after(end_seq_0, end_seq_1) &&
1188 !before(start_seq_0, start_seq_1)) { 1188 !before(start_seq_0, start_seq_1)) {
@@ -1453,8 +1453,8 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb,
1453 for (i = 0; i < num_sacks; i++) { 1453 for (i = 0; i < num_sacks; i++) {
1454 int dup_sack = !i && found_dup_sack; 1454 int dup_sack = !i && found_dup_sack;
1455 1455
1456 sp[used_sacks].start_seq = ntohl(get_unaligned(&sp_wire[i].start_seq)); 1456 sp[used_sacks].start_seq = get_unaligned_be32(&sp_wire[i].start_seq);
1457 sp[used_sacks].end_seq = ntohl(get_unaligned(&sp_wire[i].end_seq)); 1457 sp[used_sacks].end_seq = get_unaligned_be32(&sp_wire[i].end_seq);
1458 1458
1459 if (!tcp_is_sackblock_valid(tp, dup_sack, 1459 if (!tcp_is_sackblock_valid(tp, dup_sack,
1460 sp[used_sacks].start_seq, 1460 sp[used_sacks].start_seq,
@@ -3340,7 +3340,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
3340 switch (opcode) { 3340 switch (opcode) {
3341 case TCPOPT_MSS: 3341 case TCPOPT_MSS:
3342 if (opsize == TCPOLEN_MSS && th->syn && !estab) { 3342 if (opsize == TCPOLEN_MSS && th->syn && !estab) {
3343 u16 in_mss = ntohs(get_unaligned((__be16 *)ptr)); 3343 u16 in_mss = get_unaligned_be16(ptr);
3344 if (in_mss) { 3344 if (in_mss) {
3345 if (opt_rx->user_mss && 3345 if (opt_rx->user_mss &&
3346 opt_rx->user_mss < in_mss) 3346 opt_rx->user_mss < in_mss)
@@ -3369,8 +3369,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
3369 ((estab && opt_rx->tstamp_ok) || 3369 ((estab && opt_rx->tstamp_ok) ||
3370 (!estab && sysctl_tcp_timestamps))) { 3370 (!estab && sysctl_tcp_timestamps))) {
3371 opt_rx->saw_tstamp = 1; 3371 opt_rx->saw_tstamp = 1;
3372 opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr)); 3372 opt_rx->rcv_tsval = get_unaligned_be32(ptr);
3373 opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4))); 3373 opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4);
3374 } 3374 }
3375 break; 3375 break;
3376 case TCPOPT_SACK_PERM: 3376 case TCPOPT_SACK_PERM: