ipv4.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. /*
  2. * net/dccp/ipv4.c
  3. *
  4. * An implementation of the DCCP protocol
  5. * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #include <linux/config.h>
  13. #include <linux/dccp.h>
  14. #include <linux/icmp.h>
  15. #include <linux/module.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/random.h>
  18. #include <net/icmp.h>
  19. #include <net/inet_hashtables.h>
  20. #include <net/inet_sock.h>
  21. #include <net/sock.h>
  22. #include <net/timewait_sock.h>
  23. #include <net/tcp_states.h>
  24. #include <net/xfrm.h>
  25. #include "ackvec.h"
  26. #include "ccid.h"
  27. #include "dccp.h"
  28. #include "feat.h"
  29. struct inet_hashinfo __cacheline_aligned dccp_hashinfo = {
  30. .lhash_lock = RW_LOCK_UNLOCKED,
  31. .lhash_users = ATOMIC_INIT(0),
  32. .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(dccp_hashinfo.lhash_wait),
  33. };
  34. EXPORT_SYMBOL_GPL(dccp_hashinfo);
  35. static int dccp_v4_get_port(struct sock *sk, const unsigned short snum)
  36. {
  37. return inet_csk_get_port(&dccp_hashinfo, sk, snum,
  38. inet_csk_bind_conflict);
  39. }
  40. static void dccp_v4_hash(struct sock *sk)
  41. {
  42. inet_hash(&dccp_hashinfo, sk);
  43. }
  44. void dccp_unhash(struct sock *sk)
  45. {
  46. inet_unhash(&dccp_hashinfo, sk);
  47. }
  48. EXPORT_SYMBOL_GPL(dccp_unhash);
  49. int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
  50. {
  51. struct inet_sock *inet = inet_sk(sk);
  52. struct dccp_sock *dp = dccp_sk(sk);
  53. const struct sockaddr_in *usin = (struct sockaddr_in *)uaddr;
  54. struct rtable *rt;
  55. u32 daddr, nexthop;
  56. int tmp;
  57. int err;
  58. dp->dccps_role = DCCP_ROLE_CLIENT;
  59. if (dccp_service_not_initialized(sk))
  60. return -EPROTO;
  61. if (addr_len < sizeof(struct sockaddr_in))
  62. return -EINVAL;
  63. if (usin->sin_family != AF_INET)
  64. return -EAFNOSUPPORT;
  65. nexthop = daddr = usin->sin_addr.s_addr;
  66. if (inet->opt != NULL && inet->opt->srr) {
  67. if (daddr == 0)
  68. return -EINVAL;
  69. nexthop = inet->opt->faddr;
  70. }
  71. tmp = ip_route_connect(&rt, nexthop, inet->saddr,
  72. RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
  73. IPPROTO_DCCP,
  74. inet->sport, usin->sin_port, sk);
  75. if (tmp < 0)
  76. return tmp;
  77. if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
  78. ip_rt_put(rt);
  79. return -ENETUNREACH;
  80. }
  81. if (inet->opt == NULL || !inet->opt->srr)
  82. daddr = rt->rt_dst;
  83. if (inet->saddr == 0)
  84. inet->saddr = rt->rt_src;
  85. inet->rcv_saddr = inet->saddr;
  86. inet->dport = usin->sin_port;
  87. inet->daddr = daddr;
  88. inet_csk(sk)->icsk_ext_hdr_len = 0;
  89. if (inet->opt != NULL)
  90. inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen;
  91. /*
  92. * Socket identity is still unknown (sport may be zero).
  93. * However we set state to DCCP_REQUESTING and not releasing socket
  94. * lock select source port, enter ourselves into the hash tables and
  95. * complete initialization after this.
  96. */
  97. dccp_set_state(sk, DCCP_REQUESTING);
  98. err = inet_hash_connect(&dccp_death_row, sk);
  99. if (err != 0)
  100. goto failure;
  101. err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport,
  102. sk);
  103. if (err != 0)
  104. goto failure;
  105. /* OK, now commit destination to socket. */
  106. sk_setup_caps(sk, &rt->u.dst);
  107. dp->dccps_gar =
  108. dp->dccps_iss = secure_dccp_sequence_number(inet->saddr,
  109. inet->daddr,
  110. inet->sport,
  111. usin->sin_port);
  112. dccp_update_gss(sk, dp->dccps_iss);
  113. inet->id = dp->dccps_iss ^ jiffies;
  114. err = dccp_connect(sk);
  115. rt = NULL;
  116. if (err != 0)
  117. goto failure;
  118. out:
  119. return err;
  120. failure:
  121. /*
  122. * This unhashes the socket and releases the local port, if necessary.
  123. */
  124. dccp_set_state(sk, DCCP_CLOSED);
  125. ip_rt_put(rt);
  126. sk->sk_route_caps = 0;
  127. inet->dport = 0;
  128. goto out;
  129. }
  130. EXPORT_SYMBOL_GPL(dccp_v4_connect);
  131. /*
  132. * This routine does path mtu discovery as defined in RFC1191.
  133. */
  134. static inline void dccp_do_pmtu_discovery(struct sock *sk,
  135. const struct iphdr *iph,
  136. u32 mtu)
  137. {
  138. struct dst_entry *dst;
  139. const struct inet_sock *inet = inet_sk(sk);
  140. const struct dccp_sock *dp = dccp_sk(sk);
  141. /* We are not interested in DCCP_LISTEN and request_socks (RESPONSEs
  142. * send out by Linux are always < 576bytes so they should go through
  143. * unfragmented).
  144. */
  145. if (sk->sk_state == DCCP_LISTEN)
  146. return;
  147. /* We don't check in the destentry if pmtu discovery is forbidden
  148. * on this route. We just assume that no packet_to_big packets
  149. * are send back when pmtu discovery is not active.
  150. * There is a small race when the user changes this flag in the
  151. * route, but I think that's acceptable.
  152. */
  153. if ((dst = __sk_dst_check(sk, 0)) == NULL)
  154. return;
  155. dst->ops->update_pmtu(dst, mtu);
  156. /* Something is about to be wrong... Remember soft error
  157. * for the case, if this connection will not able to recover.
  158. */
  159. if (mtu < dst_mtu(dst) && ip_dont_fragment(sk, dst))
  160. sk->sk_err_soft = EMSGSIZE;
  161. mtu = dst_mtu(dst);
  162. if (inet->pmtudisc != IP_PMTUDISC_DONT &&
  163. inet_csk(sk)->icsk_pmtu_cookie > mtu) {
  164. dccp_sync_mss(sk, mtu);
  165. /*
  166. * From: draft-ietf-dccp-spec-11.txt
  167. *
  168. * DCCP-Sync packets are the best choice for upward
  169. * probing, since DCCP-Sync probes do not risk application
  170. * data loss.
  171. */
  172. dccp_send_sync(sk, dp->dccps_gsr, DCCP_PKT_SYNC);
  173. } /* else let the usual retransmit timer handle it */
  174. }
  175. static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
  176. {
  177. int err;
  178. struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
  179. const int dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
  180. sizeof(struct dccp_hdr_ext) +
  181. sizeof(struct dccp_hdr_ack_bits);
  182. struct sk_buff *skb;
  183. if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
  184. return;
  185. skb = alloc_skb(MAX_DCCP_HEADER + 15, GFP_ATOMIC);
  186. if (skb == NULL)
  187. return;
  188. /* Reserve space for headers. */
  189. skb_reserve(skb, MAX_DCCP_HEADER);
  190. skb->dst = dst_clone(rxskb->dst);
  191. skb->h.raw = skb_push(skb, dccp_hdr_ack_len);
  192. dh = dccp_hdr(skb);
  193. memset(dh, 0, dccp_hdr_ack_len);
  194. /* Build DCCP header and checksum it. */
  195. dh->dccph_type = DCCP_PKT_ACK;
  196. dh->dccph_sport = rxdh->dccph_dport;
  197. dh->dccph_dport = rxdh->dccph_sport;
  198. dh->dccph_doff = dccp_hdr_ack_len / 4;
  199. dh->dccph_x = 1;
  200. dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
  201. dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
  202. DCCP_SKB_CB(rxskb)->dccpd_seq);
  203. bh_lock_sock(dccp_ctl_socket->sk);
  204. err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
  205. rxskb->nh.iph->daddr,
  206. rxskb->nh.iph->saddr, NULL);
  207. bh_unlock_sock(dccp_ctl_socket->sk);
  208. if (err == NET_XMIT_CN || err == 0) {
  209. DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
  210. DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
  211. }
  212. }
  213. static void dccp_v4_reqsk_send_ack(struct sk_buff *skb,
  214. struct request_sock *req)
  215. {
  216. dccp_v4_ctl_send_ack(skb);
  217. }
  218. static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
  219. struct dst_entry *dst)
  220. {
  221. int err = -1;
  222. struct sk_buff *skb;
  223. /* First, grab a route. */
  224. if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
  225. goto out;
  226. skb = dccp_make_response(sk, dst, req);
  227. if (skb != NULL) {
  228. const struct inet_request_sock *ireq = inet_rsk(req);
  229. memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
  230. err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
  231. ireq->rmt_addr,
  232. ireq->opt);
  233. if (err == NET_XMIT_CN)
  234. err = 0;
  235. }
  236. out:
  237. dst_release(dst);
  238. return err;
  239. }
  240. /*
  241. * This routine is called by the ICMP module when it gets some sort of error
  242. * condition. If err < 0 then the socket should be closed and the error
  243. * returned to the user. If err > 0 it's just the icmp type << 8 | icmp code.
  244. * After adjustment header points to the first 8 bytes of the tcp header. We
  245. * need to find the appropriate port.
  246. *
  247. * The locking strategy used here is very "optimistic". When someone else
  248. * accesses the socket the ICMP is just dropped and for some paths there is no
  249. * check at all. A more general error queue to queue errors for later handling
  250. * is probably better.
  251. */
  252. void dccp_v4_err(struct sk_buff *skb, u32 info)
  253. {
  254. const struct iphdr *iph = (struct iphdr *)skb->data;
  255. const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data +
  256. (iph->ihl << 2));
  257. struct dccp_sock *dp;
  258. struct inet_sock *inet;
  259. const int type = skb->h.icmph->type;
  260. const int code = skb->h.icmph->code;
  261. struct sock *sk;
  262. __u64 seq;
  263. int err;
  264. if (skb->len < (iph->ihl << 2) + 8) {
  265. ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
  266. return;
  267. }
  268. sk = inet_lookup(&dccp_hashinfo, iph->daddr, dh->dccph_dport,
  269. iph->saddr, dh->dccph_sport, inet_iif(skb));
  270. if (sk == NULL) {
  271. ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
  272. return;
  273. }
  274. if (sk->sk_state == DCCP_TIME_WAIT) {
  275. inet_twsk_put((struct inet_timewait_sock *)sk);
  276. return;
  277. }
  278. bh_lock_sock(sk);
  279. /* If too many ICMPs get dropped on busy
  280. * servers this needs to be solved differently.
  281. */
  282. if (sock_owned_by_user(sk))
  283. NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS);
  284. if (sk->sk_state == DCCP_CLOSED)
  285. goto out;
  286. dp = dccp_sk(sk);
  287. seq = dccp_hdr_seq(skb);
  288. if (sk->sk_state != DCCP_LISTEN &&
  289. !between48(seq, dp->dccps_swl, dp->dccps_swh)) {
  290. NET_INC_STATS(LINUX_MIB_OUTOFWINDOWICMPS);
  291. goto out;
  292. }
  293. switch (type) {
  294. case ICMP_SOURCE_QUENCH:
  295. /* Just silently ignore these. */
  296. goto out;
  297. case ICMP_PARAMETERPROB:
  298. err = EPROTO;
  299. break;
  300. case ICMP_DEST_UNREACH:
  301. if (code > NR_ICMP_UNREACH)
  302. goto out;
  303. if (code == ICMP_FRAG_NEEDED) { /* PMTU discovery (RFC1191) */
  304. if (!sock_owned_by_user(sk))
  305. dccp_do_pmtu_discovery(sk, iph, info);
  306. goto out;
  307. }
  308. err = icmp_err_convert[code].errno;
  309. break;
  310. case ICMP_TIME_EXCEEDED:
  311. err = EHOSTUNREACH;
  312. break;
  313. default:
  314. goto out;
  315. }
  316. switch (sk->sk_state) {
  317. struct request_sock *req , **prev;
  318. case DCCP_LISTEN:
  319. if (sock_owned_by_user(sk))
  320. goto out;
  321. req = inet_csk_search_req(sk, &prev, dh->dccph_dport,
  322. iph->daddr, iph->saddr);
  323. if (!req)
  324. goto out;
  325. /*
  326. * ICMPs are not backlogged, hence we cannot get an established
  327. * socket here.
  328. */
  329. BUG_TRAP(!req->sk);
  330. if (seq != dccp_rsk(req)->dreq_iss) {
  331. NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
  332. goto out;
  333. }
  334. /*
  335. * Still in RESPOND, just remove it silently.
  336. * There is no good way to pass the error to the newly
  337. * created socket, and POSIX does not want network
  338. * errors returned from accept().
  339. */
  340. inet_csk_reqsk_queue_drop(sk, req, prev);
  341. goto out;
  342. case DCCP_REQUESTING:
  343. case DCCP_RESPOND:
  344. if (!sock_owned_by_user(sk)) {
  345. DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
  346. sk->sk_err = err;
  347. sk->sk_error_report(sk);
  348. dccp_done(sk);
  349. } else
  350. sk->sk_err_soft = err;
  351. goto out;
  352. }
  353. /* If we've already connected we will keep trying
  354. * until we time out, or the user gives up.
  355. *
  356. * rfc1122 4.2.3.9 allows to consider as hard errors
  357. * only PROTO_UNREACH and PORT_UNREACH (well, FRAG_FAILED too,
  358. * but it is obsoleted by pmtu discovery).
  359. *
  360. * Note, that in modern internet, where routing is unreliable
  361. * and in each dark corner broken firewalls sit, sending random
  362. * errors ordered by their masters even this two messages finally lose
  363. * their original sense (even Linux sends invalid PORT_UNREACHs)
  364. *
  365. * Now we are in compliance with RFCs.
  366. * --ANK (980905)
  367. */
  368. inet = inet_sk(sk);
  369. if (!sock_owned_by_user(sk) && inet->recverr) {
  370. sk->sk_err = err;
  371. sk->sk_error_report(sk);
  372. } else /* Only an error on timeout */
  373. sk->sk_err_soft = err;
  374. out:
  375. bh_unlock_sock(sk);
  376. sock_put(sk);
  377. }
  378. /* This routine computes an IPv4 DCCP checksum. */
  379. void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
  380. {
  381. const struct inet_sock *inet = inet_sk(sk);
  382. struct dccp_hdr *dh = dccp_hdr(skb);
  383. dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, inet->daddr);
  384. }
  385. EXPORT_SYMBOL_GPL(dccp_v4_send_check);
  386. int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code)
  387. {
  388. struct sk_buff *skb;
  389. /*
  390. * FIXME: what if rebuild_header fails?
  391. * Should we be doing a rebuild_header here?
  392. */
  393. int err = inet_sk_rebuild_header(sk);
  394. if (err != 0)
  395. return err;
  396. skb = dccp_make_reset(sk, sk->sk_dst_cache, code);
  397. if (skb != NULL) {
  398. const struct inet_sock *inet = inet_sk(sk);
  399. memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
  400. err = ip_build_and_send_pkt(skb, sk,
  401. inet->saddr, inet->daddr, NULL);
  402. if (err == NET_XMIT_CN)
  403. err = 0;
  404. }
  405. return err;
  406. }
  407. static inline u64 dccp_v4_init_sequence(const struct sock *sk,
  408. const struct sk_buff *skb)
  409. {
  410. return secure_dccp_sequence_number(skb->nh.iph->daddr,
  411. skb->nh.iph->saddr,
  412. dccp_hdr(skb)->dccph_dport,
  413. dccp_hdr(skb)->dccph_sport);
  414. }
  415. int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
  416. {
  417. struct inet_request_sock *ireq;
  418. struct dccp_sock dp;
  419. struct request_sock *req;
  420. struct dccp_request_sock *dreq;
  421. const __u32 saddr = skb->nh.iph->saddr;
  422. const __u32 daddr = skb->nh.iph->daddr;
  423. const __u32 service = dccp_hdr_request(skb)->dccph_req_service;
  424. struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
  425. __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
  426. /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
  427. if (((struct rtable *)skb->dst)->rt_flags &
  428. (RTCF_BROADCAST | RTCF_MULTICAST)) {
  429. reset_code = DCCP_RESET_CODE_NO_CONNECTION;
  430. goto drop;
  431. }
  432. if (dccp_bad_service_code(sk, service)) {
  433. reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
  434. goto drop;
  435. }
  436. /*
  437. * TW buckets are converted to open requests without
  438. * limitations, they conserve resources and peer is
  439. * evidently real one.
  440. */
  441. if (inet_csk_reqsk_queue_is_full(sk))
  442. goto drop;
  443. /*
  444. * Accept backlog is full. If we have already queued enough
  445. * of warm entries in syn queue, drop request. It is better than
  446. * clogging syn queue with openreqs with exponentially increasing
  447. * timeout.
  448. */
  449. if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
  450. goto drop;
  451. req = reqsk_alloc(sk->sk_prot->rsk_prot);
  452. if (req == NULL)
  453. goto drop;
  454. if (dccp_parse_options(sk, skb))
  455. goto drop;
  456. dccp_openreq_init(req, &dp, skb);
  457. ireq = inet_rsk(req);
  458. ireq->loc_addr = daddr;
  459. ireq->rmt_addr = saddr;
  460. req->rcv_wnd = 100; /* Fake, option parsing will get the
  461. right value */
  462. ireq->opt = NULL;
  463. /*
  464. * Step 3: Process LISTEN state
  465. *
  466. * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
  467. *
  468. * In fact we defer setting S.GSR, S.SWL, S.SWH to
  469. * dccp_create_openreq_child.
  470. */
  471. dreq = dccp_rsk(req);
  472. dreq->dreq_isr = dcb->dccpd_seq;
  473. dreq->dreq_iss = dccp_v4_init_sequence(sk, skb);
  474. dreq->dreq_service = service;
  475. if (dccp_v4_send_response(sk, req, NULL))
  476. goto drop_and_free;
  477. inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
  478. return 0;
  479. drop_and_free:
  480. reqsk_free(req);
  481. drop:
  482. DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
  483. dcb->dccpd_reset_code = reset_code;
  484. return -1;
  485. }
  486. EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
  487. /*
  488. * The three way handshake has completed - we got a valid ACK or DATAACK -
  489. * now create the new socket.
  490. *
  491. * This is the equivalent of TCP's tcp_v4_syn_recv_sock
  492. */
  493. struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb,
  494. struct request_sock *req,
  495. struct dst_entry *dst)
  496. {
  497. struct inet_request_sock *ireq;
  498. struct inet_sock *newinet;
  499. struct dccp_sock *newdp;
  500. struct sock *newsk;
  501. if (sk_acceptq_is_full(sk))
  502. goto exit_overflow;
  503. if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
  504. goto exit;
  505. newsk = dccp_create_openreq_child(sk, req, skb);
  506. if (newsk == NULL)
  507. goto exit;
  508. sk_setup_caps(newsk, dst);
  509. newdp = dccp_sk(newsk);
  510. newinet = inet_sk(newsk);
  511. ireq = inet_rsk(req);
  512. newinet->daddr = ireq->rmt_addr;
  513. newinet->rcv_saddr = ireq->loc_addr;
  514. newinet->saddr = ireq->loc_addr;
  515. newinet->opt = ireq->opt;
  516. ireq->opt = NULL;
  517. newinet->mc_index = inet_iif(skb);
  518. newinet->mc_ttl = skb->nh.iph->ttl;
  519. newinet->id = jiffies;
  520. dccp_sync_mss(newsk, dst_mtu(dst));
  521. __inet_hash(&dccp_hashinfo, newsk, 0);
  522. __inet_inherit_port(&dccp_hashinfo, sk, newsk);
  523. return newsk;
  524. exit_overflow:
  525. NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS);
  526. exit:
  527. NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS);
  528. dst_release(dst);
  529. return NULL;
  530. }
  531. EXPORT_SYMBOL_GPL(dccp_v4_request_recv_sock);
  532. static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
  533. {
  534. const struct dccp_hdr *dh = dccp_hdr(skb);
  535. const struct iphdr *iph = skb->nh.iph;
  536. struct sock *nsk;
  537. struct request_sock **prev;
  538. /* Find possible connection requests. */
  539. struct request_sock *req = inet_csk_search_req(sk, &prev,
  540. dh->dccph_sport,
  541. iph->saddr, iph->daddr);
  542. if (req != NULL)
  543. return dccp_check_req(sk, skb, req, prev);
  544. nsk = __inet_lookup_established(&dccp_hashinfo,
  545. iph->saddr, dh->dccph_sport,
  546. iph->daddr, ntohs(dh->dccph_dport),
  547. inet_iif(skb));
  548. if (nsk != NULL) {
  549. if (nsk->sk_state != DCCP_TIME_WAIT) {
  550. bh_lock_sock(nsk);
  551. return nsk;
  552. }
  553. inet_twsk_put((struct inet_timewait_sock *)nsk);
  554. return NULL;
  555. }
  556. return sk;
  557. }
  558. int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr,
  559. const u32 daddr)
  560. {
  561. const struct dccp_hdr* dh = dccp_hdr(skb);
  562. int checksum_len;
  563. u32 tmp;
  564. if (dh->dccph_cscov == 0)
  565. checksum_len = skb->len;
  566. else {
  567. checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
  568. checksum_len = checksum_len < skb->len ? checksum_len :
  569. skb->len;
  570. }
  571. tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
  572. return csum_tcpudp_magic(saddr, daddr, checksum_len,
  573. IPPROTO_DCCP, tmp);
  574. }
  575. static int dccp_v4_verify_checksum(struct sk_buff *skb,
  576. const u32 saddr, const u32 daddr)
  577. {
  578. struct dccp_hdr *dh = dccp_hdr(skb);
  579. int checksum_len;
  580. u32 tmp;
  581. if (dh->dccph_cscov == 0)
  582. checksum_len = skb->len;
  583. else {
  584. checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
  585. checksum_len = checksum_len < skb->len ? checksum_len :
  586. skb->len;
  587. }
  588. tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
  589. return csum_tcpudp_magic(saddr, daddr, checksum_len,
  590. IPPROTO_DCCP, tmp) == 0 ? 0 : -1;
  591. }
  592. static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
  593. struct sk_buff *skb)
  594. {
  595. struct rtable *rt;
  596. struct flowi fl = { .oif = ((struct rtable *)skb->dst)->rt_iif,
  597. .nl_u = { .ip4_u =
  598. { .daddr = skb->nh.iph->saddr,
  599. .saddr = skb->nh.iph->daddr,
  600. .tos = RT_CONN_FLAGS(sk) } },
  601. .proto = sk->sk_protocol,
  602. .uli_u = { .ports =
  603. { .sport = dccp_hdr(skb)->dccph_dport,
  604. .dport = dccp_hdr(skb)->dccph_sport }
  605. }
  606. };
  607. if (ip_route_output_flow(&rt, &fl, sk, 0)) {
  608. IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  609. return NULL;
  610. }
  611. return &rt->u.dst;
  612. }
  613. static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
  614. {
  615. int err;
  616. struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
  617. const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
  618. sizeof(struct dccp_hdr_ext) +
  619. sizeof(struct dccp_hdr_reset);
  620. struct sk_buff *skb;
  621. struct dst_entry *dst;
  622. u64 seqno;
  623. /* Never send a reset in response to a reset. */
  624. if (rxdh->dccph_type == DCCP_PKT_RESET)
  625. return;
  626. if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
  627. return;
  628. dst = dccp_v4_route_skb(dccp_ctl_socket->sk, rxskb);
  629. if (dst == NULL)
  630. return;
  631. skb = alloc_skb(MAX_DCCP_HEADER + 15, GFP_ATOMIC);
  632. if (skb == NULL)
  633. goto out;
  634. /* Reserve space for headers. */
  635. skb_reserve(skb, MAX_DCCP_HEADER);
  636. skb->dst = dst_clone(dst);
  637. skb->h.raw = skb_push(skb, dccp_hdr_reset_len);
  638. dh = dccp_hdr(skb);
  639. memset(dh, 0, dccp_hdr_reset_len);
  640. /* Build DCCP header and checksum it. */
  641. dh->dccph_type = DCCP_PKT_RESET;
  642. dh->dccph_sport = rxdh->dccph_dport;
  643. dh->dccph_dport = rxdh->dccph_sport;
  644. dh->dccph_doff = dccp_hdr_reset_len / 4;
  645. dh->dccph_x = 1;
  646. dccp_hdr_reset(skb)->dccph_reset_code =
  647. DCCP_SKB_CB(rxskb)->dccpd_reset_code;
  648. /* See "8.3.1. Abnormal Termination" in draft-ietf-dccp-spec-11 */
  649. seqno = 0;
  650. if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
  651. dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
  652. dccp_hdr_set_seq(dh, seqno);
  653. dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
  654. DCCP_SKB_CB(rxskb)->dccpd_seq);
  655. dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr,
  656. rxskb->nh.iph->daddr);
  657. bh_lock_sock(dccp_ctl_socket->sk);
  658. err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
  659. rxskb->nh.iph->daddr,
  660. rxskb->nh.iph->saddr, NULL);
  661. bh_unlock_sock(dccp_ctl_socket->sk);
  662. if (err == NET_XMIT_CN || err == 0) {
  663. DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
  664. DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
  665. }
  666. out:
  667. dst_release(dst);
  668. }
  669. int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
  670. {
  671. struct dccp_hdr *dh = dccp_hdr(skb);
  672. if (sk->sk_state == DCCP_OPEN) { /* Fast path */
  673. if (dccp_rcv_established(sk, skb, dh, skb->len))
  674. goto reset;
  675. return 0;
  676. }
  677. /*
  678. * Step 3: Process LISTEN state
  679. * If S.state == LISTEN,
  680. * If P.type == Request or P contains a valid Init Cookie
  681. * option,
  682. * * Must scan the packet's options to check for an Init
  683. * Cookie. Only the Init Cookie is processed here,
  684. * however; other options are processed in Step 8. This
  685. * scan need only be performed if the endpoint uses Init
  686. * Cookies *
  687. * * Generate a new socket and switch to that socket *
  688. * Set S := new socket for this port pair
  689. * S.state = RESPOND
  690. * Choose S.ISS (initial seqno) or set from Init Cookie
  691. * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
  692. * Continue with S.state == RESPOND
  693. * * A Response packet will be generated in Step 11 *
  694. * Otherwise,
  695. * Generate Reset(No Connection) unless P.type == Reset
  696. * Drop packet and return
  697. *
  698. * NOTE: the check for the packet types is done in
  699. * dccp_rcv_state_process
  700. */
  701. if (sk->sk_state == DCCP_LISTEN) {
  702. struct sock *nsk = dccp_v4_hnd_req(sk, skb);
  703. if (nsk == NULL)
  704. goto discard;
  705. if (nsk != sk) {
  706. if (dccp_child_process(sk, nsk, skb))
  707. goto reset;
  708. return 0;
  709. }
  710. }
  711. if (dccp_rcv_state_process(sk, skb, dh, skb->len))
  712. goto reset;
  713. return 0;
  714. reset:
  715. dccp_v4_ctl_send_reset(skb);
  716. discard:
  717. kfree_skb(skb);
  718. return 0;
  719. }
  720. EXPORT_SYMBOL_GPL(dccp_v4_do_rcv);
  721. int dccp_invalid_packet(struct sk_buff *skb)
  722. {
  723. const struct dccp_hdr *dh;
  724. if (skb->pkt_type != PACKET_HOST)
  725. return 1;
  726. if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) {
  727. LIMIT_NETDEBUG(KERN_WARNING "DCCP: pskb_may_pull failed\n");
  728. return 1;
  729. }
  730. dh = dccp_hdr(skb);
  731. /* If the packet type is not understood, drop packet and return */
  732. if (dh->dccph_type >= DCCP_PKT_INVALID) {
  733. LIMIT_NETDEBUG(KERN_WARNING "DCCP: invalid packet type\n");
  734. return 1;
  735. }
  736. /*
  737. * If P.Data Offset is too small for packet type, or too large for
  738. * packet, drop packet and return
  739. */
  740. if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
  741. LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.Data Offset(%u) "
  742. "too small 1\n",
  743. dh->dccph_doff);
  744. return 1;
  745. }
  746. if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
  747. LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.Data Offset(%u) "
  748. "too small 2\n",
  749. dh->dccph_doff);
  750. return 1;
  751. }
  752. dh = dccp_hdr(skb);
  753. /*
  754. * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
  755. * has short sequence numbers), drop packet and return
  756. */
  757. if (dh->dccph_x == 0 &&
  758. dh->dccph_type != DCCP_PKT_DATA &&
  759. dh->dccph_type != DCCP_PKT_ACK &&
  760. dh->dccph_type != DCCP_PKT_DATAACK) {
  761. LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.type (%s) not Data, Ack "
  762. "nor DataAck and P.X == 0\n",
  763. dccp_packet_name(dh->dccph_type));
  764. return 1;
  765. }
  766. return 0;
  767. }
  768. EXPORT_SYMBOL_GPL(dccp_invalid_packet);
  769. /* this is called when real data arrives */
  770. int dccp_v4_rcv(struct sk_buff *skb)
  771. {
  772. const struct dccp_hdr *dh;
  773. struct sock *sk;
  774. /* Step 1: Check header basics: */
  775. if (dccp_invalid_packet(skb))
  776. goto discard_it;
  777. /* If the header checksum is incorrect, drop packet and return */
  778. if (dccp_v4_verify_checksum(skb, skb->nh.iph->saddr,
  779. skb->nh.iph->daddr) < 0) {
  780. LIMIT_NETDEBUG(KERN_WARNING "%s: incorrect header checksum\n",
  781. __FUNCTION__);
  782. goto discard_it;
  783. }
  784. dh = dccp_hdr(skb);
  785. DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
  786. DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
  787. dccp_pr_debug("%8.8s "
  788. "src=%u.%u.%u.%u@%-5d "
  789. "dst=%u.%u.%u.%u@%-5d seq=%llu",
  790. dccp_packet_name(dh->dccph_type),
  791. NIPQUAD(skb->nh.iph->saddr), ntohs(dh->dccph_sport),
  792. NIPQUAD(skb->nh.iph->daddr), ntohs(dh->dccph_dport),
  793. (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
  794. if (dccp_packet_without_ack(skb)) {
  795. DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
  796. dccp_pr_debug_cat("\n");
  797. } else {
  798. DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
  799. dccp_pr_debug_cat(", ack=%llu\n",
  800. (unsigned long long)
  801. DCCP_SKB_CB(skb)->dccpd_ack_seq);
  802. }
  803. /* Step 2:
  804. * Look up flow ID in table and get corresponding socket */
  805. sk = __inet_lookup(&dccp_hashinfo,
  806. skb->nh.iph->saddr, dh->dccph_sport,
  807. skb->nh.iph->daddr, ntohs(dh->dccph_dport),
  808. inet_iif(skb));
  809. /*
  810. * Step 2:
  811. * If no socket ...
  812. * Generate Reset(No Connection) unless P.type == Reset
  813. * Drop packet and return
  814. */
  815. if (sk == NULL) {
  816. dccp_pr_debug("failed to look up flow ID in table and "
  817. "get corresponding socket\n");
  818. goto no_dccp_socket;
  819. }
  820. /*
  821. * Step 2:
  822. * ... or S.state == TIMEWAIT,
  823. * Generate Reset(No Connection) unless P.type == Reset
  824. * Drop packet and return
  825. */
  826. if (sk->sk_state == DCCP_TIME_WAIT) {
  827. dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: "
  828. "do_time_wait\n");
  829. goto do_time_wait;
  830. }
  831. if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
  832. goto discard_and_relse;
  833. nf_reset(skb);
  834. return sk_receive_skb(sk, skb);
  835. no_dccp_socket:
  836. if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
  837. goto discard_it;
  838. /*
  839. * Step 2:
  840. * Generate Reset(No Connection) unless P.type == Reset
  841. * Drop packet and return
  842. */
  843. if (dh->dccph_type != DCCP_PKT_RESET) {
  844. DCCP_SKB_CB(skb)->dccpd_reset_code =
  845. DCCP_RESET_CODE_NO_CONNECTION;
  846. dccp_v4_ctl_send_reset(skb);
  847. }
  848. discard_it:
  849. /* Discard frame. */
  850. kfree_skb(skb);
  851. return 0;
  852. discard_and_relse:
  853. sock_put(sk);
  854. goto discard_it;
  855. do_time_wait:
  856. inet_twsk_put((struct inet_timewait_sock *)sk);
  857. goto no_dccp_socket;
  858. }
  859. struct inet_connection_sock_af_ops dccp_ipv4_af_ops = {
  860. .queue_xmit = ip_queue_xmit,
  861. .send_check = dccp_v4_send_check,
  862. .rebuild_header = inet_sk_rebuild_header,
  863. .conn_request = dccp_v4_conn_request,
  864. .syn_recv_sock = dccp_v4_request_recv_sock,
  865. .net_header_len = sizeof(struct iphdr),
  866. .setsockopt = ip_setsockopt,
  867. .getsockopt = ip_getsockopt,
  868. .addr2sockaddr = inet_csk_addr2sockaddr,
  869. .sockaddr_len = sizeof(struct sockaddr_in),
  870. };
  871. int dccp_v4_init_sock(struct sock *sk)
  872. {
  873. struct dccp_sock *dp = dccp_sk(sk);
  874. struct inet_connection_sock *icsk = inet_csk(sk);
  875. static int dccp_ctl_socket_init = 1;
  876. dccp_options_init(&dp->dccps_options);
  877. do_gettimeofday(&dp->dccps_epoch);
  878. /*
  879. * FIXME: We're hardcoding the CCID, and doing this at this point makes
  880. * the listening (master) sock get CCID control blocks, which is not
  881. * necessary, but for now, to not mess with the test userspace apps,
  882. * lets leave it here, later the real solution is to do this in a
  883. * setsockopt(CCIDs-I-want/accept). -acme
  884. */
  885. if (likely(!dccp_ctl_socket_init)) {
  886. int rc;
  887. if (dp->dccps_options.dccpo_send_ack_vector) {
  888. dp->dccps_hc_rx_ackvec = dccp_ackvec_alloc(GFP_KERNEL);
  889. if (dp->dccps_hc_rx_ackvec == NULL)
  890. return -ENOMEM;
  891. }
  892. dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_rx_ccid,
  893. sk);
  894. dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_tx_ccid,
  895. sk);
  896. if (dp->dccps_hc_rx_ccid == NULL ||
  897. dp->dccps_hc_tx_ccid == NULL) {
  898. ccid_exit(dp->dccps_hc_rx_ccid, sk);
  899. ccid_exit(dp->dccps_hc_tx_ccid, sk);
  900. if (dp->dccps_options.dccpo_send_ack_vector) {
  901. dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
  902. dp->dccps_hc_rx_ackvec = NULL;
  903. }
  904. dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
  905. return -ENOMEM;
  906. }
  907. rc = dccp_feat_init(sk);
  908. if (rc)
  909. return rc;
  910. } else {
  911. /* control socket doesn't need feat nego */
  912. INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending);
  913. INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf);
  914. dccp_ctl_socket_init = 0;
  915. }
  916. dccp_init_xmit_timers(sk);
  917. icsk->icsk_rto = DCCP_TIMEOUT_INIT;
  918. sk->sk_state = DCCP_CLOSED;
  919. sk->sk_write_space = dccp_write_space;
  920. icsk->icsk_af_ops = &dccp_ipv4_af_ops;
  921. icsk->icsk_sync_mss = dccp_sync_mss;
  922. dp->dccps_mss_cache = 536;
  923. dp->dccps_role = DCCP_ROLE_UNDEFINED;
  924. dp->dccps_service = DCCP_SERVICE_INVALID_VALUE;
  925. dp->dccps_l_ack_ratio = dp->dccps_r_ack_ratio = 1;
  926. return 0;
  927. }
  928. EXPORT_SYMBOL_GPL(dccp_v4_init_sock);
  929. int dccp_v4_destroy_sock(struct sock *sk)
  930. {
  931. struct dccp_sock *dp = dccp_sk(sk);
  932. /*
  933. * DCCP doesn't use sk_write_queue, just sk_send_head
  934. * for retransmissions
  935. */
  936. if (sk->sk_send_head != NULL) {
  937. kfree_skb(sk->sk_send_head);
  938. sk->sk_send_head = NULL;
  939. }
  940. /* Clean up a referenced DCCP bind bucket. */
  941. if (inet_csk(sk)->icsk_bind_hash != NULL)
  942. inet_put_port(&dccp_hashinfo, sk);
  943. kfree(dp->dccps_service_list);
  944. dp->dccps_service_list = NULL;
  945. ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
  946. ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
  947. if (dp->dccps_options.dccpo_send_ack_vector) {
  948. dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
  949. dp->dccps_hc_rx_ackvec = NULL;
  950. }
  951. ccid_exit(dp->dccps_hc_rx_ccid, sk);
  952. ccid_exit(dp->dccps_hc_tx_ccid, sk);
  953. dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
  954. /* clean up feature negotiation state */
  955. dccp_feat_clean(sk);
  956. return 0;
  957. }
  958. EXPORT_SYMBOL_GPL(dccp_v4_destroy_sock);
  959. static void dccp_v4_reqsk_destructor(struct request_sock *req)
  960. {
  961. kfree(inet_rsk(req)->opt);
  962. }
  963. static struct request_sock_ops dccp_request_sock_ops = {
  964. .family = PF_INET,
  965. .obj_size = sizeof(struct dccp_request_sock),
  966. .rtx_syn_ack = dccp_v4_send_response,
  967. .send_ack = dccp_v4_reqsk_send_ack,
  968. .destructor = dccp_v4_reqsk_destructor,
  969. .send_reset = dccp_v4_ctl_send_reset,
  970. };
  971. static struct timewait_sock_ops dccp_timewait_sock_ops = {
  972. .twsk_obj_size = sizeof(struct inet_timewait_sock),
  973. };
  974. struct proto dccp_prot = {
  975. .name = "DCCP",
  976. .owner = THIS_MODULE,
  977. .close = dccp_close,
  978. .connect = dccp_v4_connect,
  979. .disconnect = dccp_disconnect,
  980. .ioctl = dccp_ioctl,
  981. .init = dccp_v4_init_sock,
  982. .setsockopt = dccp_setsockopt,
  983. .getsockopt = dccp_getsockopt,
  984. .sendmsg = dccp_sendmsg,
  985. .recvmsg = dccp_recvmsg,
  986. .backlog_rcv = dccp_v4_do_rcv,
  987. .hash = dccp_v4_hash,
  988. .unhash = dccp_unhash,
  989. .accept = inet_csk_accept,
  990. .get_port = dccp_v4_get_port,
  991. .shutdown = dccp_shutdown,
  992. .destroy = dccp_v4_destroy_sock,
  993. .orphan_count = &dccp_orphan_count,
  994. .max_header = MAX_DCCP_HEADER,
  995. .obj_size = sizeof(struct dccp_sock),
  996. .rsk_prot = &dccp_request_sock_ops,
  997. .twsk_prot = &dccp_timewait_sock_ops,
  998. };
  999. EXPORT_SYMBOL_GPL(dccp_prot);