浏览代码

sctp: remove dup code in net/sctp/output.c

Use sctp_packet_reset() instead of dup code.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Wei Yongjun 15 年之前
父节点
当前提交
be2971438d
共有 1 个文件被更改,包括 13 次插入24 次删除
  1. 13 24
      net/sctp/output.c

+ 13 - 24
net/sctp/output.c

@@ -69,6 +69,17 @@ static sctp_xmit_t sctp_packet_will_fit(struct sctp_packet *packet,
 					struct sctp_chunk *chunk,
 					struct sctp_chunk *chunk,
 					u16 chunk_len);
 					u16 chunk_len);
 
 
+static void sctp_packet_reset(struct sctp_packet *packet)
+{
+	packet->size = packet->overhead;
+	packet->has_cookie_echo = 0;
+	packet->has_sack = 0;
+	packet->has_data = 0;
+	packet->has_auth = 0;
+	packet->ipfragok = 0;
+	packet->auth = NULL;
+}
+
 /* Config a packet.
 /* Config a packet.
  * This appears to be a followup set of initializations.
  * This appears to be a followup set of initializations.
  */
  */
@@ -80,13 +91,8 @@ struct sctp_packet *sctp_packet_config(struct sctp_packet *packet,
 	SCTP_DEBUG_PRINTK("%s: packet:%p vtag:0x%x\n", __func__,
 	SCTP_DEBUG_PRINTK("%s: packet:%p vtag:0x%x\n", __func__,
 			  packet, vtag);
 			  packet, vtag);
 
 
+	sctp_packet_reset(packet);
 	packet->vtag = vtag;
 	packet->vtag = vtag;
-	packet->has_cookie_echo = 0;
-	packet->has_sack = 0;
-	packet->has_auth = 0;
-	packet->has_data = 0;
-	packet->ipfragok = 0;
-	packet->auth = NULL;
 
 
 	if (ecn_capable && sctp_packet_empty(packet)) {
 	if (ecn_capable && sctp_packet_empty(packet)) {
 		chunk = sctp_get_ecne_prepend(packet->transport->asoc);
 		chunk = sctp_get_ecne_prepend(packet->transport->asoc);
@@ -124,29 +130,12 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
 	}
 	}
 	overhead += sizeof(struct sctphdr);
 	overhead += sizeof(struct sctphdr);
 	packet->overhead = overhead;
 	packet->overhead = overhead;
-	packet->size = overhead;
+	sctp_packet_reset(packet);
 	packet->vtag = 0;
 	packet->vtag = 0;
-	packet->has_cookie_echo = 0;
-	packet->has_sack = 0;
-	packet->has_auth = 0;
-	packet->has_data = 0;
-	packet->ipfragok = 0;
 	packet->malloced = 0;
 	packet->malloced = 0;
-	packet->auth = NULL;
 	return packet;
 	return packet;
 }
 }
 
 
-static void sctp_packet_reset(struct sctp_packet *packet)
-{
-	packet->size = packet->overhead;
-	packet->has_cookie_echo = 0;
-	packet->has_sack = 0;
-	packet->has_data = 0;
-	packet->has_auth = 0;
-	packet->ipfragok = 0;
-	packet->auth = NULL;
-}
-
 /* Free a packet.  */
 /* Free a packet.  */
 void sctp_packet_free(struct sctp_packet *packet)
 void sctp_packet_free(struct sctp_packet *packet)
 {
 {