提交 6a1e5f33 编写于 作者: A Al Viro 提交者: David S. Miller

[SCTP]: sctp_process_init() and sctp_source() switched to net-endian.

both are done in one go since almost always we have result of
the latter immediately passed to the former.  Possibly non-obvious
note: sctp_process_param() is endian-agnostic
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 02a8a4db
...@@ -346,10 +346,8 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep) ...@@ -346,10 +346,8 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep)
* COOKIE-ECHO chunk. * COOKIE-ECHO chunk.
*/ */
if (NULL == chunk->asoc) { if (NULL == chunk->asoc) {
union sctp_addr tmp;
flip_to_n(&tmp, sctp_source(chunk));
asoc = sctp_endpoint_lookup_assoc(ep, asoc = sctp_endpoint_lookup_assoc(ep,
&tmp, sctp_source(chunk),
&transport); &transport);
chunk->asoc = asoc; chunk->asoc = asoc;
chunk->transport = transport; chunk->transport = transport;
......
...@@ -1041,10 +1041,10 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk) ...@@ -1041,10 +1041,10 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk)
{ {
/* If we have a known transport, use that. */ /* If we have a known transport, use that. */
if (chunk->transport) { if (chunk->transport) {
return &chunk->transport->ipaddr_h; return &chunk->transport->ipaddr;
} else { } else {
/* Otherwise, extract it from the IP header. */ /* Otherwise, extract it from the IP header. */
return &chunk->source_h; return &chunk->source;
} }
} }
...@@ -1844,7 +1844,6 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, ...@@ -1844,7 +1844,6 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
struct sctp_transport *transport; struct sctp_transport *transport;
struct list_head *pos, *temp; struct list_head *pos, *temp;
char *cookie; char *cookie;
union sctp_addr tmp;
/* We must include the address that the INIT packet came from. /* We must include the address that the INIT packet came from.
* This is the only address that matters for an INIT packet. * This is the only address that matters for an INIT packet.
...@@ -1857,8 +1856,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, ...@@ -1857,8 +1856,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
* be a a better choice than any of the embedded addresses. * be a a better choice than any of the embedded addresses.
*/ */
if (peer_addr) { if (peer_addr) {
flip_to_n(&tmp, peer_addr); if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
if(!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_ACTIVE))
goto nomem; goto nomem;
} }
...@@ -2419,7 +2417,6 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, ...@@ -2419,7 +2417,6 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
union sctp_addr addr; union sctp_addr addr;
struct list_head *pos; struct list_head *pos;
union sctp_addr_param *addr_param; union sctp_addr_param *addr_param;
union sctp_addr tmp;
addr_param = (union sctp_addr_param *) addr_param = (union sctp_addr_param *)
((void *)asconf_param + sizeof(sctp_addip_param_t)); ((void *)asconf_param + sizeof(sctp_addip_param_t));
...@@ -2463,8 +2460,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, ...@@ -2463,8 +2460,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
* an Error Cause TLV set to the new error code 'Request to * an Error Cause TLV set to the new error code 'Request to
* Delete Source IP Address' * Delete Source IP Address'
*/ */
flip_to_n(&tmp, sctp_source(asconf)); if (sctp_cmp_addr_exact(sctp_source(asconf), &addr))
if (sctp_cmp_addr_exact(&tmp, &addr))
return SCTP_ERROR_DEL_SRC_IP; return SCTP_ERROR_DEL_SRC_IP;
sctp_assoc_del_peer(asoc, &addr); sctp_assoc_del_peer(asoc, &addr);
......
...@@ -598,7 +598,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, ...@@ -598,7 +598,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
struct sctp_ulpevent *ev, *ai_ev = NULL; struct sctp_ulpevent *ev, *ai_ev = NULL;
int error = 0; int error = 0;
struct sctp_chunk *err_chk_p; struct sctp_chunk *err_chk_p;
union sctp_addr tmp;
/* If the packet is an OOTB packet which is temporarily on the /* If the packet is an OOTB packet which is temporarily on the
* control endpoint, respond with an ABORT. * control endpoint, respond with an ABORT.
...@@ -666,9 +665,8 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, ...@@ -666,9 +665,8 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
*/ */
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
flip_to_h(&tmp, &chunk->subh.cookie_hdr->c.peer_addr);
if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type, if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,
&tmp, &chunk->subh.cookie_hdr->c.peer_addr,
peer_init, GFP_ATOMIC)) peer_init, GFP_ATOMIC))
goto nomem_init; goto nomem_init;
...@@ -5105,7 +5103,6 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc ...@@ -5105,7 +5103,6 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc
__u16 sport; __u16 sport;
__u16 dport; __u16 dport;
__u32 vtag; __u32 vtag;
union sctp_addr tmp;
/* Get the source and destination port from the inbound packet. */ /* Get the source and destination port from the inbound packet. */
sport = ntohs(chunk->sctp_hdr->dest); sport = ntohs(chunk->sctp_hdr->dest);
...@@ -5136,8 +5133,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc ...@@ -5136,8 +5133,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc
} }
/* Make a transport for the bucket, Eliza... */ /* Make a transport for the bucket, Eliza... */
flip_to_n(&tmp, sctp_source(chunk)); transport = sctp_transport_new(sctp_source(chunk), GFP_ATOMIC);
transport = sctp_transport_new(&tmp, GFP_ATOMIC);
if (!transport) if (!transport)
goto nomem; goto nomem;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册