Commit d3e2ce3bcdbf4319dea308c79b5f72a8ecc8015c
Committed by
David S. Miller
1 parent
8398531939
Exists in
master
and in
7 other branches
net: use get/put_unaligned_* helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 4 changed files with 21 additions and 23 deletions Side-by-side Diff
net/bridge/br_stp_bpdu.c
... | ... | @@ -58,12 +58,12 @@ |
58 | 58 | { |
59 | 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 | |
64 | 64 | static 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 | 68 | return DIV_ROUND_UP(ticks * HZ, STP_HZ); |
69 | 69 | } |
net/core/filter.c
... | ... | @@ -213,7 +213,7 @@ |
213 | 213 | load_w: |
214 | 214 | ptr = load_pointer(skb, k, 4, &tmp); |
215 | 215 | if (ptr != NULL) { |
216 | - A = ntohl(get_unaligned((__be32 *)ptr)); | |
216 | + A = get_unaligned_be32(ptr); | |
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | break; |
... | ... | @@ -222,7 +222,7 @@ |
222 | 222 | load_h: |
223 | 223 | ptr = load_pointer(skb, k, 2, &tmp); |
224 | 224 | if (ptr != NULL) { |
225 | - A = ntohs(get_unaligned((__be16 *)ptr)); | |
225 | + A = get_unaligned_be16(ptr); | |
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | break; |
net/ipv4/cipso_ipv4.c
... | ... | @@ -983,7 +983,7 @@ |
983 | 983 | return -EFAULT; |
984 | 984 | |
985 | 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 | 987 | if (cat <= cat_prev) |
988 | 988 | return -EFAULT; |
989 | 989 | cat_prev = cat; |
... | ... | @@ -1052,7 +1052,7 @@ |
1052 | 1052 | |
1053 | 1053 | for (iter = 0; iter < net_cat_len; iter += 2) { |
1054 | 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 | 1056 | GFP_ATOMIC); |
1057 | 1057 | if (ret_val != 0) |
1058 | 1058 | return ret_val; |
1059 | 1059 | |
... | ... | @@ -1086,10 +1086,9 @@ |
1086 | 1086 | return -EFAULT; |
1087 | 1087 | |
1088 | 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 | 1090 | if ((iter + 4) <= rngcat_len) |
1091 | - cat_low = ntohs( | |
1092 | - get_unaligned((__be16 *)&rngcat[iter + 2])); | |
1091 | + cat_low = get_unaligned_be16(&rngcat[iter + 2]); | |
1093 | 1092 | else |
1094 | 1093 | cat_low = 0; |
1095 | 1094 | |
1096 | 1095 | |
... | ... | @@ -1188,10 +1187,9 @@ |
1188 | 1187 | u16 cat_high; |
1189 | 1188 | |
1190 | 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 | 1191 | if ((net_iter + 4) <= net_cat_len) |
1193 | - cat_low = ntohs( | |
1194 | - get_unaligned((__be16 *)&net_cat[net_iter + 2])); | |
1192 | + cat_low = get_unaligned_be16(&net_cat[net_iter + 2]); | |
1195 | 1193 | else |
1196 | 1194 | cat_low = 0; |
1197 | 1195 | |
... | ... | @@ -1562,7 +1560,7 @@ |
1562 | 1560 | } |
1563 | 1561 | |
1564 | 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 | 1564 | if (doi_def == NULL) { |
1567 | 1565 | err_offset = 2; |
1568 | 1566 | goto validate_return_locked; |
... | ... | @@ -1843,7 +1841,7 @@ |
1843 | 1841 | if (cipso_v4_cache_check(cipso, cipso[1], secattr) == 0) |
1844 | 1842 | return 0; |
1845 | 1843 | |
1846 | - doi = ntohl(get_unaligned((__be32 *)&cipso[2])); | |
1844 | + doi = get_unaligned_be32(&cipso[2]); | |
1847 | 1845 | rcu_read_lock(); |
1848 | 1846 | doi_def = cipso_v4_doi_search(doi); |
1849 | 1847 | if (doi_def == NULL) |
net/ipv4/tcp_input.c
... | ... | @@ -1172,8 +1172,8 @@ |
1172 | 1172 | struct tcp_sack_block_wire *sp, int num_sacks, |
1173 | 1173 | u32 prior_snd_una) |
1174 | 1174 | { |
1175 | - u32 start_seq_0 = ntohl(get_unaligned(&sp[0].start_seq)); | |
1176 | - u32 end_seq_0 = ntohl(get_unaligned(&sp[0].end_seq)); | |
1175 | + u32 start_seq_0 = get_unaligned_be32(&sp[0].start_seq); | |
1176 | + u32 end_seq_0 = get_unaligned_be32(&sp[0].end_seq); | |
1177 | 1177 | int dup_sack = 0; |
1178 | 1178 | |
1179 | 1179 | if (before(start_seq_0, TCP_SKB_CB(ack_skb)->ack_seq)) { |
... | ... | @@ -1181,8 +1181,8 @@ |
1181 | 1181 | tcp_dsack_seen(tp); |
1182 | 1182 | NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV); |
1183 | 1183 | } else if (num_sacks > 1) { |
1184 | - u32 end_seq_1 = ntohl(get_unaligned(&sp[1].end_seq)); | |
1185 | - u32 start_seq_1 = ntohl(get_unaligned(&sp[1].start_seq)); | |
1184 | + u32 end_seq_1 = get_unaligned_be32(&sp[1].end_seq); | |
1185 | + u32 start_seq_1 = get_unaligned_be32(&sp[1].start_seq); | |
1186 | 1186 | |
1187 | 1187 | if (!after(end_seq_0, end_seq_1) && |
1188 | 1188 | !before(start_seq_0, start_seq_1)) { |
... | ... | @@ -1453,8 +1453,8 @@ |
1453 | 1453 | for (i = 0; i < num_sacks; i++) { |
1454 | 1454 | int dup_sack = !i && found_dup_sack; |
1455 | 1455 | |
1456 | - sp[used_sacks].start_seq = ntohl(get_unaligned(&sp_wire[i].start_seq)); | |
1457 | - sp[used_sacks].end_seq = ntohl(get_unaligned(&sp_wire[i].end_seq)); | |
1456 | + sp[used_sacks].start_seq = get_unaligned_be32(&sp_wire[i].start_seq); | |
1457 | + sp[used_sacks].end_seq = get_unaligned_be32(&sp_wire[i].end_seq); | |
1458 | 1458 | |
1459 | 1459 | if (!tcp_is_sackblock_valid(tp, dup_sack, |
1460 | 1460 | sp[used_sacks].start_seq, |
... | ... | @@ -3340,7 +3340,7 @@ |
3340 | 3340 | switch (opcode) { |
3341 | 3341 | case TCPOPT_MSS: |
3342 | 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 | 3344 | if (in_mss) { |
3345 | 3345 | if (opt_rx->user_mss && |
3346 | 3346 | opt_rx->user_mss < in_mss) |
... | ... | @@ -3369,8 +3369,8 @@ |
3369 | 3369 | ((estab && opt_rx->tstamp_ok) || |
3370 | 3370 | (!estab && sysctl_tcp_timestamps))) { |
3371 | 3371 | opt_rx->saw_tstamp = 1; |
3372 | - opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr)); | |
3373 | - opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4))); | |
3372 | + opt_rx->rcv_tsval = get_unaligned_be32(ptr); | |
3373 | + opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4); | |
3374 | 3374 | } |
3375 | 3375 | break; |
3376 | 3376 | case TCPOPT_SACK_PERM: |