DCCP protocol discussions
 help / color / mirror / Atom feed
* [PATCH 2/4] [DCCP] ccid2: coding style cleanups
From: Arnaldo Carvalho de Melo @ 2006-02-28 22:09 UTC (permalink / raw)
  To: dccp

No changes in the logic where made.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/ccids/ccid2.c |   76 ++++++++++++++++--------------------------------
 1 files changed, 26 insertions(+), 50 deletions(-)

1c6ddda9288aba6a761b45357d119a47df165d4a
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 11c73ab..e00e225 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -37,10 +37,7 @@
 
 static int ccid2_debug;
 
-#if 0
-#define CCID2_DEBUG
-#endif
-
+#undef CCID2_DEBUG
 #ifdef CCID2_DEBUG
 #define ccid2_pr_debug(format, a...) \
         do { if (ccid2_debug) \
@@ -56,10 +53,8 @@ static const int ccid2_seq_len = 128;
 static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
 {
 	int len = 0;
-	struct ccid2_seq *seqp;
 	int pipe = 0;
-
-	seqp = hctx->ccid2hctx_seqh;
+	struct ccid2_seq *seqp = hctx->ccid2hctx_seqh;
 
 	/* there is data in the chain */
 	if (seqp != hctx->ccid2hctx_seqt) {
@@ -69,9 +64,8 @@ static void ccid2_hc_tx_check_sanity(con
 			pipe++;
 	
 		while (seqp != hctx->ccid2hctx_seqt) {
-			struct ccid2_seq *prev;
+			struct ccid2_seq *prev = seqp->ccid2s_prev;
 
-			prev = seqp->ccid2s_prev;
 			len++;
 			if (!prev->ccid2s_acked)
 				pipe++;
@@ -92,7 +86,7 @@ static void ccid2_hc_tx_check_sanity(con
 		seqp = seqp->ccid2s_prev;
 		len++;
 		BUG_ON(len > ccid2_seq_len);
-	} while(seqp != hctx->ccid2hctx_seqh);
+	} while (seqp != hctx->ccid2hctx_seqh);
 
 	BUG_ON(len != ccid2_seq_len);
 	ccid2_pr_debug("total len=%d\n", len);
@@ -141,7 +135,7 @@ static void ccid2_change_l_ack_ratio(str
 	 * -sorbo.
 	 */
 	if (val != 2) {
-		struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
+		const struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
 		int max = hctx->ccid2hctx_cwnd / 2;
 
 		/* round up */
@@ -179,9 +173,6 @@ static void ccid2_hc_tx_rto_expire(unsig
 	struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
 	long s;
 
-	/* XXX I don't think i'm locking correctly
-	 * -sorbo.
-	 */
 	bh_lock_sock(sk);
 	if (sock_owned_by_user(sk)) {
 		sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
@@ -278,36 +269,33 @@ static void ccid2_hc_tx_packet_sent(stru
 	/* We had an ack loss in this window... */
 	if (hctx->ccid2hctx_ackloss) {
 		if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) {
-			hctx->ccid2hctx_arsent = 0;
-			hctx->ccid2hctx_ackloss = 0;
+			hctx->ccid2hctx_arsent	= 0;
+			hctx->ccid2hctx_ackloss	= 0;
 		}
-	}
-	/* No acks lost up to now... */
-	else {
+	} else {
+		/* No acks lost up to now... */
 		/* decrease ack ratio if enough packets were sent */
 		if (dp->dccps_l_ack_ratio > 1) {
 			/* XXX don't calculate denominator each time */
-			int denom;
+			int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - 
+				    dp->dccps_l_ack_ratio;
 
-			denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - 
-				dp->dccps_l_ack_ratio;
 			denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom;
 
 			if (hctx->ccid2hctx_arsent >= denom) {
 				ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
 				hctx->ccid2hctx_arsent = 0;
 			}
-		}
-		/* we can't increase ack ratio further [1] */
-		else {
+		} else {
+			/* we can't increase ack ratio further [1] */
 			hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/
 		}
 	}
 
 	/* setup RTO timer */
-	if (!timer_pending(&hctx->ccid2hctx_rtotimer)) {
+	if (!timer_pending(&hctx->ccid2hctx_rtotimer))
 		ccid2_start_rto_timer(sk);
-	}
+
 #ifdef CCID2_DEBUG
 	ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
 	ccid2_pr_debug("Sent: seq=%llu\n", seq);
@@ -320,7 +308,7 @@ static void ccid2_hc_tx_packet_sent(stru
 				       seqp->ccid2s_sent);
 			seqp = seqp->ccid2s_next;
 		}
-	} while(0);
+	} while (0);
 	ccid2_pr_debug("=====\n");
 	ccid2_hc_tx_check_sanity(hctx);
 #endif
@@ -378,7 +366,6 @@ static int ccid2_ackvector(struct sock *
 			*vec	= value;
 			*veclen = len;
 			return offset + (opt_ptr - options);
-			break;
 		}
 	}
 
@@ -416,13 +403,11 @@ static inline void ccid2_new_ack(struct 
 				hctx->ccid2hctx_ssacks = 0;
 				*maxincr = *maxincr - 1;
 			}
-		}
-		/* increased cwnd enough for this single ack */
-		else {
+		} else {
+			/* increased cwnd enough for this single ack */
 			hctx->ccid2hctx_ssacks = 0;
 		}
-	}
-	else {
+	} else {
 		hctx->ccid2hctx_ssacks = 0;
 		hctx->ccid2hctx_acks++;
 
@@ -444,8 +429,7 @@ static inline void ccid2_new_ack(struct 
 			       	       r, jiffies, seqp->ccid2s_seq);
 			hctx->ccid2hctx_srtt = r;
 			hctx->ccid2hctx_rttvar = r >> 1;
-		}
-		else {
+		} else {
 			/* RTTVAR */
 			long tmp = hctx->ccid2hctx_srtt - r;
 			if (tmp < 0)
@@ -528,12 +512,10 @@ static void ccid2_hc_tx_packet_recv(stru
 	if (hctx->ccid2hctx_rpdupack = -1) {
 		hctx->ccid2hctx_rpdupack = 0;
 		hctx->ccid2hctx_rpseq = seqno;
-	}
-	else {
+	} else {
 		/* check if packet is consecutive */
-		if ((hctx->ccid2hctx_rpseq + 1) = seqno) {
+		if ((hctx->ccid2hctx_rpseq + 1) = seqno)
 			hctx->ccid2hctx_rpseq++;
-		}
 		/* it's a later packet */
 		else if (after48(seqno, hctx->ccid2hctx_rpseq)) {
 			hctx->ccid2hctx_rpdupack++;
@@ -541,7 +523,6 @@ static void ccid2_hc_tx_packet_recv(stru
 			/* check if we got enough dupacks */
 			if (hctx->ccid2hctx_rpdupack > 			    hctx->ccid2hctx_numdupack) {
-
 				hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
 				hctx->ccid2hctx_rpseq = 0;
 
@@ -559,7 +540,6 @@ static void ccid2_hc_tx_packet_recv(stru
 	case DCCP_PKT_ACK:
 	case DCCP_PKT_DATAACK:
 		break;
-	
 	default:
 		return;
 	}
@@ -612,11 +592,9 @@ static void ccid2_hc_tx_packet_recv(stru
 				    	if (state = 
 					    DCCP_ACKVEC_STATE_ECN_MARKED) {
 						loss = 1;
-					}
-					else {
+					} else
 						ccid2_new_ack(sk, seqp,
 							      &maxincr);
-					}
 
 					seqp->ccid2s_acked = 1;
 					ccid2_pr_debug("Got ack for %llu\n",
@@ -648,13 +626,11 @@ static void ccid2_hc_tx_packet_recv(stru
 	while (1) {
 		if (seqp->ccid2s_acked) {
 			done++;
-			if (done = hctx->ccid2hctx_numdupack) {
+			if (done = hctx->ccid2hctx_numdupack)
 				break;
-			}	
 		}
-		if (seqp = hctx->ccid2hctx_seqt) {
+		if (seqp = hctx->ccid2hctx_seqt)
 			break;
-		}
 		seqp = seqp->ccid2s_prev;
 	}
 
@@ -798,6 +774,6 @@ static __exit void ccid2_module_exit(voi
 module_exit(ccid2_module_exit);
 
 MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
-MODULE_DESCRIPTION("DCCP TCP CCID2 CCID");
+MODULE_DESCRIPTION("DCCP TCP-Like (CCID2) CCID");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("net-dccp-ccid-2");
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 1/4] [DCCP] ipv6: cleanups
From: Arnaldo Carvalho de Melo @ 2006-02-28 22:09 UTC (permalink / raw)
  To: dccp

No changes in the logic were made, just removing trailing whitespaces, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/ipv6.c |  256 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 129 insertions(+), 127 deletions(-)

1cb5220969e0f2ceef2ad5f0d280e8a98221ed63
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 6bd9979..f28f38f 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1,6 +1,6 @@
 /*
  *	DCCP over IPv6
- *	Linux INET6 implementation 
+ *	Linux INET6 implementation
  *
  *	Based on net/dccp6/ipv6.c
  *
@@ -66,8 +66,8 @@ static void dccp_v6_hash(struct sock *sk
 }
 
 static inline u16 dccp_v6_check(struct dccp_hdr *dh, int len,
-				struct in6_addr *saddr, 
-				struct in6_addr *daddr, 
+				struct in6_addr *saddr,
+				struct in6_addr *daddr,
 				unsigned long base)
 {
 	return csum_ipv6_magic(saddr, daddr, len, IPPROTO_DCCP, base);
@@ -82,17 +82,17 @@ static __u32 dccp_v6_init_sequence(struc
 						    skb->nh.ipv6h->saddr.s6_addr32,
 						    dh->dccph_dport,
 						    dh->dccph_sport);
-	else
-		return secure_dccp_sequence_number(skb->nh.iph->daddr,
-						   skb->nh.iph->saddr,
-						   dh->dccph_dport,
-						   dh->dccph_sport);
+
+	return secure_dccp_sequence_number(skb->nh.iph->daddr,
+					   skb->nh.iph->saddr,
+					   dh->dccph_dport,
+					   dh->dccph_sport);
 }
 
-static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 
+static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
 			   int addr_len)
 {
-	struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
+	struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct inet_sock *inet = inet_sk(sk);
 	struct ipv6_pinfo *np = inet6_sk(sk);
@@ -105,10 +105,10 @@ static int dccp_v6_connect(struct sock *
 
 	dp->dccps_role = DCCP_ROLE_CLIENT;
 
-	if (addr_len < SIN6_LEN_RFC2133) 
+	if (addr_len < SIN6_LEN_RFC2133)
 		return -EINVAL;
 
-	if (usin->sin6_family != AF_INET6) 
+	if (usin->sin6_family != AF_INET6)
 		return -EAFNOSUPPORT;
 
 	memset(&fl, 0, sizeof(fl));
@@ -125,17 +125,15 @@ static int dccp_v6_connect(struct sock *
 			fl6_sock_release(flowlabel);
 		}
 	}
-
 	/*
-  	 *	connect() to INADDR_ANY means loopback (BSD'ism).
-  	 */
-  	
-  	if (ipv6_addr_any(&usin->sin6_addr))
-		usin->sin6_addr.s6_addr[15] = 0x1; 
+	 * connect() to INADDR_ANY means loopback (BSD'ism).
+	 */
+	if (ipv6_addr_any(&usin->sin6_addr))
+		usin->sin6_addr.s6_addr[15] = 1;
 
 	addr_type = ipv6_addr_type(&usin->sin6_addr);
 
-	if(addr_type & IPV6_ADDR_MULTICAST)
+	if (addr_type & IPV6_ADDR_MULTICAST)
 		return -ENETUNREACH;
 
 	if (addr_type & IPV6_ADDR_LINKLOCAL) {
@@ -160,9 +158,8 @@ static int dccp_v6_connect(struct sock *
 	np->flow_label = fl.fl6_flowlabel;
 
 	/*
-	 *	DCCP over IPv4
+	 * DCCP over IPv4
 	 */
-
 	if (addr_type = IPV6_ADDR_MAPPED) {
 		u32 exthdrlen = icsk->icsk_ext_hdr_len;
 		struct sockaddr_in sin;
@@ -180,7 +177,6 @@ static int dccp_v6_connect(struct sock *
 		sk->sk_backlog_rcv = dccp_v4_do_rcv;
 
 		err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
-
 		if (err) {
 			icsk->icsk_ext_hdr_len = exthdrlen;
 			icsk->icsk_af_ops = &dccp_ipv6_af_ops;
@@ -206,8 +202,9 @@ static int dccp_v6_connect(struct sock *
 	fl.fl_ip_dport = usin->sin6_port;
 	fl.fl_ip_sport = inet->sport;
 
-	if (np->opt && np->opt->srcrt) {
-		struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
+	if (np->opt != NULL && np->opt->srcrt != NULL) {
+		const struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
+
 		ipv6_addr_copy(&final, &fl.fl6_dst);
 		ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
 		final_p = &final;
@@ -216,10 +213,12 @@ static int dccp_v6_connect(struct sock *
 	err = ip6_dst_lookup(sk, &dst, &fl);
 	if (err)
 		goto failure;
+
 	if (final_p)
 		ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-	if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
+	err = xfrm_lookup(&dst, &fl, sk, 0);
+	if (err < 0)
 		goto failure;
 
 	if (saddr = NULL) {
@@ -234,7 +233,7 @@ static int dccp_v6_connect(struct sock *
 	ip6_dst_store(sk, dst, NULL);
 
 	icsk->icsk_ext_hdr_len = 0;
-	if (np->opt)
+	if (np->opt != NULL)
 		icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
 					  np->opt->opt_nflen);
 
@@ -308,7 +307,6 @@ static void dccp_v6_err(struct sk_buff *
 
 		/* icmp should have updated the destination cache entry */
 		dst = __sk_dst_check(sk, np->dst_cookie);
-
 		if (dst = NULL) {
 			struct inet_sock *inet = inet_sk(sk);
 			struct flowi fl;
@@ -325,16 +323,17 @@ static void dccp_v6_err(struct sk_buff *
 			fl.fl_ip_dport = inet->dport;
 			fl.fl_ip_sport = inet->sport;
 
-			if ((err = ip6_dst_lookup(sk, &dst, &fl))) {
+			err = ip6_dst_lookup(sk, &dst, &fl);
+			if (err) {
 				sk->sk_err_soft = -err;
 				goto out;
 			}
 
-			if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) {
+			err = xfrm_lookup(&dst, &fl, sk, 0);
+			if (err < 0) {
 				sk->sk_err_soft = -err;
 				goto out;
 			}
-
 		} else
 			dst_hold(dst);
 
@@ -358,11 +357,12 @@ static void dccp_v6_err(struct sk_buff *
 		req = inet6_csk_search_req(sk, &prev, dh->dccph_dport,
 					   &hdr->daddr, &hdr->saddr,
 					   inet6_iif(skb));
-		if (!req)
+		if (req = NULL)
 			goto out;
 
-		/* ICMPs are not backlogged, hence we cannot get
-		 * an established socket here.
+		/*
+		 * ICMPs are not backlogged, hence we cannot get an established
+		 * socket here.
 		 */
 		BUG_TRAP(req->sk = NULL);
 
@@ -376,7 +376,7 @@ static void dccp_v6_err(struct sk_buff *
 
 	case DCCP_REQUESTING:
 	case DCCP_RESPOND:  /* Cannot happen.
-			       It can, it SYNs are crossed. --ANK */ 
+			       It can, it SYNs are crossed. --ANK */
 		if (!sock_owned_by_user(sk)) {
 			DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
 			sk->sk_err = err;
@@ -385,7 +385,6 @@ static void dccp_v6_err(struct sk_buff *
 			 * (see connect in sock.c)
 			 */
 			sk->sk_error_report(sk);
-
 			dccp_done(sk);
 		} else
 			sk->sk_err_soft = err;
@@ -431,14 +430,16 @@ static int dccp_v6_send_response(struct 
 		    ireq6->pktopts) {
 			struct sk_buff *pktopts = ireq6->pktopts;
 			struct inet6_skb_parm *rxopt = IP6CB(pktopts);
+
 			if (rxopt->srcrt)
 				opt = ipv6_invert_rthdr(sk,
 					(struct ipv6_rt_hdr *)(pktopts->nh.raw +
 							       rxopt->srcrt));
 		}
 
-		if (opt && opt->srcrt) {
-			struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
+		if (opt != NULL && opt->srcrt != NULL) {
+			const struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
+
 			ipv6_addr_copy(&final, &fl.fl6_dst);
 			ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
 			final_p = &final;
@@ -447,15 +448,19 @@ static int dccp_v6_send_response(struct 
 		err = ip6_dst_lookup(sk, &dst, &fl);
 		if (err)
 			goto done;
+
 		if (final_p)
 			ipv6_addr_copy(&fl.fl6_dst, final_p);
-		if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
+
+		err = xfrm_lookup(&dst, &fl, sk, 0);
+		if (err < 0)
 			goto done;
 	}
 
 	skb = dccp_make_response(sk, dst, req);
 	if (skb != NULL) {
 		struct dccp_hdr *dh = dccp_hdr(skb);
+
 		dh->dccph_checksum = dccp_v6_check(dh, skb->len,
 						   &ireq6->loc_addr,
 						   &ireq6->rmt_addr,
@@ -469,7 +474,7 @@ static int dccp_v6_send_response(struct 
 	}
 
 done:
-        if (opt && opt != np->opt)
+	if (opt != NULL && opt != np->opt)
 		sock_kfree_s(sk, opt, opt->tot_len);
 	dst_release(dst);
 	return err;
@@ -500,7 +505,7 @@ static void dccp_v6_send_check(struct so
 	struct dccp_hdr *dh = dccp_hdr(skb);
 
 	dh->dccph_checksum = csum_ipv6_magic(&np->saddr, &np->daddr,
-					     len, IPPROTO_DCCP, 
+					     len, IPPROTO_DCCP,
 					     csum_partial((char *)dh,
 							  dh->dccph_doff << 2,
 							  skb->csum));
@@ -508,7 +513,7 @@ static void dccp_v6_send_check(struct so
 
 static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
 {
-	struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; 
+	struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
 	const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
 				       sizeof(struct dccp_hdr_ext) +
 				       sizeof(struct dccp_hdr_reset);
@@ -520,7 +525,7 @@ static void dccp_v6_ctl_send_reset(struc
 		return;
 
 	if (!ipv6_unicast_destination(rxskb))
-		return; 
+		return;
 
 	/*
 	 * We need to grab some memory, and put together an RST,
@@ -529,7 +534,7 @@ static void dccp_v6_ctl_send_reset(struc
 
 	skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) +
 			dccp_hdr_reset_len, GFP_ATOMIC);
-	if (skb = NULL) 
+	if (skb = NULL)
 	  	return;
 
 	skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) +
@@ -608,7 +613,7 @@ static void dccp_v6_ctl_send_ack(struct 
 	dh->dccph_dport = rxdh->dccph_sport;
 	dh->dccph_doff	= dccp_hdr_ack_len / 4;
 	dh->dccph_x	= 1;
-	
+
 	dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
 	dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
 			 DCCP_SKB_CB(rxskb)->dccpd_seq);
@@ -660,7 +665,6 @@ static struct sock *dccp_v6_hnd_req(stru
 					 &iph->saddr, dh->dccph_sport,
 					 &iph->daddr, ntohs(dh->dccph_dport),
 					 inet6_iif(skb));
-
 	if (nsk != NULL) {
 		if (nsk->sk_state != DCCP_TIME_WAIT) {
 			bh_lock_sock(nsk);
@@ -689,17 +693,17 @@ static int dccp_v6_conn_request(struct s
 		return dccp_v4_conn_request(sk, skb);
 
 	if (!ipv6_unicast_destination(skb))
-		goto drop; 
+		goto drop;
 
 	if (dccp_bad_service_code(sk, service)) {
 		reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
 		goto drop;
  	}
 	/*
-	 *	There are no SYN attacks on IPv6, yet...	
+	 * There are no SYN attacks on IPv6, yet...
 	 */
 	if (inet_csk_reqsk_queue_is_full(sk))
-		goto drop;		
+		goto drop;
 
 	if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
 		goto drop;
@@ -733,7 +737,7 @@ static int dccp_v6_conn_request(struct s
 	    ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL)
 		ireq6->iif = inet6_iif(skb);
 
-	/* 
+	/*
 	 * Step 3: Process LISTEN state
 	 *
 	 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
@@ -777,9 +781,8 @@ static struct sock *dccp_v6_request_recv
 		/*
 		 *	v6 mapped
 		 */
-
 		newsk = dccp_v4_request_recv_sock(sk, skb, req, dst);
-		if (newsk = NULL) 
+		if (newsk = NULL)
 			return NULL;
 
 		newdp6 = (struct dccp6_sock *)newsk;
@@ -825,9 +828,9 @@ static struct sock *dccp_v6_request_recv
 	if (sk_acceptq_is_full(sk))
 		goto out_overflow;
 
-	if (np->rxopt.bits.osrcrt = 2 &&
-	    opt = NULL && ireq6->pktopts) {
-		struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts);
+	if (np->rxopt.bits.osrcrt = 2 && opt = NULL && ireq6->pktopts) {
+		const struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts);
+
 		if (rxopt->srcrt)
 			opt = ipv6_invert_rthdr(sk,
 				(struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw +
@@ -841,8 +844,9 @@ static struct sock *dccp_v6_request_recv
 		memset(&fl, 0, sizeof(fl));
 		fl.proto = IPPROTO_DCCP;
 		ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
-		if (opt && opt->srcrt) {
-			struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
+		if (opt != NULL && opt->srcrt != NULL) {
+			const struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
+
 			ipv6_addr_copy(&final, &fl.fl6_dst);
 			ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
 			final_p = &final;
@@ -860,7 +864,7 @@ static struct sock *dccp_v6_request_recv
 
 		if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0)
 			goto out;
-	} 
+	}
 
 	newsk = dccp_create_openreq_child(sk, req, skb);
 	if (newsk = NULL)
@@ -873,9 +877,8 @@ static struct sock *dccp_v6_request_recv
 	 */
 
 	ip6_dst_store(newsk, dst, NULL);
-	newsk->sk_route_caps = dst->dev->features &
-		~(NETIF_F_IP_CSUM | NETIF_F_TSO);
-
+	newsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |
+						      NETIF_F_TSO);
 	newdp6 = (struct dccp6_sock *)newsk;
 	newinet = inet_sk(newsk);
 	newinet->pinet6 = &newdp6->inet6;
@@ -889,7 +892,7 @@ static struct sock *dccp_v6_request_recv
 	ipv6_addr_copy(&newnp->rcv_saddr, &ireq6->loc_addr);
 	newsk->sk_bound_dev_if = ireq6->iif;
 
-	/* Now IPv6 options... 
+	/* Now IPv6 options...
 
 	   First: no IPv4 options.
 	 */
@@ -911,20 +914,20 @@ static struct sock *dccp_v6_request_recv
 	newnp->mcast_oif  = inet6_iif(skb);
 	newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
 
-	/* Clone native IPv6 options from listening socket (if any)
-
-	   Yes, keeping reference count would be much more clever,
-	   but we make one more one thing there: reattach optmem
-	   to newsk.
+	/*
+	 * Clone native IPv6 options from listening socket (if any)
+	 *
+	 * Yes, keeping reference count would be much more clever, but we make
+	 * one more one thing there: reattach optmem to newsk.
 	 */
-	if (opt) {
+	if (opt != NULL) {
 		newnp->opt = ipv6_dup_options(newsk, opt);
 		if (opt != np->opt)
 			sock_kfree_s(sk, opt, opt->tot_len);
 	}
 
 	inet_csk(newsk)->icsk_ext_hdr_len = 0;
-	if (newnp->opt)
+	if (newnp->opt != NULL)
 		inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen +
 						     newnp->opt->opt_flen);
 
@@ -941,7 +944,7 @@ out_overflow:
 	NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS);
 out:
 	NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS);
-	if (opt && opt != np->opt)
+	if (opt != NULL && opt != np->opt)
 		sock_kfree_s(sk, opt, opt->tot_len);
 	dst_release(dst);
 	return NULL;
@@ -975,8 +978,8 @@ static int dccp_v6_do_rcv(struct sock *s
 		goto discard;
 
 	/*
-	 *	socket locking is here for SMP purposes as backlog rcv
-	 *	is currently called with bh processing disabled.
+	 * socket locking is here for SMP purposes as backlog rcv is currently
+	 * called with bh processing disabled.
 	 */
 
 	/* Do Stevens' IPV6_PKTOPTIONS.
@@ -1001,20 +1004,20 @@ static int dccp_v6_do_rcv(struct sock *s
 		return 0;
 	}
 
-	if (sk->sk_state = DCCP_LISTEN) { 
+	if (sk->sk_state = DCCP_LISTEN) {
 		struct sock *nsk = dccp_v6_hnd_req(sk, skb);
-		if (!nsk)
-			goto discard;
 
+		if (nsk = NULL)
+			goto discard;
 		/*
 		 * Queue it on the new socket if the new socket is active,
 		 * otherwise we just shortcircuit this and continue with
 		 * the new socket..
 		 */
- 		if(nsk != sk) {
+ 		if (nsk != sk) {
 			if (dccp_child_process(sk, nsk, skb))
 				goto reset;
-			if (opt_skb)
+			if (opt_skb != NULL)
 				__kfree_skb(opt_skb);
 			return 0;
 		}
@@ -1027,7 +1030,7 @@ static int dccp_v6_do_rcv(struct sock *s
 reset:
 	dccp_v6_ctl_send_reset(skb);
 discard:
-	if (opt_skb)
+	if (opt_skb != NULL)
 		__kfree_skb(opt_skb);
 	kfree_skb(skb);
 	return 0;
@@ -1060,7 +1063,7 @@ static int dccp_v6_rcv(struct sk_buff **
 			    dh->dccph_sport,
 			    &skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport),
 			    inet6_iif(skb));
-	/* 
+	/*
 	 * Step 2:
 	 * 	If no socket ...
 	 *		Generate Reset(No Connection) unless P.type = Reset
@@ -1069,15 +1072,14 @@ static int dccp_v6_rcv(struct sk_buff **
 	if (sk = NULL)
 		goto no_dccp_socket;
 
-	/* 
+	/*
 	 * Step 2:
 	 * 	... or S.state = TIMEWAIT,
 	 *		Generate Reset(No Connection) unless P.type = Reset
 	 *		Drop packet and return
 	 */
-	       
 	if (sk->sk_state = DCCP_TIME_WAIT)
-                goto do_time_wait;
+		goto do_time_wait;
 
 	if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
 		goto discard_and_relse;
@@ -1116,32 +1118,32 @@ do_time_wait:
 }
 
 static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
-	.queue_xmit	=	inet6_csk_xmit,
-	.send_check	=	dccp_v6_send_check,
-	.rebuild_header	=	inet6_sk_rebuild_header,
-	.conn_request	=	dccp_v6_conn_request,
-	.syn_recv_sock	=	dccp_v6_request_recv_sock,
-	.net_header_len	=	sizeof(struct ipv6hdr),
-	.setsockopt	=	ipv6_setsockopt,
-	.getsockopt	=	ipv6_getsockopt,
-	.addr2sockaddr	=	inet6_csk_addr2sockaddr,
-	.sockaddr_len	=	sizeof(struct sockaddr_in6)
+	.queue_xmit	= inet6_csk_xmit,
+	.send_check	= dccp_v6_send_check,
+	.rebuild_header	= inet6_sk_rebuild_header,
+	.conn_request	= dccp_v6_conn_request,
+	.syn_recv_sock	= dccp_v6_request_recv_sock,
+	.net_header_len	= sizeof(struct ipv6hdr),
+	.setsockopt	= ipv6_setsockopt,
+	.getsockopt	= ipv6_getsockopt,
+	.addr2sockaddr	= inet6_csk_addr2sockaddr,
+	.sockaddr_len	= sizeof(struct sockaddr_in6)
 };
 
 /*
  *	DCCP over IPv4 via INET6 API
  */
 static struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
-	.queue_xmit	=	ip_queue_xmit,
-	.send_check	=	dccp_v4_send_check,
-	.rebuild_header	=	inet_sk_rebuild_header,
-	.conn_request	=	dccp_v6_conn_request,
-	.syn_recv_sock	=	dccp_v6_request_recv_sock,
-	.net_header_len	=	sizeof(struct iphdr),
-	.setsockopt	=	ipv6_setsockopt,
-	.getsockopt	=	ipv6_getsockopt,
-	.addr2sockaddr	=	inet6_csk_addr2sockaddr,
-	.sockaddr_len	=	sizeof(struct sockaddr_in6)
+	.queue_xmit	= ip_queue_xmit,
+	.send_check	= dccp_v4_send_check,
+	.rebuild_header	= inet_sk_rebuild_header,
+	.conn_request	= dccp_v6_conn_request,
+	.syn_recv_sock	= dccp_v6_request_recv_sock,
+	.net_header_len	= sizeof(struct iphdr),
+	.setsockopt	= ipv6_setsockopt,
+	.getsockopt	= ipv6_getsockopt,
+	.addr2sockaddr	= inet6_csk_addr2sockaddr,
+	.sockaddr_len	= sizeof(struct sockaddr_in6)
 };
 
 /* NOTE: A lot of things set to zero explicitly by call to
@@ -1168,35 +1170,35 @@ static int dccp_v6_destroy_sock(struct s
 }
 
 static struct proto dccp_v6_prot = {
-	.name			= "DCCPv6",
-	.owner			= THIS_MODULE,
-	.close			= dccp_close,
-	.connect		= dccp_v6_connect,
-	.disconnect		= dccp_disconnect,
-	.ioctl			= dccp_ioctl,
-	.init			= dccp_v6_init_sock,
-	.setsockopt		= dccp_setsockopt,
-	.getsockopt		= dccp_getsockopt,
-	.sendmsg		= dccp_sendmsg,
-	.recvmsg		= dccp_recvmsg,
-	.backlog_rcv		= dccp_v6_do_rcv,
-	.hash			= dccp_v6_hash,
-	.unhash			= dccp_unhash,
-	.accept			= inet_csk_accept,
-	.get_port		= dccp_v6_get_port,
-	.shutdown		= dccp_shutdown,
-	.destroy		= dccp_v6_destroy_sock,
-	.orphan_count		= &dccp_orphan_count,
-	.max_header		= MAX_DCCP_HEADER,
-	.obj_size		= sizeof(struct dccp6_sock),
-	.rsk_prot		= &dccp6_request_sock_ops,
-	.twsk_prot		= &dccp6_timewait_sock_ops,
+	.name		= "DCCPv6",
+	.owner		= THIS_MODULE,
+	.close		= dccp_close,
+	.connect	= dccp_v6_connect,
+	.disconnect	= dccp_disconnect,
+	.ioctl		= dccp_ioctl,
+	.init		= dccp_v6_init_sock,
+	.setsockopt	= dccp_setsockopt,
+	.getsockopt	= dccp_getsockopt,
+	.sendmsg	= dccp_sendmsg,
+	.recvmsg	= dccp_recvmsg,
+	.backlog_rcv	= dccp_v6_do_rcv,
+	.hash		= dccp_v6_hash,
+	.unhash		= dccp_unhash,
+	.accept		= inet_csk_accept,
+	.get_port	= dccp_v6_get_port,
+	.shutdown	= dccp_shutdown,
+	.destroy	= dccp_v6_destroy_sock,
+	.orphan_count	= &dccp_orphan_count,
+	.max_header	= MAX_DCCP_HEADER,
+	.obj_size	= sizeof(struct dccp6_sock),
+	.rsk_prot	= &dccp6_request_sock_ops,
+	.twsk_prot	= &dccp6_timewait_sock_ops,
 };
 
 static struct inet6_protocol dccp_v6_protocol = {
-	.handler	=	dccp_v6_rcv,
-	.err_handler	=	dccp_v6_err,
-	.flags		=	INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
+	.handler	= dccp_v6_rcv,
+	.err_handler	= dccp_v6_err,
+	.flags		= INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
 };
 
 static struct proto_ops inet6_dccp_ops = {
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 3/4] [DCCP] options: Fix some aspects of mandatory option processing
From: Arnaldo Carvalho de Melo @ 2006-02-28 22:09 UTC (permalink / raw)
  To: dccp

According to dccp draft (draft-ietf-dccp-spec-13.txt) section 5.8.2 (Mandatory
Option) the following patch correct the handling of the following cases:

1) "... and any Mandatory options received on DCCP-Data packets MUST be
  ignored."

2) "The connection is in error and should be reset with Reset Code 5, ...
  if option O is absent (Mandatory was the last byte of the option list), or
  if option O equals Mandatory."

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>

---

 net/dccp/options.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

61e2a0fe55ae1e6b2d1f7f10660065de8c606e5c
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 79d228e..8867b6f 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -109,7 +109,8 @@ int dccp_parse_options(struct sock *sk, 
 		case DCCPO_MANDATORY:
 			if (mandatory)
 				goto out_invalid_option;
-			mandatory = 1;
+			if (pkt_type != DCCP_PKT_DATA)
+				mandatory = 1;
 			break;
 		case DCCPO_NDP_COUNT:
 			if (len > 3)
@@ -249,6 +250,10 @@ int dccp_parse_options(struct sock *sk, 
 			mandatory = 0;
 	}
 
+	/* mandatory was the last byte in option list -> reset connection */
+	if (mandatory)
+		goto out_invalid_option;
+
 	return 0;
 
 out_invalid_option:
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 4/4] [DCCP] ccid3: Divide by zero fix
From: Arnaldo Carvalho de Melo @ 2006-02-28 22:09 UTC (permalink / raw)
  To: dccp

In rare circumstances 0 is returned by dccp_li_hist_calc_i_mean which leads to
a divide by zero in ccid3_hc_rx_packet_recv. Explicitly check for zero return
now. Update copyright notice at same time.

Found by Arnaldo.

Signed-off-by: Ian McDonald <imcdnzl@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/ccids/ccid3.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

8135f5c98f27d04094f7931495a917d856192f6a
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 2b82f96..ff426a9 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -2,7 +2,7 @@
  *  net/dccp/ccids/ccid3.c
  *
  *  Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
- *  Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
+ *  Copyright (c) 2005-6 Ian McDonald <imcdnzl@gmail.com>
  *
  *  An implementation of the DCCP protocol
  *
@@ -1014,9 +1014,13 @@ static void ccid3_hc_rx_packet_recv(stru
 	p_prev = hcrx->ccid3hcrx_p;
 	
 	/* Calculate loss event rate */
-	if (!list_empty(&hcrx->ccid3hcrx_li_hist))
+	if (!list_empty(&hcrx->ccid3hcrx_li_hist)) {
+		u32 i_mean = dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
+
 		/* Scaling up by 1000000 as fixed decimal */
-		hcrx->ccid3hcrx_p = 1000000 / dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
+		if (i_mean != 0)
+			hcrx->ccid3hcrx_p = 1000000 / i_mean;
+	}
 
 	if (hcrx->ccid3hcrx_p > p_prev) {
 		ccid3_hc_rx_send_feedback(sk);
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 0/4][DCCP]: Fixes and cleanups
From: Arnaldo Carvalho de Melo @ 2006-02-28 22:09 UTC (permalink / raw)
  To: dccp

Hi David,

   Please consider pulling from:

master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.17.git

Best Regards,

- Arnaldo

 ccids/ccid2.c |   77 +++++------------
 ccids/ccid3.c |   11 +-
 ipv6.c        |  257 +++++++++++++++++++++++++++++-----------------------------
 options.c     |    8 +
 4 files changed, 168 insertions(+), 185 deletions(-)


^ permalink raw reply

* Re: Resend: [PATCH] DCCP: Divide by zero fix
From: Ian McDonald @ 2006-02-28 21:35 UTC (permalink / raw)
  To: dccp
In-Reply-To: <cbec11ac0602281324i6e1ff681m752c06c3b7fa7b97@mail.gmail.com>

On 3/1/06, Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> On 2/28/06, Ian McDonald <imcdnzl@gmail.com> wrote:
> > Arnaldo,
> >
> > Haven't seen this going in so resending...
>
> What a coincidence, I'm testing this patch right now, and I'm afraid it has
> some bug or makes it more likely that some other bug happens, the machine
> soft locks with it enabled and when using CCID3 as the default RX CCID in
> a TTCP test over loopback.
>
> Note that the problem happens more quickly if you test it on a machine with
> less than 64 MB (where the problem happens, but after more time).
>
OK. I am doing some testing on lockups at present from CCID3 which I
suspect are introduced recently.... they don't lock up on older code.
Having said that I'm running without that patch applied so I will
retest soon - but I don't believe it is the problem when I looked at
the scope of that code.

I have a suspicion that if I don't find anything with git-bisect for
CCID3 lockups that it might be when you use CCID3 and set
DCCP_INITIAL_SEND_ACK_VECTOR to 1....

Anyway another 3 or 4 reboots and I should give some more answers.

BTW my problems occur when using a netem box in the middle as per
setup described on DCCP testing on ODSL Wiki.

Ian
--
Ian McDonald
Web: http://wand.net.nz/~iam4
Blog: http://imcdnzl.blogspot.com
WAND Network Research Group
Department of Computer Science
University of Waikato
New Zealand

^ permalink raw reply

* Re: Resend: [PATCH] DCCP: Divide by zero fix
From: Arnaldo Carvalho de Melo @ 2006-02-28 21:28 UTC (permalink / raw)
  To: dccp
In-Reply-To: <cbec11ac0602281324i6e1ff681m752c06c3b7fa7b97@mail.gmail.com>

On 2/28/06, Ian McDonald <imcdnzl@gmail.com> wrote:
> Arnaldo,
>
> Haven't seen this going in so resending...

What a coincidence, I'm testing this patch right now, and I'm afraid it has
some bug or makes it more likely that some other bug happens, the machine
soft locks with it enabled and when using CCID3 as the default RX CCID in
a TTCP test over loopback.

Note that the problem happens more quickly if you test it on a machine with
less than 64 MB (where the problem happens, but after more time).

- Arnaldo

^ permalink raw reply

* Resend: [PATCH] DCCP: Divide by zero fix
From: Ian McDonald @ 2006-02-28 21:24 UTC (permalink / raw)
  To: dccp

Arnaldo,

Haven't seen this going in so resending...

Ian

---------- Forwarded message ----------
From: Ian McDonald <imcdnzl@gmail.com>
Date: Feb 17, 2006 3:17 PM
Subject: [PATCH] DCCP: Divide by zero fix
To: DCCP Mailing List <dccp@vger.kernel.org>, Arnaldo Carvalho de Melo
<acme@mandriva.com>


In rare circumstances 0 is returned by dccp_li_hist_calc_i_mean which
leads to a divide by zero in ccid3_hc_rx_packet_recv. Explicitly check
for zero return now. Update copyright notice at same time.

Found by Arnaldo

Signed-off-by: Ian McDonald <imcdnzl@gmail.com>
----
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 165fc40..fb4db88 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -2,7 +2,7 @@
  *  net/dccp/ccids/ccid3.c
  *
  *  Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
- *  Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
+ *  Copyright (c) 2005-6 Ian McDonald <imcdnzl@gmail.com>
  *
  *  An implementation of the DCCP protocol
  *
@@ -925,7 +925,7 @@ static void ccid3_hc_rx_packet_recv(stru
        struct dccp_rx_hist_entry *packet;
        struct timeval now;
        u8 win_count;
-       u32 p_prev, r_sample, t_elapsed;
+       u32 p_prev, r_sample, t_elapsed, i_mean;
        int ins;

        BUG_ON(hcrx = NULL ||
@@ -1025,9 +1025,11 @@ static void ccid3_hc_rx_packet_recv(stru
        p_prev = hcrx->ccid3hcrx_p;

        /* Calculate loss event rate */
-       if (!list_empty(&hcrx->ccid3hcrx_li_hist))
+       if (!list_empty(&hcrx->ccid3hcrx_li_hist)) {
+               i_mean = dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
+               if (i_mean)
                /* Scaling up by 1000000 as fixed decimal */
-               hcrx->ccid3hcrx_p = 1000000 /
dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
+                       hcrx->ccid3hcrx_p = 1000000 / i_mean;

        if (hcrx->ccid3hcrx_p > p_prev) {
                ccid3_hc_rx_send_feedback(sk);


--
Ian McDonald
Web: http://wand.net.nz/~iam4
Blog: http://imcdnzl.blogspot.com
WAND Network Research Group
Department of Computer Science
University of Waikato
New Zealand

^ permalink raw reply related

* Re: [PATCH] Mandatory Option Draft Cleanup
From: Arnaldo Carvalho de Melo @ 2006-02-28 20:28 UTC (permalink / raw)
  To: dccp
In-Reply-To: <20060222113802.GB21876@c3po.0xdef.net>

On 2/28/06, Hagen Paul Pfeifer <hagen@jauu.net> wrote:
>
> According to dccp draft (draft-ietf-dccp-spec-13.txt) section 5.8.2 (Mandatory
> Option) the following patch correct the handling of the following cases:
>
> 1) "... and any Mandatory options received on DCCP-Data packets MUST be
>    ignored."
>
> 2) "The connection is in error and should be reset with Reset Code 5, ...
>    if option O is absent (Mandatory was the last byte of the option list), or
>    if option O equals Mandatory."
>
>
> Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>

Thanks, I got this one merged already, take a look at:

http://www.kernel.org/git/?p=linux/kernel/git/acme/net-2.6.17.git;a=summary

Will submit to Dave later today.

- Arnaldo

^ permalink raw reply

* [PATCH] Mandatory Option Draft Cleanup
From: Hagen Paul Pfeifer @ 2006-02-28 20:15 UTC (permalink / raw)
  To: dccp
In-Reply-To: <20060222113802.GB21876@c3po.0xdef.net>

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]


According to dccp draft (draft-ietf-dccp-spec-13.txt) section 5.8.2 (Mandatory
Option) the following patch correct the handling of the following cases:

1) "... and any Mandatory options received on DCCP-Data packets MUST be
   ignored."

2) "The connection is in error and should be reset with Reset Code 5, ...
   if option O is absent (Mandatory was the last byte of the option list), or
   if option O equals Mandatory."


Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>



[-- Attachment #2: mandatory.patch --]
[-- Type: text/plain, Size: 635 bytes --]

diff --git a/net/dccp/options.c b/net/dccp/options.c
index 7d73b33..3db9aad 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -107,7 +107,8 @@ int dccp_parse_options(struct sock *sk, 
 		case DCCPO_MANDATORY:
 			if (mandatory)
 				goto out_invalid_option;
-			mandatory = 1;
+			if (pkt_type != DCCP_PKT_DATA)
+				mandatory = 1;
 			break;
 		case DCCPO_NDP_COUNT:
 			if (len > 3)
@@ -247,6 +248,10 @@ int dccp_parse_options(struct sock *sk, 
 			mandatory = 0;
 	}
 
+	/* mandatory was the last byte in option list -> reset connection */
+	if (mandatory)
+		goto out_invalid_option;
+
 	return 0;
 
 out_invalid_option:

^ permalink raw reply related

* Re: [PATCH] [ICSK]: Introduce inet_csk_ctl_sock_create
From: David S. Miller @ 2006-02-26  0:59 UTC (permalink / raw)
  To: dccp
In-Reply-To: <11409064891373-git-send-email-acme@mandriva.com>

From: "Arnaldo Carvalho de Melo" <acme@ghostprotocols.net>
Date: Sat, 25 Feb 2006 19:32:47 -0300

>    Please consider pulling from:
> 
> master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.17.git
> 
>   I should have used git-send-email --compose even with just one cset, ah
> and include netdev too, sorry.
> 
>     Now there are 4 outstanding changesets in this tree.

All looks fine, pulled.

Thanks a lot.

^ permalink raw reply

* Re: [PATCH] [ICSK]: Introduce inet_csk_ctl_sock_create
From: Arnaldo Carvalho de Melo @ 2006-02-25 22:32 UTC (permalink / raw)
  To: dccp
In-Reply-To: <11409064891373-git-send-email-acme@mandriva.com>

Hi David,

   Please consider pulling from:

master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.17.git

  I should have used git-send-email --compose even with just one cset, ah
and include netdev too, sorry.

    Now there are 4 outstanding changesets in this tree.

Regards,

- Arnaldo

On 2/25/06, Arnaldo Carvalho de Melo <acme@mandriva.com> wrote:
> Consolidating open coded sequences in tcp and dccp, v4 and v6.
>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
>
> ---
>
>  include/net/inet_connection_sock.h |    4 ++++
>  net/dccp/ipv4.c                    |   26 ++------------------------
>  net/dccp/ipv6.c                    |   27 +++------------------------
>  net/ipv4/inet_connection_sock.c    |   19 +++++++++++++++++++
>  net/ipv4/tcp_ipv4.c                |   13 +------------
>  net/ipv6/tcp_ipv6.c                |   13 ++-----------
>  6 files changed, 31 insertions(+), 71 deletions(-)
>
> d2c5bf98ebbf4ad6ab670ec0e65494b04e75ab90
> diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
> index c0a4d3c..3895420 100644
> --- a/include/net/inet_connection_sock.h
> +++ b/include/net/inet_connection_sock.h
> @@ -321,4 +321,8 @@ extern void inet_csk_listen_stop(struct
>
>  extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
>
> +extern int inet_csk_ctl_sock_create(struct socket **sock,
> +                                   unsigned short family,
> +                                   unsigned short type,
> +                                   unsigned char protocol);
>  #endif /* _INET_CONNECTION_SOCK_H */
> diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
> index f53bce5..7098f10 100644
> --- a/net/dccp/ipv4.c
> +++ b/net/dccp/ipv4.c
> @@ -1099,29 +1099,6 @@ static struct inet_protosw dccp_v4_proto
>         .flags          = INET_PROTOSW_ICSK,
>  };
>
> -static char dccp_v4_ctl_socket_err_msg[] __initdata > -       KERN_ERR "DCCP: Failed to create the control socket.\n";
> -
> -static int __init dccp_v4_ctl_sock_init(void)
> -{
> -       int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP,
> -                                 &dccp_v4_ctl_socket);
> -       if (rc < 0)
> -               printk(dccp_v4_ctl_socket_err_msg);
> -       else {
> -               dccp_v4_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
> -               inet_sk(dccp_v4_ctl_socket->sk)->uc_ttl = -1;
> -
> -               /* Unhash it so that IP input processing does not even
> -                * see it, we do not wish this socket to see incoming
> -                * packets.
> -                */
> -               dccp_v4_ctl_socket->sk->sk_prot->unhash(dccp_v4_ctl_socket->sk);
> -       }
> -
> -       return rc;
> -}
> -
>  static int __init dccp_v4_init(void)
>  {
>         int err = proto_register(&dccp_v4_prot, 1);
> @@ -1135,7 +1112,8 @@ static int __init dccp_v4_init(void)
>
>         inet_register_protosw(&dccp_v4_protosw);
>
> -       err = dccp_v4_ctl_sock_init();
> +       err = inet_csk_ctl_sock_create(&dccp_v4_ctl_socket, PF_INET,
> +                                      SOCK_DCCP, IPPROTO_DCCP);
>         if (err)
>                 goto out_unregister_protosw;
>  out:
> diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
> index 3c9f083..6bd9979 100644
> --- a/net/dccp/ipv6.c
> +++ b/net/dccp/ipv6.c
> @@ -1229,29 +1229,6 @@ static struct inet_protosw dccp_v6_proto
>         .flags          = INET_PROTOSW_ICSK,
>  };
>
> -static char dccp_v6_ctl_socket_err_msg[] __initdata > -       KERN_ERR "DCCP: Failed to create the control socket.\n";
> -
> -static int __init dccp_v6_ctl_sock_init(void)
> -{
> -       int rc = sock_create_kern(PF_INET6, SOCK_DCCP, IPPROTO_DCCP,
> -                                 &dccp_v6_ctl_socket);
> -       if (rc < 0)
> -               printk(dccp_v6_ctl_socket_err_msg);
> -       else {
> -               dccp_v6_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
> -               inet_sk(dccp_v6_ctl_socket->sk)->uc_ttl = -1;
> -
> -               /* Unhash it so that IP input processing does not even
> -                * see it, we do not wish this socket to see incoming
> -                * packets.
> -                */
> -               dccp_v6_ctl_socket->sk->sk_prot->unhash(dccp_v6_ctl_socket->sk);
> -       }
> -
> -       return rc;
> -}
> -
>  static int __init dccp_v6_init(void)
>  {
>         int err = proto_register(&dccp_v6_prot, 1);
> @@ -1265,7 +1242,9 @@ static int __init dccp_v6_init(void)
>
>         inet6_register_protosw(&dccp_v6_protosw);
>
> -       if (dccp_v6_ctl_sock_init() != 0)
> +       err = inet_csk_ctl_sock_create(&dccp_v6_ctl_socket, PF_INET6,
> +                                      SOCK_DCCP, IPPROTO_DCCP);
> +       if (err != 0)
>                 goto out_unregister_protosw;
>  out:
>         return err;
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index ae20281..359f48c 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
> @@ -648,3 +648,22 @@ void inet_csk_addr2sockaddr(struct sock
>  }
>
>  EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr);
> +
> +int inet_csk_ctl_sock_create(struct socket **sock, unsigned short family,
> +                            unsigned short type, unsigned char protocol)
> +{
> +       int rc = sock_create_kern(family, type, protocol, sock);
> +
> +       if (rc = 0) {
> +               (*sock)->sk->sk_allocation = GFP_ATOMIC;
> +               inet_sk((*sock)->sk)->uc_ttl = -1;
> +               /*
> +                * Unhash it so that IP input processing does not even see it,
> +                * we do not wish this socket to see incoming packets.
> +                */
> +               (*sock)->sk->sk_prot->unhash((*sock)->sk);
> +       }
> +       return rc;
> +}
> +
> +EXPORT_SYMBOL_GPL(inet_csk_ctl_sock_create);
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index 57e7a26..4eb903d 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -1828,21 +1828,10 @@ struct proto tcp_prot = {
>         .rsk_prot               = &tcp_request_sock_ops,
>  };
>
> -
> -
>  void __init tcp_v4_init(struct net_proto_family *ops)
>  {
> -       int err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_TCP, &tcp_socket);
> -       if (err < 0)
> +       if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, IPPROTO_TCP) < 0)
>                 panic("Failed to create the TCP control socket.\n");
> -       tcp_socket->sk->sk_allocation   = GFP_ATOMIC;
> -       inet_sk(tcp_socket->sk)->uc_ttl = -1;
> -
> -       /* Unhash it so that IP input processing does not even
> -        * see it, we do not wish this socket to see incoming
> -        * packets.
> -        */
> -       tcp_socket->sk->sk_prot->unhash(tcp_socket->sk);
>  }
>
>  EXPORT_SYMBOL(ipv4_specific);
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 14de503..af6a0c6 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -1605,21 +1605,12 @@ static struct inet_protosw tcpv6_protosw
>
>  void __init tcpv6_init(void)
>  {
> -       int err;
> -
>         /* register inet6 protocol */
>         if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0)
>                 printk(KERN_ERR "tcpv6_init: Could not register protocol\n");
>         inet6_register_protosw(&tcpv6_protosw);
>
> -       err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_TCP, &tcp6_socket);
> -       if (err < 0)
> +       if (inet_csk_ctl_sock_create(&tcp6_socket, PF_INET6, SOCK_RAW,
> +                                    IPPROTO_TCP) < 0)
>                 panic("Failed to create the TCPv6 control socket.\n");
> -       tcp6_socket->sk->sk_allocation = GFP_ATOMIC;
> -
> -       /* Unhash it so that IP input processing does not even
> -        * see it, we do not wish this socket to see incoming
> -        * packets.
> -        */
> -       tcp6_socket->sk->sk_prot->unhash(tcp6_socket->sk);
>  }
> --
> 1.2.2.gd27d

^ permalink raw reply

* [PATCH] [ICSK]: Introduce inet_csk_ctl_sock_create
From: Arnaldo Carvalho de Melo @ 2006-02-25 22:28 UTC (permalink / raw)
  To: dccp

Consolidating open coded sequences in tcp and dccp, v4 and v6.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 include/net/inet_connection_sock.h |    4 ++++
 net/dccp/ipv4.c                    |   26 ++------------------------
 net/dccp/ipv6.c                    |   27 +++------------------------
 net/ipv4/inet_connection_sock.c    |   19 +++++++++++++++++++
 net/ipv4/tcp_ipv4.c                |   13 +------------
 net/ipv6/tcp_ipv6.c                |   13 ++-----------
 6 files changed, 31 insertions(+), 71 deletions(-)

d2c5bf98ebbf4ad6ab670ec0e65494b04e75ab90
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index c0a4d3c..3895420 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -321,4 +321,8 @@ extern void inet_csk_listen_stop(struct 
 
 extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
 
+extern int inet_csk_ctl_sock_create(struct socket **sock,
+				    unsigned short family,
+				    unsigned short type,
+				    unsigned char protocol);
 #endif /* _INET_CONNECTION_SOCK_H */
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index f53bce5..7098f10 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -1099,29 +1099,6 @@ static struct inet_protosw dccp_v4_proto
 	.flags		= INET_PROTOSW_ICSK,
 };
 
-static char dccp_v4_ctl_socket_err_msg[] __initdata -	KERN_ERR "DCCP: Failed to create the control socket.\n";
-
-static int __init dccp_v4_ctl_sock_init(void)
-{
-	int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP,
-				  &dccp_v4_ctl_socket);
-	if (rc < 0)
-		printk(dccp_v4_ctl_socket_err_msg);
-	else {
-		dccp_v4_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
-		inet_sk(dccp_v4_ctl_socket->sk)->uc_ttl = -1;
-
-		/* Unhash it so that IP input processing does not even
-		 * see it, we do not wish this socket to see incoming
-		 * packets.
-		 */
-		dccp_v4_ctl_socket->sk->sk_prot->unhash(dccp_v4_ctl_socket->sk);
-	}
-
-	return rc;
-}
-
 static int __init dccp_v4_init(void)
 {
 	int err = proto_register(&dccp_v4_prot, 1);
@@ -1135,7 +1112,8 @@ static int __init dccp_v4_init(void)
 
 	inet_register_protosw(&dccp_v4_protosw);
 
-	err = dccp_v4_ctl_sock_init();
+	err = inet_csk_ctl_sock_create(&dccp_v4_ctl_socket, PF_INET,
+				       SOCK_DCCP, IPPROTO_DCCP);
 	if (err)
 		goto out_unregister_protosw;
 out:
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 3c9f083..6bd9979 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1229,29 +1229,6 @@ static struct inet_protosw dccp_v6_proto
 	.flags		= INET_PROTOSW_ICSK,
 };
 
-static char dccp_v6_ctl_socket_err_msg[] __initdata -	KERN_ERR "DCCP: Failed to create the control socket.\n";
-
-static int __init dccp_v6_ctl_sock_init(void)
-{
-	int rc = sock_create_kern(PF_INET6, SOCK_DCCP, IPPROTO_DCCP,
-				  &dccp_v6_ctl_socket);
-	if (rc < 0)
-		printk(dccp_v6_ctl_socket_err_msg);
-	else {
-		dccp_v6_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
-		inet_sk(dccp_v6_ctl_socket->sk)->uc_ttl = -1;
-
-		/* Unhash it so that IP input processing does not even
-		 * see it, we do not wish this socket to see incoming
-		 * packets.
-		 */
-		dccp_v6_ctl_socket->sk->sk_prot->unhash(dccp_v6_ctl_socket->sk);
-	}
-
-	return rc;
-}
-
 static int __init dccp_v6_init(void)
 {
 	int err = proto_register(&dccp_v6_prot, 1);
@@ -1265,7 +1242,9 @@ static int __init dccp_v6_init(void)
 
 	inet6_register_protosw(&dccp_v6_protosw);
 
-	if (dccp_v6_ctl_sock_init() != 0)
+	err = inet_csk_ctl_sock_create(&dccp_v6_ctl_socket, PF_INET6,
+				       SOCK_DCCP, IPPROTO_DCCP);
+	if (err != 0)
 		goto out_unregister_protosw;
 out:
 	return err;
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index ae20281..359f48c 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -648,3 +648,22 @@ void inet_csk_addr2sockaddr(struct sock 
 }
 
 EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr);
+
+int inet_csk_ctl_sock_create(struct socket **sock, unsigned short family,
+			     unsigned short type, unsigned char protocol)
+{
+	int rc = sock_create_kern(family, type, protocol, sock);
+
+	if (rc = 0) {
+		(*sock)->sk->sk_allocation = GFP_ATOMIC;
+		inet_sk((*sock)->sk)->uc_ttl = -1;
+		/*
+		 * Unhash it so that IP input processing does not even see it,
+		 * we do not wish this socket to see incoming packets.
+		 */
+		(*sock)->sk->sk_prot->unhash((*sock)->sk);
+	}
+	return rc;
+}
+
+EXPORT_SYMBOL_GPL(inet_csk_ctl_sock_create);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 57e7a26..4eb903d 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1828,21 +1828,10 @@ struct proto tcp_prot = {
 	.rsk_prot		= &tcp_request_sock_ops,
 };
 
-
-
 void __init tcp_v4_init(struct net_proto_family *ops)
 {
-	int err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_TCP, &tcp_socket);
-	if (err < 0)
+	if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, IPPROTO_TCP) < 0)
 		panic("Failed to create the TCP control socket.\n");
-	tcp_socket->sk->sk_allocation   = GFP_ATOMIC;
-	inet_sk(tcp_socket->sk)->uc_ttl = -1;
-
-	/* Unhash it so that IP input processing does not even
-	 * see it, we do not wish this socket to see incoming
-	 * packets.
-	 */
-	tcp_socket->sk->sk_prot->unhash(tcp_socket->sk);
 }
 
 EXPORT_SYMBOL(ipv4_specific);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 14de503..af6a0c6 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1605,21 +1605,12 @@ static struct inet_protosw tcpv6_protosw
 
 void __init tcpv6_init(void)
 {
-	int err;
-
 	/* register inet6 protocol */
 	if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0)
 		printk(KERN_ERR "tcpv6_init: Could not register protocol\n");
 	inet6_register_protosw(&tcpv6_protosw);
 
-	err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_TCP, &tcp6_socket);
-	if (err < 0)
+	if (inet_csk_ctl_sock_create(&tcp6_socket, PF_INET6, SOCK_RAW,
+				     IPPROTO_TCP) < 0)
 		panic("Failed to create the TCPv6 control socket.\n");
-	tcp6_socket->sk->sk_allocation = GFP_ATOMIC;
-
-	/* Unhash it so that IP input processing does not even
-	 * see it, we do not wish this socket to see incoming
-	 * packets.
-	 */
-	tcp6_socket->sk->sk_prot->unhash(tcp6_socket->sk);
 }
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 1/3] [DCCP] ipv4: make struct dccp_v4_prot static
From: Arnaldo Carvalho de Melo @ 2006-02-25 21:16 UTC (permalink / raw)
  To: dccp

There's no reason for struct dccp_v4_prot being global.

Signed-off-by: Adrian Bunk <bunk@stusta.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/ipv4.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

16106bb9b047c6a60190f11a674d804bdf1f8320
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 033c3ab..3fe958e 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -1022,7 +1022,7 @@ static struct timewait_sock_ops dccp_tim
 	.twsk_obj_size	= sizeof(struct inet_timewait_sock),
 };
 
-struct proto dccp_v4_prot = {
+static struct proto dccp_v4_prot = {
 	.name			= "DCCP",
 	.owner			= THIS_MODULE,
 	.close			= dccp_close,
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 3/3] [DCCP] ipv6: Add missing ipv6 control socket
From: Arnaldo Carvalho de Melo @ 2006-02-25 21:16 UTC (permalink / raw)
  To: dccp

I guess I forgot to add it, nah, now it just works:

18:04:33.274066 IP6 ::1.1476 > ::1.5001: request (service=0)
18:04:33.334482 IP6 ::1.5001 > ::1.1476: reset (codeºd_service_code)

Ditched IP_DCCP_UNLOAD_HACK, as now we would have to do it for both IPv6 and
IPv4, so I'll come up with another way for freeing the control sockets in
upcoming changesets.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/Kconfig       |    9 -------
 net/dccp/ccids/ccid3.c |    9 -------
 net/dccp/dccp.h        |    4 +--
 net/dccp/ipv4.c        |   65 +++++++++++++++++++++---------------------------
 net/dccp/ipv6.c        |   44 ++++++++++++++++++++++++++++++--
 net/dccp/proto.c       |    6 +---
 6 files changed, 72 insertions(+), 65 deletions(-)

3e8d786e99c8e5abd88177763e7121341bb05d05
diff --git a/net/dccp/Kconfig b/net/dccp/Kconfig
index 24a6981..7e096ba 100644
--- a/net/dccp/Kconfig
+++ b/net/dccp/Kconfig
@@ -40,15 +40,6 @@ config IP_DCCP_DEBUG
 
 	  Just say N.
 
-config IP_DCCP_UNLOAD_HACK
-	depends on IP_DCCP=m && IP_DCCP_CCID3=m
-	bool "DCCP control sock unload hack"
-	---help---
-	  Enable this to be able to unload the dccp module when the it
-	  has only one refcount held, the control sock one. Just execute
-	  "rmmod dccp_ccid3 dccp"
-
-	  Just say N.
 endmenu
 
 endmenu
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 47660ca..2b82f96 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -1207,15 +1207,6 @@ module_init(ccid3_module_init);
 
 static __exit void ccid3_module_exit(void)
 {
-#ifdef CONFIG_IP_DCCP_UNLOAD_HACK
-	/*
-	 * Hack to use while developing, so that we get rid of the control
-	 * sock, that is what keeps a refcount on dccp.ko -acme
-	 */
-	extern void dccp_ctl_sock_exit(void);
-
-	dccp_ctl_sock_exit();
-#endif
 	ccid_unregister(&ccid3);
 
 	if (ccid3_tx_hist != NULL) {
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 6fcc9d4..d57d213 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -177,7 +177,7 @@ extern int dccp_rcv_state_process(struct
 extern int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
 				const struct dccp_hdr *dh, const unsigned len);
 
-extern int dccp_init_sock(struct sock *sk);
+extern int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized);
 extern int dccp_destroy_sock(struct sock *sk);
 
 extern void		dccp_close(struct sock *sk, long timeout);
@@ -337,8 +337,6 @@ extern void dccp_insert_option(struct so
 			       unsigned char option,
 			       const void *value, unsigned char len);
 
-extern struct socket *dccp_ctl_socket;
-
 extern void dccp_timestamp(const struct sock *sk, struct timeval *tv);
 
 static inline suseconds_t timeval_usecs(const struct timeval *tv)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 3fe958e..f53bce5 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -32,6 +32,13 @@
 #include "dccp.h"
 #include "feat.h"
 
+/*
+ * This is the global socket data structure used for responding to
+ * the Out-of-the-blue (OOTB) packets. A control sock will be created
+ * for this socket at the initialization time.
+ */
+static struct socket *dccp_v4_ctl_socket;
+
 static int dccp_v4_get_port(struct sock *sk, const unsigned short snum)
 {
 	return inet_csk_get_port(&dccp_hashinfo, sk, snum,
@@ -226,11 +233,11 @@ static void dccp_v4_ctl_send_ack(struct 
 	dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
 			 DCCP_SKB_CB(rxskb)->dccpd_seq);
 
-	bh_lock_sock(dccp_ctl_socket->sk);
-	err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
+	bh_lock_sock(dccp_v4_ctl_socket->sk);
+	err = ip_build_and_send_pkt(skb, dccp_v4_ctl_socket->sk,
 				    rxskb->nh.iph->daddr,
 				    rxskb->nh.iph->saddr, NULL);
-	bh_unlock_sock(dccp_ctl_socket->sk);
+	bh_unlock_sock(dccp_v4_ctl_socket->sk);
 
 	if (err = NET_XMIT_CN || err = 0) {
 		DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
@@ -704,7 +711,7 @@ static void dccp_v4_ctl_send_reset(struc
 	if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
 		return;
 
-	dst = dccp_v4_route_skb(dccp_ctl_socket->sk, rxskb);
+	dst = dccp_v4_route_skb(dccp_v4_ctl_socket->sk, rxskb);
 	if (dst = NULL)
 		return;
 
@@ -741,11 +748,11 @@ static void dccp_v4_ctl_send_reset(struc
 	dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr,
 					      rxskb->nh.iph->daddr);
 
-	bh_lock_sock(dccp_ctl_socket->sk);
-	err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
+	bh_lock_sock(dccp_v4_ctl_socket->sk);
+	err = ip_build_and_send_pkt(skb, dccp_v4_ctl_socket->sk,
 				    rxskb->nh.iph->daddr,
 				    rxskb->nh.iph->saddr, NULL);
-	bh_unlock_sock(dccp_ctl_socket->sk);
+	bh_unlock_sock(dccp_v4_ctl_socket->sk);
 
 	if (err = NET_XMIT_CN || err = 0) {
 		DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
@@ -997,10 +1004,15 @@ static struct inet_connection_sock_af_op
 
 static int dccp_v4_init_sock(struct sock *sk)
 {
-	const int err = dccp_init_sock(sk);
+	static __u8 dccp_v4_ctl_sock_initialized;
+	int err = dccp_init_sock(sk, dccp_v4_ctl_sock_initialized);
 
-	if (err = 0)
+	if (err = 0) {
+		if (unlikely(!dccp_v4_ctl_sock_initialized))
+			dccp_v4_ctl_sock_initialized = 1;
 		inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops;
+	}
+
 	return err;
 }
 
@@ -1087,48 +1099,29 @@ static struct inet_protosw dccp_v4_proto
 	.flags		= INET_PROTOSW_ICSK,
 };
 
-/*
- * This is the global socket data structure used for responding to
- * the Out-of-the-blue (OOTB) packets. A control sock will be created
- * for this socket at the initialization time.
- */
-struct socket *dccp_ctl_socket;
-
-static char dccp_ctl_socket_err_msg[] __initdata +static char dccp_v4_ctl_socket_err_msg[] __initdata  	KERN_ERR "DCCP: Failed to create the control socket.\n";
 
-static int __init dccp_ctl_sock_init(void)
+static int __init dccp_v4_ctl_sock_init(void)
 {
 	int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP,
-				  &dccp_ctl_socket);
+				  &dccp_v4_ctl_socket);
 	if (rc < 0)
-		printk(dccp_ctl_socket_err_msg);
+		printk(dccp_v4_ctl_socket_err_msg);
 	else {
-		dccp_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
-		inet_sk(dccp_ctl_socket->sk)->uc_ttl = -1;
+		dccp_v4_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
+		inet_sk(dccp_v4_ctl_socket->sk)->uc_ttl = -1;
 
 		/* Unhash it so that IP input processing does not even
 		 * see it, we do not wish this socket to see incoming
 		 * packets.
 		 */
-		dccp_ctl_socket->sk->sk_prot->unhash(dccp_ctl_socket->sk);
+		dccp_v4_ctl_socket->sk->sk_prot->unhash(dccp_v4_ctl_socket->sk);
 	}
 
 	return rc;
 }
 
-#ifdef CONFIG_IP_DCCP_UNLOAD_HACK
-void dccp_ctl_sock_exit(void)
-{
-	if (dccp_ctl_socket != NULL) {
-		sock_release(dccp_ctl_socket);
-		dccp_ctl_socket = NULL;
-	}
-}
-
-EXPORT_SYMBOL_GPL(dccp_ctl_sock_exit);
-#endif
-
 static int __init dccp_v4_init(void)
 {
 	int err = proto_register(&dccp_v4_prot, 1);
@@ -1142,7 +1135,7 @@ static int __init dccp_v4_init(void)
 
 	inet_register_protosw(&dccp_v4_protosw);
 
-	err = dccp_ctl_sock_init();
+	err = dccp_v4_ctl_sock_init();
 	if (err)
 		goto out_unregister_protosw;
 out:
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 904967b..3c9f083 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -33,6 +33,9 @@
 #include "dccp.h"
 #include "ipv6.h"
 
+/* Socket used for sending RSTs and ACKs */
+static struct socket *dccp_v6_ctl_socket;
+
 static void dccp_v6_ctl_send_reset(struct sk_buff *skb);
 static void dccp_v6_reqsk_send_ack(struct sk_buff *skb,
 				   struct request_sock *req);
@@ -568,7 +571,7 @@ static void dccp_v6_ctl_send_reset(struc
 	/* sk = NULL, but it is safe for now. RST socket required. */
 	if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) {
 		if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) {
-			ip6_xmit(NULL, skb, &fl, NULL, 0);
+			ip6_xmit(dccp_v6_ctl_socket->sk, skb, &fl, NULL, 0);
 			DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
 			DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
 			return;
@@ -623,7 +626,7 @@ static void dccp_v6_ctl_send_ack(struct 
 
 	if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) {
 		if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) {
-			ip6_xmit(NULL, skb, &fl, NULL, 0);
+			ip6_xmit(dccp_v6_ctl_socket->sk, skb, &fl, NULL, 0);
 			DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
 			return;
 		}
@@ -1146,10 +1149,14 @@ static struct inet_connection_sock_af_op
  */
 static int dccp_v6_init_sock(struct sock *sk)
 {
-	int err = dccp_init_sock(sk);
+	static __u8 dccp_v6_ctl_sock_initialized;
+	int err = dccp_init_sock(sk, dccp_v6_ctl_sock_initialized);
 
-	if (err = 0)
+	if (err = 0) {
+		if (unlikely(!dccp_v6_ctl_sock_initialized))
+			dccp_v6_ctl_sock_initialized = 1;
 		inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
+	}
 
 	return err;
 }
@@ -1222,6 +1229,29 @@ static struct inet_protosw dccp_v6_proto
 	.flags		= INET_PROTOSW_ICSK,
 };
 
+static char dccp_v6_ctl_socket_err_msg[] __initdata +	KERN_ERR "DCCP: Failed to create the control socket.\n";
+
+static int __init dccp_v6_ctl_sock_init(void)
+{
+	int rc = sock_create_kern(PF_INET6, SOCK_DCCP, IPPROTO_DCCP,
+				  &dccp_v6_ctl_socket);
+	if (rc < 0)
+		printk(dccp_v6_ctl_socket_err_msg);
+	else {
+		dccp_v6_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
+		inet_sk(dccp_v6_ctl_socket->sk)->uc_ttl = -1;
+
+		/* Unhash it so that IP input processing does not even
+		 * see it, we do not wish this socket to see incoming
+		 * packets.
+		 */
+		dccp_v6_ctl_socket->sk->sk_prot->unhash(dccp_v6_ctl_socket->sk);
+	}
+
+	return rc;
+}
+
 static int __init dccp_v6_init(void)
 {
 	int err = proto_register(&dccp_v6_prot, 1);
@@ -1234,8 +1264,14 @@ static int __init dccp_v6_init(void)
 		goto out_unregister_proto;
 
 	inet6_register_protosw(&dccp_v6_protosw);
+
+	if (dccp_v6_ctl_sock_init() != 0)
+		goto out_unregister_protosw;
 out:
 	return err;
+out_unregister_protosw:
+	inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
+	inet6_unregister_protosw(&dccp_v6_protosw);
 out_unregister_proto:
 	proto_unregister(&dccp_v6_prot);
 	goto out;
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index c735433..9e97ce6 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -163,11 +163,10 @@ void dccp_unhash(struct sock *sk)
 
 EXPORT_SYMBOL_GPL(dccp_unhash);
 
-int dccp_init_sock(struct sock *sk)
+int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
 	struct inet_connection_sock *icsk = inet_csk(sk);
-	static int dccp_ctl_socket_init = 1;
 
 	dccp_options_init(&dp->dccps_options);
 	do_gettimeofday(&dp->dccps_epoch);
@@ -179,7 +178,7 @@ int dccp_init_sock(struct sock *sk)
 	 * lets leave it here, later the real solution is to do this in a
 	 * setsockopt(CCIDs-I-want/accept). -acme
 	 */
-	if (likely(!dccp_ctl_socket_init)) {
+	if (likely(ctl_sock_initialized)) {
 		int rc = dccp_feat_init(sk);
 
 		if (rc)
@@ -211,7 +210,6 @@ int dccp_init_sock(struct sock *sk)
 		/* control socket doesn't need feat nego */
 		INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending);
 		INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf);
-		dccp_ctl_socket_init = 0;
 	}	
 
 	dccp_init_xmit_timers(sk);
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 2/3] [DCCP]: Uninline some functions
From: Arnaldo Carvalho de Melo @ 2006-02-25 21:16 UTC (permalink / raw)
  To: dccp

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/ccids/ccid3.c |   10 +++++----
 net/dccp/dccp.h        |   49 ++-------------------------------------------
 net/dccp/input.c       |    7 +++---
 net/dccp/output.c      |    2 +-
 net/dccp/proto.c       |   52 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 57 deletions(-)

c0658f19b2570dfe73979c22dd9030f89b6c2dfd
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index c0d2ef7..47660ca 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -46,7 +46,7 @@
  * Reason for maths here is to avoid 32 bit overflow when a is big.
  * With this we get close to the limit.
  */
-static inline u32 usecs_div(const u32 a, const u32 b)
+static u32 usecs_div(const u32 a, const u32 b)
 {
 	const u32 div = a < (UINT_MAX / (USEC_PER_SEC /    10)) ?    10 :
 			a < (UINT_MAX / (USEC_PER_SEC /    50)) ?    50 :
@@ -98,8 +98,8 @@ static const char *ccid3_tx_state_name(e
 }
 #endif
 
-static inline void ccid3_hc_tx_set_state(struct sock *sk,
-					 enum ccid3_hc_tx_states state)
+static void ccid3_hc_tx_set_state(struct sock *sk,
+				  enum ccid3_hc_tx_states state)
 {
 	struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
 	enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state;
@@ -708,8 +708,8 @@ static const char *ccid3_rx_state_name(e
 }
 #endif
 
-static inline void ccid3_hc_rx_set_state(struct sock *sk,
-					 enum ccid3_hc_rx_states state)
+static void ccid3_hc_rx_set_state(struct sock *sk,
+				  enum ccid3_hc_rx_states state)
 {
 	struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
 	enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state;
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 46aa481..6fcc9d4 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -138,53 +138,8 @@ extern unsigned int dccp_sync_mss(struct
 extern const char *dccp_packet_name(const int type);
 extern const char *dccp_state_name(const int state);
 
-static inline void dccp_set_state(struct sock *sk, const int state)
-{
-	const int oldstate = sk->sk_state;
-
-	dccp_pr_debug("%s(%p) %-10.10s -> %s\n",
-		      dccp_role(sk), sk,
-		      dccp_state_name(oldstate), dccp_state_name(state));
-	WARN_ON(state = oldstate);
-
-	switch (state) {
-	case DCCP_OPEN:
-		if (oldstate != DCCP_OPEN)
-			DCCP_INC_STATS(DCCP_MIB_CURRESTAB);
-		break;
-
-	case DCCP_CLOSED:
-		if (oldstate = DCCP_CLOSING || oldstate = DCCP_OPEN)
-			DCCP_INC_STATS(DCCP_MIB_ESTABRESETS);
-
-		sk->sk_prot->unhash(sk);
-		if (inet_csk(sk)->icsk_bind_hash != NULL &&
-		    !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
-			inet_put_port(&dccp_hashinfo, sk);
-		/* fall through */
-	default:
-		if (oldstate = DCCP_OPEN)
-			DCCP_DEC_STATS(DCCP_MIB_CURRESTAB);
-	}
-
-	/* Change state AFTER socket is unhashed to avoid closed
-	 * socket sitting in hash tables.
-	 */
-	sk->sk_state = state;
-}
-
-static inline void dccp_done(struct sock *sk)
-{
-	dccp_set_state(sk, DCCP_CLOSED);
-	dccp_clear_xmit_timers(sk);
-
-	sk->sk_shutdown = SHUTDOWN_MASK;
-
-	if (!sock_flag(sk, SOCK_DEAD))
-		sk->sk_state_change(sk);
-	else
-		inet_csk_destroy_sock(sk);
-}
+extern void dccp_set_state(struct sock *sk, const int state);
+extern void dccp_done(struct sock *sk);
 
 static inline void dccp_openreq_init(struct request_sock *req,
 				     struct dccp_sock *dp,
diff --git a/net/dccp/input.c b/net/dccp/input.c
index eac5178..f53e3fc 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -56,7 +56,7 @@ static void dccp_rcv_closereq(struct soc
 	dccp_send_close(sk, 0);
 }
 
-static inline void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb)
+static void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
 
@@ -151,9 +151,8 @@ static int dccp_check_seqno(struct sock 
 	return 0;
 }
 
-static inline int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
-					 const struct dccp_hdr *dh,
-					 const unsigned len)
+static int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
+				  const struct dccp_hdr *dh, const unsigned len)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
 
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 8c83aa5..6f3a5f0 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -27,7 +27,7 @@ static inline void dccp_event_ack_sent(s
 	inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
 }
 
-static inline void dccp_skb_entail(struct sock *sk, struct sk_buff *skb)
+static void dccp_skb_entail(struct sock *sk, struct sk_buff *skb)
 {
 	skb_set_owner_w(skb, sk);
 	WARN_ON(sk->sk_send_head);
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index d110cdb..c735433 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -53,6 +53,58 @@ struct inet_hashinfo __cacheline_aligned
 
 EXPORT_SYMBOL_GPL(dccp_hashinfo);
 
+void dccp_set_state(struct sock *sk, const int state)
+{
+	const int oldstate = sk->sk_state;
+
+	dccp_pr_debug("%s(%p) %-10.10s -> %s\n",
+		      dccp_role(sk), sk,
+		      dccp_state_name(oldstate), dccp_state_name(state));
+	WARN_ON(state = oldstate);
+
+	switch (state) {
+	case DCCP_OPEN:
+		if (oldstate != DCCP_OPEN)
+			DCCP_INC_STATS(DCCP_MIB_CURRESTAB);
+		break;
+
+	case DCCP_CLOSED:
+		if (oldstate = DCCP_CLOSING || oldstate = DCCP_OPEN)
+			DCCP_INC_STATS(DCCP_MIB_ESTABRESETS);
+
+		sk->sk_prot->unhash(sk);
+		if (inet_csk(sk)->icsk_bind_hash != NULL &&
+		    !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
+			inet_put_port(&dccp_hashinfo, sk);
+		/* fall through */
+	default:
+		if (oldstate = DCCP_OPEN)
+			DCCP_DEC_STATS(DCCP_MIB_CURRESTAB);
+	}
+
+	/* Change state AFTER socket is unhashed to avoid closed
+	 * socket sitting in hash tables.
+	 */
+	sk->sk_state = state;
+}
+
+EXPORT_SYMBOL_GPL(dccp_set_state);
+
+void dccp_done(struct sock *sk)
+{
+	dccp_set_state(sk, DCCP_CLOSED);
+	dccp_clear_xmit_timers(sk);
+
+	sk->sk_shutdown = SHUTDOWN_MASK;
+
+	if (!sock_flag(sk, SOCK_DEAD))
+		sk->sk_state_change(sk);
+	else
+		inet_csk_destroy_sock(sk);
+}
+
+EXPORT_SYMBOL_GPL(dccp_done);
+
 const char *dccp_packet_name(const int type)
 {
 	static const char *dccp_packet_names[] = {
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 0/3][DCCP]: Fixes
From: Arnaldo Carvalho de Melo @ 2006-02-25 21:16 UTC (permalink / raw)
  To: dccp

Hi David,

   Please consider pulling from:

master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.17.git

Best Regards,

- Arnaldo

 b/net/dccp/Kconfig       |    9 ------
 b/net/dccp/ccids/ccid3.c |   10 +++----
 b/net/dccp/dccp.h        |   49 +----------------------------------
 b/net/dccp/input.c       |    7 ++---
 b/net/dccp/ipv4.c        |    3 --
 b/net/dccp/ipv6.c        |   44 ++++++++++++++++++++++++++++---
 b/net/dccp/output.c      |    2 -
 b/net/dccp/proto.c       |   53 +++++++++++++++++++++++++++++++++++++-
 net/dccp/ccids/ccid3.c   |    9 ------
 net/dccp/dccp.h          |    4 --
 net/dccp/ipv4.c          |   65 ++++++++++++++++++++---------------------------
 net/dccp/proto.c         |    7 +----
 12 files changed, 136 insertions(+), 126 deletions(-)


^ permalink raw reply

* Re: [PATCH 0/7][DCCP]: Improvements
From: Arnaldo Carvalho de Melo @ 2006-02-24  0:35 UTC (permalink / raw)
  To: dccp
In-Reply-To: <11407327772616-git-send-email-acme@mandriva.com>

On 2/23/06, David S. Miller <davem@davemloft.net> wrote:
> From: Arnaldo Carvalho de Melo <acme@mandriva.com>
> Date: Thu, 23 Feb 2006 19:12:57 -0300
>
> >    Please consider pulling from:
> >
> > master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.17.git
>
> Pulled, nice work.
>
> Thanks a lot Arnaldo. I kind of like my legacy ipv4, dude :-)

Hey, I have to bow to Yoshifuji-san every once in a while 8) IPv4 is nice
too, postponing retirement like I'll probably do too, hope to be as effective
as v4 8)

- Arnaldo

^ permalink raw reply

* Re: [PATCH 0/7][DCCP]: Improvements
From: David S. Miller @ 2006-02-24  0:30 UTC (permalink / raw)
  To: dccp
In-Reply-To: <11407327772616-git-send-email-acme@mandriva.com>

From: Arnaldo Carvalho de Melo <acme@mandriva.com>
Date: Thu, 23 Feb 2006 19:12:57 -0300

>    Please consider pulling from:
> 
> master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.17.git

Pulled, nice work.

Thanks a lot Arnaldo. I kind of like my legacy ipv4, dude :-)

^ permalink raw reply

* [PATCH 2/7] [DCCP]: Move dccp_v4_{init,destroy}_sock to the core
From: Arnaldo Carvalho de Melo @ 2006-02-23 22:12 UTC (permalink / raw)
  To: dccp

Removing one more ipv6 uses ipv4 stuff case in dccp land.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/dccp.h  |    4 +-
 net/dccp/ipv4.c  |  106 +++---------------------------------------------------
 net/dccp/ipv6.c  |    4 +-
 net/dccp/proto.c |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 112 insertions(+), 104 deletions(-)

8f62e07749b62f28242dc9fb7db5c0531d33401e
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index cd7c5d0..8f3903b 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -228,8 +228,8 @@ extern int dccp_rcv_state_process(struct
 extern int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
 				const struct dccp_hdr *dh, const unsigned len);
 
-extern int dccp_v4_init_sock(struct sock *sk);
-extern int dccp_v4_destroy_sock(struct sock *sk);
+extern int dccp_init_sock(struct sock *sk);
+extern int dccp_destroy_sock(struct sock *sk);
 
 extern void		dccp_close(struct sock *sk, long timeout);
 extern struct sk_buff	*dccp_make_response(struct sock *sk,
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 766b619..b26a4f8 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -1008,109 +1008,15 @@ struct inet_connection_sock_af_ops dccp_
 	.sockaddr_len	= sizeof(struct sockaddr_in),
 };
 
-int dccp_v4_init_sock(struct sock *sk)
+static int dccp_v4_init_sock(struct sock *sk)
 {
-	struct dccp_sock *dp = dccp_sk(sk);
-	struct inet_connection_sock *icsk = inet_csk(sk);
-	static int dccp_ctl_socket_init = 1;
-
-	dccp_options_init(&dp->dccps_options);
-	do_gettimeofday(&dp->dccps_epoch);
-
-	/*
-	 * FIXME: We're hardcoding the CCID, and doing this at this point makes
-	 * the listening (master) sock get CCID control blocks, which is not
-	 * necessary, but for now, to not mess with the test userspace apps,
-	 * lets leave it here, later the real solution is to do this in a
-	 * setsockopt(CCIDs-I-want/accept). -acme
-	 */
-	if (likely(!dccp_ctl_socket_init)) {
-		int rc = dccp_feat_init(sk);
-
-		if (rc)
-			return rc;
-
-		if (dp->dccps_options.dccpo_send_ack_vector) {
-			dp->dccps_hc_rx_ackvec = dccp_ackvec_alloc(GFP_KERNEL);
-			if (dp->dccps_hc_rx_ackvec = NULL)
-				return -ENOMEM;
-		}
-		dp->dccps_hc_rx_ccid -				ccid_hc_rx_new(dp->dccps_options.dccpo_rx_ccid,
-					       sk, GFP_KERNEL);
-		dp->dccps_hc_tx_ccid -				ccid_hc_tx_new(dp->dccps_options.dccpo_tx_ccid,
-					       sk, GFP_KERNEL);
-	    	if (unlikely(dp->dccps_hc_rx_ccid = NULL ||
-			     dp->dccps_hc_tx_ccid = NULL)) {
-			ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
-			ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
-			if (dp->dccps_options.dccpo_send_ack_vector) {
-				dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
-				dp->dccps_hc_rx_ackvec = NULL;
-			}
-			dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
-			return -ENOMEM;
-		}
-	} else {
-		/* control socket doesn't need feat nego */
-		INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending);
-		INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf);
-		dccp_ctl_socket_init = 0;
-	}	
-
-	dccp_init_xmit_timers(sk);
-	icsk->icsk_rto = DCCP_TIMEOUT_INIT;
-	sk->sk_state = DCCP_CLOSED;
-	sk->sk_write_space = dccp_write_space;
-	icsk->icsk_af_ops = &dccp_ipv4_af_ops;
-	icsk->icsk_sync_mss = dccp_sync_mss;
-	dp->dccps_mss_cache = 536;
-	dp->dccps_role = DCCP_ROLE_UNDEFINED;
-	dp->dccps_service = DCCP_SERVICE_INVALID_VALUE;
-	dp->dccps_l_ack_ratio = dp->dccps_r_ack_ratio = 1;
+	const int err = dccp_init_sock(sk);
 
-	return 0;
+	if (err = 0)
+		inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops;
+	return err;
 }
 
-EXPORT_SYMBOL_GPL(dccp_v4_init_sock);
-
-int dccp_v4_destroy_sock(struct sock *sk)
-{
-	struct dccp_sock *dp = dccp_sk(sk);
-
-	/*
-	 * DCCP doesn't use sk_write_queue, just sk_send_head
-	 * for retransmissions
-	 */
-	if (sk->sk_send_head != NULL) {
-		kfree_skb(sk->sk_send_head);
-		sk->sk_send_head = NULL;
-	}
-
-	/* Clean up a referenced DCCP bind bucket. */
-	if (inet_csk(sk)->icsk_bind_hash != NULL)
-		inet_put_port(&dccp_hashinfo, sk);
-
-	kfree(dp->dccps_service_list);
-	dp->dccps_service_list = NULL;
-
-	if (dp->dccps_options.dccpo_send_ack_vector) {
-		dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
-		dp->dccps_hc_rx_ackvec = NULL;
-	}
-	ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
-	ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
-	dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
-
-	/* clean up feature negotiation state */
-	dccp_feat_clean(sk);
-
-	return 0;
-}
-
-EXPORT_SYMBOL_GPL(dccp_v4_destroy_sock);
-
 static void dccp_v4_reqsk_destructor(struct request_sock *req)
 {
 	kfree(inet_rsk(req)->opt);
@@ -1147,7 +1053,7 @@ struct proto dccp_prot = {
 	.accept			= inet_csk_accept,
 	.get_port		= dccp_v4_get_port,
 	.shutdown		= dccp_shutdown,
-	.destroy		= dccp_v4_destroy_sock,
+	.destroy		= dccp_destroy_sock,
 	.orphan_count		= &dccp_orphan_count,
 	.max_header		= MAX_DCCP_HEADER,
 	.obj_size		= sizeof(struct dccp_sock),
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index ad5a1c6..84651bc 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1146,7 +1146,7 @@ static struct inet_connection_sock_af_op
  */
 static int dccp_v6_init_sock(struct sock *sk)
 {
-	int err = dccp_v4_init_sock(sk);
+	int err = dccp_init_sock(sk);
 
 	if (err = 0)
 		inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
@@ -1156,7 +1156,7 @@ static int dccp_v6_init_sock(struct sock
 
 static int dccp_v6_destroy_sock(struct sock *sk)
 {
-	dccp_v4_destroy_sock(sk);
+	dccp_destroy_sock(sk);
 	return inet6_destroy_sock(sk);
 }
 
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 04315c3..1f5c92d 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -97,6 +97,108 @@ const char *dccp_state_name(const int st
 
 EXPORT_SYMBOL_GPL(dccp_state_name);
 
+int dccp_init_sock(struct sock *sk)
+{
+	struct dccp_sock *dp = dccp_sk(sk);
+	struct inet_connection_sock *icsk = inet_csk(sk);
+	static int dccp_ctl_socket_init = 1;
+
+	dccp_options_init(&dp->dccps_options);
+	do_gettimeofday(&dp->dccps_epoch);
+
+	/*
+	 * FIXME: We're hardcoding the CCID, and doing this at this point makes
+	 * the listening (master) sock get CCID control blocks, which is not
+	 * necessary, but for now, to not mess with the test userspace apps,
+	 * lets leave it here, later the real solution is to do this in a
+	 * setsockopt(CCIDs-I-want/accept). -acme
+	 */
+	if (likely(!dccp_ctl_socket_init)) {
+		int rc = dccp_feat_init(sk);
+
+		if (rc)
+			return rc;
+
+		if (dp->dccps_options.dccpo_send_ack_vector) {
+			dp->dccps_hc_rx_ackvec = dccp_ackvec_alloc(GFP_KERNEL);
+			if (dp->dccps_hc_rx_ackvec = NULL)
+				return -ENOMEM;
+		}
+		dp->dccps_hc_rx_ccid +				ccid_hc_rx_new(dp->dccps_options.dccpo_rx_ccid,
+					       sk, GFP_KERNEL);
+		dp->dccps_hc_tx_ccid +				ccid_hc_tx_new(dp->dccps_options.dccpo_tx_ccid,
+					       sk, GFP_KERNEL);
+	    	if (unlikely(dp->dccps_hc_rx_ccid = NULL ||
+			     dp->dccps_hc_tx_ccid = NULL)) {
+			ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
+			ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
+			if (dp->dccps_options.dccpo_send_ack_vector) {
+				dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
+				dp->dccps_hc_rx_ackvec = NULL;
+			}
+			dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
+			return -ENOMEM;
+		}
+	} else {
+		/* control socket doesn't need feat nego */
+		INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending);
+		INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf);
+		dccp_ctl_socket_init = 0;
+	}	
+
+	dccp_init_xmit_timers(sk);
+	icsk->icsk_rto		= DCCP_TIMEOUT_INIT;
+	sk->sk_state		= DCCP_CLOSED;
+	sk->sk_write_space	= dccp_write_space;
+	icsk->icsk_sync_mss	= dccp_sync_mss;
+	dp->dccps_mss_cache	= 536;
+	dp->dccps_role		= DCCP_ROLE_UNDEFINED;
+	dp->dccps_service	= DCCP_SERVICE_INVALID_VALUE;
+	dp->dccps_l_ack_ratio	= dp->dccps_r_ack_ratio = 1;
+
+	return 0;
+}
+
+EXPORT_SYMBOL_GPL(dccp_init_sock);
+
+int dccp_destroy_sock(struct sock *sk)
+{
+	struct dccp_sock *dp = dccp_sk(sk);
+
+	/*
+	 * DCCP doesn't use sk_write_queue, just sk_send_head
+	 * for retransmissions
+	 */
+	if (sk->sk_send_head != NULL) {
+		kfree_skb(sk->sk_send_head);
+		sk->sk_send_head = NULL;
+	}
+
+	/* Clean up a referenced DCCP bind bucket. */
+	if (inet_csk(sk)->icsk_bind_hash != NULL)
+		inet_put_port(&dccp_hashinfo, sk);
+
+	kfree(dp->dccps_service_list);
+	dp->dccps_service_list = NULL;
+
+	if (dp->dccps_options.dccpo_send_ack_vector) {
+		dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
+		dp->dccps_hc_rx_ackvec = NULL;
+	}
+	ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
+	ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
+	dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
+
+	/* clean up feature negotiation state */
+	dccp_feat_clean(sk);
+
+	return 0;
+}
+
+EXPORT_SYMBOL_GPL(dccp_destroy_sock);
+
 static inline int dccp_listen_start(struct sock *sk)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 7/7] [DCCP]: Move the IPv4 specific bits from proto.c to ipv4.c
From: Arnaldo Carvalho de Melo @ 2006-02-23 22:12 UTC (permalink / raw)
  To: dccp

With this patch in place we can break down the complexity by better
compartmentalizing the code that is common to ipv6 and ipv4.

Now we have these modules:
Module                  Size  Used by
dccp_diag               1344  0
inet_diag               9448  1 dccp_diag
dccp_ccid3             15856  0
dccp_tfrc_lib          12320  1 dccp_ccid3
dccp_ccid2              5764  0
dccp_ipv4              16996  2
dccp                   48208  4 dccp_diag,dccp_ccid3,dccp_ccid2,dccp_ipv4

dccp_ipv6 still requires dccp_ipv4 due to dccp_ipv6_mapped, that is the next
target to work on the "hey, ipv4 is legacy, I only want ipv6 dude!" direction.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/Makefile  |    7 +--
 net/dccp/dccp.h    |    6 --
 net/dccp/ipv4.c    |  140 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 net/dccp/options.c |    2 +
 net/dccp/output.c  |    2 +
 net/dccp/proto.c   |  132 ++-----------------------------------------------
 6 files changed, 148 insertions(+), 141 deletions(-)

63d1742ba27197d1678bd5cc05cfa8a1fde3c6d4
diff --git a/net/dccp/Makefile b/net/dccp/Makefile
index 7af0569..7696e21 100644
--- a/net/dccp/Makefile
+++ b/net/dccp/Makefile
@@ -2,10 +2,11 @@ obj-$(CONFIG_IPV6) += dccp_ipv6.o
 
 dccp_ipv6-y := ipv6.o
 
-obj-$(CONFIG_IP_DCCP) += dccp.o
+obj-$(CONFIG_IP_DCCP) += dccp.o dccp_ipv4.o
 
-dccp-y := ccid.o feat.o input.o ipv4.o minisocks.o options.o output.o proto.o \
-	  timer.o
+dccp-y := ccid.o feat.o input.o minisocks.o options.o output.o proto.o timer.o
+
+dccp_ipv4-y := ipv4.o
 
 dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.o
 
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index b6ea4cc..46aa481 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -59,8 +59,6 @@ extern void dccp_time_wait(struct sock *
 
 #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
 
-extern struct proto dccp_prot;
-
 /* is seq1 < seq2 ? */
 static inline int before48(const u64 seq1, const u64 seq2)
 {
@@ -209,10 +207,6 @@ extern struct sock *dccp_create_openreq_
 
 extern int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb);
 
-extern void dccp_v4_err(struct sk_buff *skb, u32);
-
-extern int dccp_v4_rcv(struct sk_buff *skb);
-
 extern struct sock *dccp_v4_request_recv_sock(struct sock *sk,
 					      struct sk_buff *skb,
 					      struct request_sock *req,
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index a7332f0..033c3ab 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -18,8 +18,10 @@
 #include <linux/random.h>
 
 #include <net/icmp.h>
+#include <net/inet_common.h>
 #include <net/inet_hashtables.h>
 #include <net/inet_sock.h>
+#include <net/protocol.h>
 #include <net/sock.h>
 #include <net/timewait_sock.h>
 #include <net/tcp_states.h>
@@ -285,7 +287,7 @@ out:
  * check at all. A more general error queue to queue errors for later handling
  * is probably better.
  */
-void dccp_v4_err(struct sk_buff *skb, u32 info)
+static void dccp_v4_err(struct sk_buff *skb, u32 info)
 {
 	const struct iphdr *iph = (struct iphdr *)skb->data;
 	const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data +
@@ -639,6 +641,8 @@ int dccp_v4_checksum(const struct sk_buf
 				 IPPROTO_DCCP, tmp);
 }
 
+EXPORT_SYMBOL_GPL(dccp_v4_checksum);
+
 static int dccp_v4_verify_checksum(struct sk_buff *skb,
 				   const __be32 saddr, const __be32 daddr)
 {
@@ -871,7 +875,7 @@ int dccp_invalid_packet(struct sk_buff *
 EXPORT_SYMBOL_GPL(dccp_invalid_packet);
 
 /* this is called when real data arrives */
-int dccp_v4_rcv(struct sk_buff *skb)
+static int dccp_v4_rcv(struct sk_buff *skb)
 {
 	const struct dccp_hdr *dh;
 	struct sock *sk;
@@ -978,7 +982,7 @@ do_time_wait:
 	goto no_dccp_socket;
 }
 
-struct inet_connection_sock_af_ops dccp_ipv4_af_ops = {
+static struct inet_connection_sock_af_ops dccp_ipv4_af_ops = {
 	.queue_xmit	= ip_queue_xmit,
 	.send_check	= dccp_v4_send_check,
 	.rebuild_header	= inet_sk_rebuild_header,
@@ -1018,7 +1022,7 @@ static struct timewait_sock_ops dccp_tim
 	.twsk_obj_size	= sizeof(struct inet_timewait_sock),
 };
 
-struct proto dccp_prot = {
+struct proto dccp_v4_prot = {
 	.name			= "DCCP",
 	.owner			= THIS_MODULE,
 	.close			= dccp_close,
@@ -1044,4 +1048,130 @@ struct proto dccp_prot = {
 	.twsk_prot		= &dccp_timewait_sock_ops,
 };
 
-EXPORT_SYMBOL_GPL(dccp_prot);
+static struct net_protocol dccp_v4_protocol = {
+	.handler	= dccp_v4_rcv,
+	.err_handler	= dccp_v4_err,
+	.no_policy	= 1,
+};
+
+static const struct proto_ops inet_dccp_ops = {
+	.family		= PF_INET,
+	.owner		= THIS_MODULE,
+	.release	= inet_release,
+	.bind		= inet_bind,
+	.connect	= inet_stream_connect,
+	.socketpair	= sock_no_socketpair,
+	.accept		= inet_accept,
+	.getname	= inet_getname,
+	/* FIXME: work on tcp_poll to rename it to inet_csk_poll */
+	.poll		= dccp_poll,
+	.ioctl		= inet_ioctl,
+	/* FIXME: work on inet_listen to rename it to sock_common_listen */
+	.listen		= inet_dccp_listen,
+	.shutdown	= inet_shutdown,
+	.setsockopt	= sock_common_setsockopt,
+	.getsockopt	= sock_common_getsockopt,
+	.sendmsg	= inet_sendmsg,
+	.recvmsg	= sock_common_recvmsg,
+	.mmap		= sock_no_mmap,
+	.sendpage	= sock_no_sendpage,
+};
+
+static struct inet_protosw dccp_v4_protosw = {
+	.type		= SOCK_DCCP,
+	.protocol	= IPPROTO_DCCP,
+	.prot		= &dccp_v4_prot,
+	.ops		= &inet_dccp_ops,
+	.capability	= -1,
+	.no_check	= 0,
+	.flags		= INET_PROTOSW_ICSK,
+};
+
+/*
+ * This is the global socket data structure used for responding to
+ * the Out-of-the-blue (OOTB) packets. A control sock will be created
+ * for this socket at the initialization time.
+ */
+struct socket *dccp_ctl_socket;
+
+static char dccp_ctl_socket_err_msg[] __initdata +	KERN_ERR "DCCP: Failed to create the control socket.\n";
+
+static int __init dccp_ctl_sock_init(void)
+{
+	int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP,
+				  &dccp_ctl_socket);
+	if (rc < 0)
+		printk(dccp_ctl_socket_err_msg);
+	else {
+		dccp_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
+		inet_sk(dccp_ctl_socket->sk)->uc_ttl = -1;
+
+		/* Unhash it so that IP input processing does not even
+		 * see it, we do not wish this socket to see incoming
+		 * packets.
+		 */
+		dccp_ctl_socket->sk->sk_prot->unhash(dccp_ctl_socket->sk);
+	}
+
+	return rc;
+}
+
+#ifdef CONFIG_IP_DCCP_UNLOAD_HACK
+void dccp_ctl_sock_exit(void)
+{
+	if (dccp_ctl_socket != NULL) {
+		sock_release(dccp_ctl_socket);
+		dccp_ctl_socket = NULL;
+	}
+}
+
+EXPORT_SYMBOL_GPL(dccp_ctl_sock_exit);
+#endif
+
+static int __init dccp_v4_init(void)
+{
+	int err = proto_register(&dccp_v4_prot, 1);
+
+	if (err != 0)
+		goto out;
+
+	err = inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
+	if (err != 0)
+		goto out_proto_unregister;
+
+	inet_register_protosw(&dccp_v4_protosw);
+
+	err = dccp_ctl_sock_init();
+	if (err)
+		goto out_unregister_protosw;
+out:
+	return err;
+out_unregister_protosw:
+	inet_unregister_protosw(&dccp_v4_protosw);
+	inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
+out_proto_unregister:
+	proto_unregister(&dccp_v4_prot);
+	goto out;
+}
+
+static void __exit dccp_v4_exit(void)
+{
+	inet_unregister_protosw(&dccp_v4_protosw);
+	inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
+	proto_unregister(&dccp_v4_prot);
+}
+
+module_init(dccp_v4_init);
+module_exit(dccp_v4_exit);
+
+/*
+ * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
+ * values directly, Also cover the case where the protocol is not specified,
+ * i.e. net-pf-PF_INET-proto-0-type-SOCK_DCCP
+ */
+MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-33-type-6");
+MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-0-type-6");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
+MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 3ecd319..79d228e 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -258,6 +258,8 @@ out_invalid_option:
 	return -1;
 }
 
+EXPORT_SYMBOL_GPL(dccp_parse_options);
+
 static void dccp_encode_value_var(const u32 value, unsigned char *to,
 				  const unsigned int len)
 {
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 6bd21e3..8c83aa5 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -526,6 +526,8 @@ void dccp_send_sync(struct sock *sk, con
 	dccp_transmit_skb(sk, skb);
 }
 
+EXPORT_SYMBOL_GPL(dccp_send_sync);
+
 /*
  * Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This
  * cannot be allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index c048d5b..d110cdb 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -23,9 +23,7 @@
 #include <linux/random.h>
 #include <net/checksum.h>
 
-#include <net/inet_common.h>
 #include <net/inet_sock.h>
-#include <net/protocol.h>
 #include <net/sock.h>
 #include <net/xfrm.h>
 
@@ -55,12 +53,6 @@ struct inet_hashinfo __cacheline_aligned
 
 EXPORT_SYMBOL_GPL(dccp_hashinfo);
 
-static struct net_protocol dccp_protocol = {
-	.handler	= dccp_v4_rcv,
-	.err_handler	= dccp_v4_err,
-	.no_policy	= 1,
-};
-
 const char *dccp_packet_name(const int type)
 {
 	static const char *dccp_packet_names[] = {
@@ -856,83 +848,6 @@ void dccp_shutdown(struct sock *sk, int 
 
 EXPORT_SYMBOL_GPL(dccp_shutdown);
 
-static const struct proto_ops inet_dccp_ops = {
-	.family		= PF_INET,
-	.owner		= THIS_MODULE,
-	.release	= inet_release,
-	.bind		= inet_bind,
-	.connect	= inet_stream_connect,
-	.socketpair	= sock_no_socketpair,
-	.accept		= inet_accept,
-	.getname	= inet_getname,
-	/* FIXME: work on tcp_poll to rename it to inet_csk_poll */
-	.poll		= dccp_poll,
-	.ioctl		= inet_ioctl,
-	/* FIXME: work on inet_listen to rename it to sock_common_listen */
-	.listen		= inet_dccp_listen,
-	.shutdown	= inet_shutdown,
-	.setsockopt	= sock_common_setsockopt,
-	.getsockopt	= sock_common_getsockopt,
-	.sendmsg	= inet_sendmsg,
-	.recvmsg	= sock_common_recvmsg,
-	.mmap		= sock_no_mmap,
-	.sendpage	= sock_no_sendpage,
-};
-
-extern struct net_proto_family inet_family_ops;
-
-static struct inet_protosw dccp_v4_protosw = {
-	.type		= SOCK_DCCP,
-	.protocol	= IPPROTO_DCCP,
-	.prot		= &dccp_prot,
-	.ops		= &inet_dccp_ops,
-	.capability	= -1,
-	.no_check	= 0,
-	.flags		= INET_PROTOSW_ICSK,
-};
-
-/*
- * This is the global socket data structure used for responding to
- * the Out-of-the-blue (OOTB) packets. A control sock will be created
- * for this socket at the initialization time.
- */
-struct socket *dccp_ctl_socket;
-
-static char dccp_ctl_socket_err_msg[] __initdata -	KERN_ERR "DCCP: Failed to create the control socket.\n";
-
-static int __init dccp_ctl_sock_init(void)
-{
-	int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP,
-				  &dccp_ctl_socket);
-	if (rc < 0)
-		printk(dccp_ctl_socket_err_msg);
-	else {
-		dccp_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
-		inet_sk(dccp_ctl_socket->sk)->uc_ttl = -1;
-
-		/* Unhash it so that IP input processing does not even
-		 * see it, we do not wish this socket to see incoming
-		 * packets.
-		 */
-		dccp_ctl_socket->sk->sk_prot->unhash(dccp_ctl_socket->sk);
-	}
-
-	return rc;
-}
-
-#ifdef CONFIG_IP_DCCP_UNLOAD_HACK
-void dccp_ctl_sock_exit(void)
-{
-	if (dccp_ctl_socket != NULL) {
-		sock_release(dccp_ctl_socket);
-		dccp_ctl_socket = NULL;
-	}
-}
-
-EXPORT_SYMBOL_GPL(dccp_ctl_sock_exit);
-#endif
-
 static int __init dccp_mib_init(void)
 {
 	int rc = -ENOMEM;
@@ -955,7 +870,7 @@ out_free_one:
 
 }
 
-static int dccp_mib_exit(void)
+static void dccp_mib_exit(void)
 {
 	free_percpu(dccp_statistics[0]);
 	free_percpu(dccp_statistics[1]);
@@ -978,18 +893,14 @@ static int __init dccp_init(void)
 {
 	unsigned long goal;
 	int ehash_order, bhash_order, i;
-	int rc = proto_register(&dccp_prot, 1);
+	int rc = -ENOBUFS;
 
-	if (rc)
-		goto out;
-
-	rc = -ENOBUFS;
 	dccp_hashinfo.bind_bucket_cachep  		kmem_cache_create("dccp_bind_bucket",
 				  sizeof(struct inet_bind_bucket), 0,
 				  SLAB_HWCACHE_ALIGN, NULL, NULL);
 	if (!dccp_hashinfo.bind_bucket_cachep)
-		goto out_proto_unregister;
+		goto out;
 
 	/*
 	 * Size and allocate the main established and bind bucket
@@ -1055,33 +966,18 @@ static int __init dccp_init(void)
 	if (rc)
 		goto out_free_dccp_bhash;
 
-	rc = -EAGAIN;
-	if (inet_add_protocol(&dccp_protocol, IPPROTO_DCCP))
-		goto out_free_dccp_v4_mibs;
-
-	inet_register_protosw(&dccp_v4_protosw);
-
 	rc = dccp_ackvec_init();
 	if (rc)
-		goto out_unregister_protosw;
+		goto out_free_dccp_mib;
 
 	rc = dccp_sysctl_init();
 	if (rc)
 		goto out_ackvec_exit;
-
-	rc = dccp_ctl_sock_init();
-	if (rc)
-		goto out_sysctl_exit;
 out:
 	return rc;
-out_sysctl_exit:
-	dccp_sysctl_exit();
 out_ackvec_exit:
 	dccp_ackvec_exit();
-out_unregister_protosw:
-	inet_unregister_protosw(&dccp_v4_protosw);
-	inet_del_protocol(&dccp_protocol, IPPROTO_DCCP);
-out_free_dccp_v4_mibs:
+out_free_dccp_mib:
 	dccp_mib_exit();
 out_free_dccp_bhash:
 	free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
@@ -1092,21 +988,11 @@ out_free_dccp_ehash:
 out_free_bind_bucket_cachep:
 	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
 	dccp_hashinfo.bind_bucket_cachep = NULL;
-out_proto_unregister:
-	proto_unregister(&dccp_prot);
 	goto out;
 }
 
-static const char dccp_del_proto_err_msg[] __exitdata -	KERN_ERR "can't remove dccp net_protocol\n";
-
 static void __exit dccp_fini(void)
 {
-	inet_unregister_protosw(&dccp_v4_protosw);
-
-	if (inet_del_protocol(&dccp_protocol, IPPROTO_DCCP) < 0)
-		printk(dccp_del_proto_err_msg);
-
 	dccp_mib_exit();
 	free_pages((unsigned long)dccp_hashinfo.bhash,
 		   get_order(dccp_hashinfo.bhash_size *
@@ -1115,7 +1001,6 @@ static void __exit dccp_fini(void)
 		   get_order(dccp_hashinfo.ehash_size *
 			     sizeof(struct inet_ehash_bucket)));
 	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
-	proto_unregister(&dccp_prot);
 	dccp_ackvec_exit();
 	dccp_sysctl_exit();
 }
@@ -1123,13 +1008,6 @@ static void __exit dccp_fini(void)
 module_init(dccp_init);
 module_exit(dccp_fini);
 
-/*
- * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
- * values directly, Also cover the case where the protocol is not specified,
- * i.e. net-pf-PF_INET-proto-0-type-SOCK_DCCP
- */
-MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-33-type-6");
-MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-0-type-6");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@conectiva.com.br>");
 MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 4/7] [DCCP]: Dont use dccp_v4_checksum in dccp_make_response
From: Arnaldo Carvalho de Melo @ 2006-02-23 22:12 UTC (permalink / raw)
  To: dccp

dccp_make_response is shared by ipv4/6 and the ipv6 code was recalculating the
checksum, not good, so move the dccp_v4_checksum call to dccp_v4_send_response.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/ipv4.c   |    3 +++
 net/dccp/output.c |    3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

e9ec1a839d3fe9f2ec5e864a094cf04b6c511c03
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 34d1b11..f087593 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -264,7 +264,10 @@ static int dccp_v4_send_response(struct 
 	skb = dccp_make_response(sk, dst, req);
 	if (skb != NULL) {
 		const struct inet_request_sock *ireq = inet_rsk(req);
+		struct dccp_hdr *dh = dccp_hdr(skb);
 
+		dh->dccph_checksum = dccp_v4_checksum(skb, ireq->loc_addr,
+						      ireq->rmt_addr);
 		memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
 		err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
 					    ireq->rmt_addr,
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 9922d26..6bd21e3 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -314,9 +314,6 @@ struct sk_buff *dccp_make_response(struc
 	dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr);
 	dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service;
 
-	dh->dccph_checksum = dccp_v4_checksum(skb, inet_rsk(req)->loc_addr,
-					      inet_rsk(req)->rmt_addr);
-
 	DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
 	return skb;
 }
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 1/7] [DCCP]: Generalize dccp_v4_send_reset
From: Arnaldo Carvalho de Melo @ 2006-02-23 22:12 UTC (permalink / raw)
  To: dccp

Renaming it to dccp_send_reset and moving it from the ipv4 specific code to the
core dccp code.

This fixes some bugs in IPV6 where timers would send v4 resets, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/dccp.h   |    6 +-----
 net/dccp/input.c  |    2 +-
 net/dccp/ipv4.c   |   26 --------------------------
 net/dccp/output.c |   30 +++++++++++++++++++++++++-----
 net/dccp/timer.c  |    2 +-
 5 files changed, 28 insertions(+), 38 deletions(-)

f6d02dcee746dd116bcdf3902d40eeab21e3b517
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index f059541..cd7c5d0 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -235,9 +235,6 @@ extern void		dccp_close(struct sock *sk,
 extern struct sk_buff	*dccp_make_response(struct sock *sk,
 					    struct dst_entry *dst,
 					    struct request_sock *req);
-extern struct sk_buff	*dccp_make_reset(struct sock *sk,
-					 struct dst_entry *dst,
-					 enum dccp_reset_codes code);
 
 extern int	   dccp_connect(struct sock *sk);
 extern int	   dccp_disconnect(struct sock *sk, int flags);
@@ -264,8 +261,7 @@ extern int	   dccp_v4_connect(struct soc
 extern int	   dccp_v4_checksum(const struct sk_buff *skb,
 				    const __be32 saddr, const __be32 daddr);
 
-extern int	   dccp_v4_send_reset(struct sock *sk,
-				      enum dccp_reset_codes code);
+extern int	   dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
 extern void	   dccp_send_close(struct sock *sk, const int active);
 extern int	   dccp_invalid_packet(struct sk_buff *skb);
 
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 67691a0..eac5178 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -32,7 +32,7 @@ static void dccp_fin(struct sock *sk, st
 
 static void dccp_rcv_close(struct sock *sk, struct sk_buff *skb)
 {
-	dccp_v4_send_reset(sk, DCCP_RESET_CODE_CLOSED);
+	dccp_send_reset(sk, DCCP_RESET_CODE_CLOSED);
 	dccp_fin(sk, skb);
 	dccp_set_state(sk, DCCP_CLOSED);
 	sk_wake_async(sk, 1, POLL_HUP);
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 4a2ce1c..766b619 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -457,32 +457,6 @@ void dccp_v4_send_check(struct sock *sk,
 
 EXPORT_SYMBOL_GPL(dccp_v4_send_check);
 
-int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code)
-{
-	struct sk_buff *skb;
-	/*
-	 * FIXME: what if rebuild_header fails?
-	 * Should we be doing a rebuild_header here?
-	 */
-	int err = inet_sk_rebuild_header(sk);
-
-	if (err != 0)
-		return err;
-
-	skb = dccp_make_reset(sk, sk->sk_dst_cache, code);
-	if (skb != NULL) {
-		const struct inet_sock *inet = inet_sk(sk);
-
-		memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
-		err = ip_build_and_send_pkt(skb, sk,
-					    inet->saddr, inet->daddr, NULL);
-		if (err = NET_XMIT_CN)
-			err = 0;
-	}
-
-	return err;
-}
-
 static inline u64 dccp_v4_init_sequence(const struct sock *sk,
 					const struct sk_buff *skb)
 {
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 0cc2bcf..9922d26 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -323,8 +323,8 @@ struct sk_buff *dccp_make_response(struc
 
 EXPORT_SYMBOL_GPL(dccp_make_response);
 
-struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
-				const enum dccp_reset_codes code)
+static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
+				       const enum dccp_reset_codes code)
 				   
 {
 	struct dccp_hdr *dh;
@@ -366,14 +366,34 @@ struct sk_buff *dccp_make_reset(struct s
 	dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dp->dccps_gsr);
 
 	dccp_hdr_reset(skb)->dccph_reset_code = code;
-
-	dh->dccph_checksum = dccp_v4_checksum(skb, inet_sk(sk)->saddr,
-					      inet_sk(sk)->daddr);
+	inet_csk(sk)->icsk_af_ops->send_check(sk, skb->len, skb);
 
 	DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
 	return skb;
 }
 
+int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code)
+{
+	/*
+	 * FIXME: what if rebuild_header fails?
+	 * Should we be doing a rebuild_header here?
+	 */
+	int err = inet_sk_rebuild_header(sk);
+
+	if (err = 0) {
+		struct sk_buff *skb = dccp_make_reset(sk, sk->sk_dst_cache,
+						      code);
+		if (skb != NULL) {
+			memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+			err = inet_csk(sk)->icsk_af_ops->queue_xmit(skb, 0);
+			if (err = NET_XMIT_CN)
+				err = 0;
+		}
+	}
+
+	return err;
+}
+
 /*
  * Do all connect socket setups that can be done AF independent.
  */
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index d7c7866..5244415 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -31,7 +31,7 @@ static void dccp_write_err(struct sock *
 	sk->sk_err = sk->sk_err_soft ? : ETIMEDOUT;
 	sk->sk_error_report(sk);
 
-	dccp_v4_send_reset(sk, DCCP_RESET_CODE_ABORTED);
+	dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED);
 	dccp_done(sk);
 	DCCP_INC_STATS_BH(DCCP_MIB_ABORTONTIMEOUT);
 }
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 3/7] [DCCP]: Move dccp_[un]hash from ipv4.c to the core
From: Arnaldo Carvalho de Melo @ 2006-02-23 22:12 UTC (permalink / raw)
  To: dccp

As this is used by both ipv4 and ipv6 and is not ipv4 specific.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/dccp.h  |    1 +
 net/dccp/ipv4.c  |   14 +-------------
 net/dccp/ipv6.c  |    2 +-
 net/dccp/proto.c |   14 ++++++++++++++
 4 files changed, 17 insertions(+), 14 deletions(-)

5f50d3a8059644b039b19a43200800783658e130
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 8f3903b..b6ea4cc 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -238,6 +238,7 @@ extern struct sk_buff	*dccp_make_respons
 
 extern int	   dccp_connect(struct sock *sk);
 extern int	   dccp_disconnect(struct sock *sk, int flags);
+extern void	   dccp_hash(struct sock *sk);
 extern void	   dccp_unhash(struct sock *sk);
 extern int	   dccp_getsockopt(struct sock *sk, int level, int optname,
 				   char __user *optval, int __user *optlen);
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index b26a4f8..34d1b11 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -44,18 +44,6 @@ static int dccp_v4_get_port(struct sock 
 				 inet_csk_bind_conflict);
 }
 
-static void dccp_v4_hash(struct sock *sk)
-{
-	inet_hash(&dccp_hashinfo, sk);
-}
-
-void dccp_unhash(struct sock *sk)
-{
-	inet_unhash(&dccp_hashinfo, sk);
-}
-
-EXPORT_SYMBOL_GPL(dccp_unhash);
-
 int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
 {
 	struct inet_sock *inet = inet_sk(sk);
@@ -1048,7 +1036,7 @@ struct proto dccp_prot = {
 	.sendmsg		= dccp_sendmsg,
 	.recvmsg		= dccp_recvmsg,
 	.backlog_rcv		= dccp_v4_do_rcv,
-	.hash			= dccp_v4_hash,
+	.hash			= dccp_hash,
 	.unhash			= dccp_unhash,
 	.accept			= inet_csk_accept,
 	.get_port		= dccp_v4_get_port,
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 84651bc..904967b 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -53,7 +53,7 @@ static void dccp_v6_hash(struct sock *sk
 {
 	if (sk->sk_state != DCCP_CLOSED) {
 		if (inet_csk(sk)->icsk_af_ops = &dccp_ipv6_mapped) {
-			dccp_prot.hash(sk);
+			dccp_hash(sk);
 			return;
 		}
 		local_bh_disable();
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 1f5c92d..7ac935a 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -97,6 +97,20 @@ const char *dccp_state_name(const int st
 
 EXPORT_SYMBOL_GPL(dccp_state_name);
 
+void dccp_hash(struct sock *sk)
+{
+	inet_hash(&dccp_hashinfo, sk);
+}
+
+EXPORT_SYMBOL_GPL(dccp_hash);
+
+void dccp_unhash(struct sock *sk)
+{
+	inet_unhash(&dccp_hashinfo, sk);
+}
+
+EXPORT_SYMBOL_GPL(dccp_unhash);
+
 int dccp_init_sock(struct sock *sk)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
-- 
1.2.2.gd27d



^ permalink raw reply related

* [PATCH 6/7] [DCCP]: Rename init_dccp_v4_mibs to dccp_mib_init
From: Arnaldo Carvalho de Melo @ 2006-02-23 22:12 UTC (permalink / raw)
  To: dccp

And introduce dccp_mib_exit grouping previously open coded sequence.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

---

 net/dccp/proto.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

2250710f2979bf1e47bba2f6e3fcadfd9a686071
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index a57a8b6..c048d5b 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -933,7 +933,7 @@ void dccp_ctl_sock_exit(void)
 EXPORT_SYMBOL_GPL(dccp_ctl_sock_exit);
 #endif
 
-static int __init init_dccp_v4_mibs(void)
+static int __init dccp_mib_init(void)
 {
 	int rc = -ENOMEM;
 
@@ -955,6 +955,13 @@ out_free_one:
 
 }
 
+static int dccp_mib_exit(void)
+{
+	free_percpu(dccp_statistics[0]);
+	free_percpu(dccp_statistics[1]);
+	dccp_statistics[0] = dccp_statistics[1] = NULL;
+}
+
 static int thash_entries;
 module_param(thash_entries, int, 0444);
 MODULE_PARM_DESC(thash_entries, "Number of ehash buckets");
@@ -1044,7 +1051,7 @@ static int __init dccp_init(void)
 		INIT_HLIST_HEAD(&dccp_hashinfo.bhash[i].chain);
 	}
 
-	rc = init_dccp_v4_mibs();
+	rc = dccp_mib_init();
 	if (rc)
 		goto out_free_dccp_bhash;
 
@@ -1075,9 +1082,7 @@ out_unregister_protosw:
 	inet_unregister_protosw(&dccp_v4_protosw);
 	inet_del_protocol(&dccp_protocol, IPPROTO_DCCP);
 out_free_dccp_v4_mibs:
-	free_percpu(dccp_statistics[0]);
-	free_percpu(dccp_statistics[1]);
-	dccp_statistics[0] = dccp_statistics[1] = NULL;
+	dccp_mib_exit();
 out_free_dccp_bhash:
 	free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
 	dccp_hashinfo.bhash = NULL;
@@ -1102,8 +1107,7 @@ static void __exit dccp_fini(void)
 	if (inet_del_protocol(&dccp_protocol, IPPROTO_DCCP) < 0)
 		printk(dccp_del_proto_err_msg);
 
-	free_percpu(dccp_statistics[0]);
-	free_percpu(dccp_statistics[1]);
+	dccp_mib_exit();
 	free_pages((unsigned long)dccp_hashinfo.bhash,
 		   get_order(dccp_hashinfo.bhash_size *
 			     sizeof(struct inet_bind_hashbucket)));
-- 
1.2.2.gd27d



^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox