2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
33 #include "opt_inet6.h"
34 #include "opt_ipsec.h"
37 #include <sys/param.h>
39 #include <sys/kernel.h>
42 #include <sys/malloc.h>
45 #include <sys/protosw.h>
46 #include <sys/signalvar.h>
47 #include <sys/socket.h>
48 #include <sys/socketvar.h>
50 #include <sys/sysctl.h>
51 #include <sys/systm.h>
56 #include <net/route.h>
58 #include <netinet/in.h>
59 #include <netinet/in_systm.h>
60 #include <netinet/in_pcb.h>
61 #include <netinet/in_var.h>
62 #include <netinet/ip.h>
63 #include <netinet/ip_var.h>
64 #include <netinet/ip_mroute.h>
66 #include <netinet/ip_fw.h>
67 #include <netinet/ip_dummynet.h>
70 #include <netipsec/ipsec.h>
74 #include <netinet6/ipsec.h>
77 struct inpcbhead ripcb;
78 struct inpcbinfo ripcbinfo;
80 /* control hooks for ipfw and dummynet */
81 ip_fw_ctl_t *ip_fw_ctl_ptr = NULL;
82 ip_dn_ctl_t *ip_dn_ctl_ptr = NULL;
85 * hooks for multicast routing. They all default to NULL,
86 * so leave them not initialized and rely on BSS being set to 0.
89 /* The socket used to communicate with the multicast routing daemon. */
90 struct socket *ip_mrouter;
92 /* The various mrouter and rsvp functions */
93 int (*ip_mrouter_set)(struct socket *, struct sockopt *);
94 int (*ip_mrouter_get)(struct socket *, struct sockopt *);
95 int (*ip_mrouter_done)(void);
96 int (*ip_mforward)(struct ip *, struct ifnet *, struct mbuf *,
97 struct ip_moptions *);
98 int (*mrt_ioctl)(int, caddr_t);
99 int (*legal_vif_num)(int);
100 u_long (*ip_mcast_src)(int);
102 void (*rsvp_input_p)(struct mbuf *m, int off);
103 int (*ip_rsvp_vif)(struct socket *, struct sockopt *);
104 void (*ip_rsvp_force_done)(struct socket *);
107 * Nominal space allocated to a raw ip socket.
113 * Raw interface to IP protocol.
117 * Initialize raw connection block q.
120 rip_zone_change(void *tag)
123 uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
127 rip_inpcb_init(void *mem, int size, int flags)
129 struct inpcb *inp = (struct inpcb *) mem;
130 INP_LOCK_INIT(inp, "inp", "rawinp");
137 INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
139 ripcbinfo.listhead = &ripcb;
141 * XXX We don't use the hash list for raw IP, but it's easier
142 * to allocate a one entry hash list than it is to check all
143 * over the place for hashbase == NULL.
145 ripcbinfo.hashbase = hashinit(1, M_PCB, &ripcbinfo.hashmask);
146 ripcbinfo.porthashbase = hashinit(1, M_PCB, &ripcbinfo.porthashmask);
147 ripcbinfo.ipi_zone = uma_zcreate("ripcb", sizeof(struct inpcb),
148 NULL, NULL, rip_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
149 uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
150 EVENTHANDLER_REGISTER(maxsockets_change, rip_zone_change,
151 NULL, EVENTHANDLER_PRI_ANY);
154 static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
157 raw_append(struct inpcb *last, struct ip *ip, struct mbuf *n)
161 INP_LOCK_ASSERT(last);
163 #if defined(IPSEC) || defined(FAST_IPSEC)
164 /* check AH/ESP integrity. */
165 if (ipsec4_in_reject(n, last)) {
168 ipsecstat.in_polvio++;
170 /* do not inject data to pcb */
172 #endif /*IPSEC || FAST_IPSEC*/
174 if (!policyfail && mac_check_inpcb_deliver(last, n) != 0)
177 /* Check the minimum TTL for socket. */
178 if (last->inp_ip_minttl && last->inp_ip_minttl > ip->ip_ttl)
181 struct mbuf *opts = NULL;
184 so = last->inp_socket;
185 if ((last->inp_flags & INP_CONTROLOPTS) ||
186 (so->so_options & (SO_TIMESTAMP | SO_BINTIME)))
187 ip_savecontrol(last, &opts, ip, n);
188 SOCKBUF_LOCK(&so->so_rcv);
189 if (sbappendaddr_locked(&so->so_rcv,
190 (struct sockaddr *)&ripsrc, n, opts) == 0) {
191 /* should notify about lost packet */
195 SOCKBUF_UNLOCK(&so->so_rcv);
197 sorwakeup_locked(so);
204 * Setup generic address and protocol structures
205 * for raw_input routine, then pass them along with
209 rip_input(struct mbuf *m, int off)
211 struct ip *ip = mtod(m, struct ip *);
212 int proto = ip->ip_p;
213 struct inpcb *inp, *last;
215 INP_INFO_RLOCK(&ripcbinfo);
216 ripsrc.sin_addr = ip->ip_src;
218 LIST_FOREACH(inp, &ripcb, inp_list) {
220 if (inp->inp_ip_p && inp->inp_ip_p != proto) {
226 if ((inp->inp_vflag & INP_IPV4) == 0)
229 if (inp->inp_laddr.s_addr &&
230 inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
232 if (inp->inp_faddr.s_addr &&
233 inp->inp_faddr.s_addr != ip->ip_src.s_addr)
235 if (jailed(inp->inp_socket->so_cred))
236 if (htonl(prison_getip(inp->inp_socket->so_cred)) !=
242 n = m_copy(m, 0, (int)M_COPYALL);
244 (void) raw_append(last, ip, n);
245 /* XXX count dropped packet */
251 if (raw_append(last, ip, m) != 0)
252 ipstat.ips_delivered--;
256 ipstat.ips_noproto++;
257 ipstat.ips_delivered--;
259 INP_INFO_RUNLOCK(&ripcbinfo);
263 * Generate IP header and pass packet to ip_output.
264 * Tack on options user may have setup with control call.
267 rip_output(struct mbuf *m, struct socket *so, u_long dst)
271 struct inpcb *inp = sotoinpcb(so);
272 int flags = ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0) |
276 * If the user handed us a complete IP packet, use it.
277 * Otherwise, allocate an mbuf for a header and fill it in.
279 if ((inp->inp_flags & INP_HDRINCL) == 0) {
280 if (m->m_pkthdr.len + sizeof(struct ip) > IP_MAXPACKET) {
284 M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
289 ip = mtod(m, struct ip *);
290 ip->ip_tos = inp->inp_ip_tos;
291 if (inp->inp_flags & INP_DONTFRAG)
295 ip->ip_p = inp->inp_ip_p;
296 ip->ip_len = m->m_pkthdr.len;
297 if (jailed(inp->inp_socket->so_cred))
299 htonl(prison_getip(inp->inp_socket->so_cred));
301 ip->ip_src = inp->inp_laddr;
302 ip->ip_dst.s_addr = dst;
303 ip->ip_ttl = inp->inp_ip_ttl;
305 if (m->m_pkthdr.len > IP_MAXPACKET) {
310 ip = mtod(m, struct ip *);
311 if (jailed(inp->inp_socket->so_cred)) {
312 if (ip->ip_src.s_addr !=
313 htonl(prison_getip(inp->inp_socket->so_cred))) {
319 /* don't allow both user specified and setsockopt options,
320 and don't allow packet length sizes that will crash */
321 if (((ip->ip_hl != (sizeof (*ip) >> 2))
323 || (ip->ip_len > m->m_pkthdr.len)
324 || (ip->ip_len < (ip->ip_hl << 2))) {
330 ip->ip_id = ip_newid();
331 /* XXX prevent ip_output from overwriting header fields */
332 flags |= IP_RAWOUTPUT;
336 if (inp->inp_flags & INP_ONESBCAST)
337 flags |= IP_SENDONES;
340 mac_create_mbuf_from_inpcb(inp, m);
343 error = ip_output(m, inp->inp_options, NULL, flags,
344 inp->inp_moptions, inp);
350 * Raw IP socket option processing.
352 * IMPORTANT NOTE regarding access control: Traditionally, raw sockets could
353 * only be created by a privileged process, and as such, socket option
354 * operations to manage system properties on any raw socket were allowed to
355 * take place without explicit additional access control checks. However,
356 * raw sockets can now also be created in jail(), and therefore explicit
357 * checks are now required. Likewise, raw sockets can be used by a process
358 * after it gives up privilege, so some caution is required. For options
359 * passed down to the IP layer via ip_ctloutput(), checks are assumed to be
360 * performed in ip_ctloutput() and therefore no check occurs here.
361 * Unilaterally checking suser() here breaks normal IP socket option
362 * operations on raw sockets.
364 * When adding new socket options here, make sure to add access control
365 * checks here as necessary.
368 rip_ctloutput(struct socket *so, struct sockopt *sopt)
370 struct inpcb *inp = sotoinpcb(so);
373 if (sopt->sopt_level != IPPROTO_IP)
377 switch (sopt->sopt_dir) {
379 switch (sopt->sopt_name) {
381 optval = inp->inp_flags & INP_HDRINCL;
382 error = sooptcopyout(sopt, &optval, sizeof optval);
385 case IP_FW_ADD: /* ADD actually returns the body... */
387 case IP_FW_TABLE_GETSIZE:
388 case IP_FW_TABLE_LIST:
389 error = suser(curthread);
392 if (ip_fw_ctl_ptr != NULL)
393 error = ip_fw_ctl_ptr(sopt);
398 case IP_DUMMYNET_GET:
399 error = suser(curthread);
402 if (ip_dn_ctl_ptr != NULL)
403 error = ip_dn_ctl_ptr(sopt);
416 case MRT_API_SUPPORT:
418 case MRT_ADD_BW_UPCALL:
419 case MRT_DEL_BW_UPCALL:
420 error = suser(curthread);
423 error = ip_mrouter_get ? ip_mrouter_get(so, sopt) :
428 error = ip_ctloutput(so, sopt);
434 switch (sopt->sopt_name) {
436 error = sooptcopyin(sopt, &optval, sizeof optval,
441 inp->inp_flags |= INP_HDRINCL;
443 inp->inp_flags &= ~INP_HDRINCL;
451 case IP_FW_TABLE_ADD:
452 case IP_FW_TABLE_DEL:
453 case IP_FW_TABLE_FLUSH:
454 error = suser(curthread);
457 if (ip_fw_ctl_ptr != NULL)
458 error = ip_fw_ctl_ptr(sopt);
463 case IP_DUMMYNET_CONFIGURE:
464 case IP_DUMMYNET_DEL:
465 case IP_DUMMYNET_FLUSH:
466 error = suser(curthread);
469 if (ip_dn_ctl_ptr != NULL)
470 error = ip_dn_ctl_ptr(sopt);
472 error = ENOPROTOOPT ;
476 error = suser(curthread);
479 error = ip_rsvp_init(so);
483 error = suser(curthread);
486 error = ip_rsvp_done();
490 case IP_RSVP_VIF_OFF:
491 error = suser(curthread);
494 error = ip_rsvp_vif ?
495 ip_rsvp_vif(so, sopt) : EINVAL;
506 case MRT_API_SUPPORT:
508 case MRT_ADD_BW_UPCALL:
509 case MRT_DEL_BW_UPCALL:
510 error = suser(curthread);
513 error = ip_mrouter_set ? ip_mrouter_set(so, sopt) :
518 error = ip_ctloutput(so, sopt);
528 * This function exists solely to receive the PRC_IFDOWN messages which
529 * are sent by if_down(). It looks for an ifaddr whose ifa_addr is sa,
530 * and calls in_ifadown() to remove all routes corresponding to that address.
531 * It also receives the PRC_IFUP messages from if_up() and reinstalls the
535 rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
537 struct in_ifaddr *ia;
544 TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
545 if (ia->ia_ifa.ifa_addr == sa
546 && (ia->ia_flags & IFA_ROUTE)) {
548 * in_ifscrub kills the interface route.
550 in_ifscrub(ia->ia_ifp, ia);
552 * in_ifadown gets rid of all the rest of
553 * the routes. This is not quite the right
554 * thing to do, but at least if we are running
555 * a routing process they will come back.
557 in_ifadown(&ia->ia_ifa, 0);
564 TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
565 if (ia->ia_ifa.ifa_addr == sa)
568 if (ia == 0 || (ia->ia_flags & IFA_ROUTE))
571 ifp = ia->ia_ifa.ifa_ifp;
573 if ((ifp->if_flags & IFF_LOOPBACK)
574 || (ifp->if_flags & IFF_POINTOPOINT))
577 err = rtinit(&ia->ia_ifa, RTM_ADD, flags);
579 ia->ia_flags |= IFA_ROUTE;
584 u_long rip_sendspace = RIPSNDQ;
585 u_long rip_recvspace = RIPRCVQ;
587 SYSCTL_ULONG(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW,
588 &rip_sendspace, 0, "Maximum outgoing raw IP datagram size");
589 SYSCTL_ULONG(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
590 &rip_recvspace, 0, "Maximum space for incoming raw IP datagrams");
593 rip_attach(struct socket *so, int proto, struct thread *td)
599 KASSERT(inp == NULL, ("rip_attach: inp != NULL"));
600 if (jailed(td->td_ucred) && !jail_allow_raw_sockets)
602 if ((error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)) != 0)
604 if (proto >= IPPROTO_MAX || proto < 0)
605 return EPROTONOSUPPORT;
606 error = soreserve(so, rip_sendspace, rip_recvspace);
609 INP_INFO_WLOCK(&ripcbinfo);
610 error = in_pcballoc(so, &ripcbinfo);
612 INP_INFO_WUNLOCK(&ripcbinfo);
615 inp = (struct inpcb *)so->so_pcb;
616 INP_INFO_WUNLOCK(&ripcbinfo);
617 inp->inp_vflag |= INP_IPV4;
618 inp->inp_ip_p = proto;
619 inp->inp_ip_ttl = ip_defttl;
625 rip_detach(struct socket *so)
630 KASSERT(inp != NULL, ("rip_detach: inp == NULL"));
631 KASSERT(inp->inp_faddr.s_addr == INADDR_ANY,
632 ("rip_detach: not closed"));
634 INP_INFO_WLOCK(&ripcbinfo);
636 if (so == ip_mrouter && ip_mrouter_done)
638 if (ip_rsvp_force_done)
639 ip_rsvp_force_done(so);
644 INP_INFO_WUNLOCK(&ripcbinfo);
648 rip_dodisconnect(struct socket *so, struct inpcb *inp)
651 INP_LOCK_ASSERT(inp);
653 inp->inp_faddr.s_addr = INADDR_ANY;
655 so->so_state &= ~SS_ISCONNECTED;
660 rip_abort(struct socket *so)
665 KASSERT(inp != NULL, ("rip_abort: inp == NULL"));
667 INP_INFO_WLOCK(&ripcbinfo);
669 rip_dodisconnect(so, inp);
671 INP_INFO_WUNLOCK(&ripcbinfo);
675 rip_close(struct socket *so)
680 KASSERT(inp != NULL, ("rip_close: inp == NULL"));
682 INP_INFO_WLOCK(&ripcbinfo);
684 rip_dodisconnect(so, inp);
686 INP_INFO_WUNLOCK(&ripcbinfo);
690 rip_disconnect(struct socket *so)
694 if ((so->so_state & SS_ISCONNECTED) == 0)
698 KASSERT(inp != NULL, ("rip_disconnect: inp == NULL"));
699 INP_INFO_WLOCK(&ripcbinfo);
701 rip_dodisconnect(so, inp);
703 INP_INFO_WUNLOCK(&ripcbinfo);
708 rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
710 struct sockaddr_in *addr = (struct sockaddr_in *)nam;
713 if (nam->sa_len != sizeof(*addr))
716 if (jailed(td->td_ucred)) {
717 if (addr->sin_addr.s_addr == INADDR_ANY)
718 addr->sin_addr.s_addr =
719 htonl(prison_getip(td->td_ucred));
720 if (htonl(prison_getip(td->td_ucred)) != addr->sin_addr.s_addr)
721 return (EADDRNOTAVAIL);
724 if (TAILQ_EMPTY(&ifnet) ||
725 (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) ||
726 (addr->sin_addr.s_addr &&
727 ifa_ifwithaddr((struct sockaddr *)addr) == 0))
728 return EADDRNOTAVAIL;
731 KASSERT(inp != NULL, ("rip_bind: inp == NULL"));
732 INP_INFO_WLOCK(&ripcbinfo);
734 inp->inp_laddr = addr->sin_addr;
736 INP_INFO_WUNLOCK(&ripcbinfo);
741 rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
743 struct sockaddr_in *addr = (struct sockaddr_in *)nam;
746 if (nam->sa_len != sizeof(*addr))
748 if (TAILQ_EMPTY(&ifnet))
749 return EADDRNOTAVAIL;
750 if (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK)
754 KASSERT(inp != NULL, ("rip_connect: inp == NULL"));
755 INP_INFO_WLOCK(&ripcbinfo);
757 inp->inp_faddr = addr->sin_addr;
760 INP_INFO_WUNLOCK(&ripcbinfo);
765 rip_shutdown(struct socket *so)
770 KASSERT(inp != NULL, ("rip_shutdown: inp == NULL"));
778 rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
779 struct mbuf *control, struct thread *td)
785 KASSERT(inp != NULL, ("rip_send: inp == NULL"));
787 * Note: 'dst' reads below are unlocked.
789 if (so->so_state & SS_ISCONNECTED) {
794 dst = inp->inp_faddr.s_addr; /* Unlocked read. */
800 dst = ((struct sockaddr_in *)nam)->sin_addr.s_addr;
802 return rip_output(m, so, dst);
806 rip_pcblist(SYSCTL_HANDLER_ARGS)
809 struct inpcb *inp, **inp_list;
814 * The process of preparing the TCB list is too time-consuming and
815 * resource-intensive to repeat twice on every request.
817 if (req->oldptr == 0) {
818 n = ripcbinfo.ipi_count;
819 req->oldidx = 2 * (sizeof xig)
820 + (n + n/8) * sizeof(struct xinpcb);
824 if (req->newptr != 0)
828 * OK, now we're committed to doing something.
830 INP_INFO_RLOCK(&ripcbinfo);
831 gencnt = ripcbinfo.ipi_gencnt;
832 n = ripcbinfo.ipi_count;
833 INP_INFO_RUNLOCK(&ripcbinfo);
835 xig.xig_len = sizeof xig;
837 xig.xig_gen = gencnt;
838 xig.xig_sogen = so_gencnt;
839 error = SYSCTL_OUT(req, &xig, sizeof xig);
843 inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
847 INP_INFO_RLOCK(&ripcbinfo);
848 for (inp = LIST_FIRST(ripcbinfo.listhead), i = 0; inp && i < n;
849 inp = LIST_NEXT(inp, inp_list)) {
851 if (inp->inp_gencnt <= gencnt &&
852 cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0) {
853 /* XXX held references? */
858 INP_INFO_RUNLOCK(&ripcbinfo);
862 for (i = 0; i < n; i++) {
865 if (inp->inp_gencnt <= gencnt) {
867 bzero(&xi, sizeof(xi));
868 xi.xi_len = sizeof xi;
869 /* XXX should avoid extra copy */
870 bcopy(inp, &xi.xi_inp, sizeof *inp);
872 sotoxsocket(inp->inp_socket, &xi.xi_socket);
874 error = SYSCTL_OUT(req, &xi, sizeof xi);
880 * Give the user an updated idea of our state.
881 * If the generation differs from what we told
882 * her before, she knows that something happened
883 * while we were processing this request, and it
884 * might be necessary to retry.
886 INP_INFO_RLOCK(&ripcbinfo);
887 xig.xig_gen = ripcbinfo.ipi_gencnt;
888 xig.xig_sogen = so_gencnt;
889 xig.xig_count = ripcbinfo.ipi_count;
890 INP_INFO_RUNLOCK(&ripcbinfo);
891 error = SYSCTL_OUT(req, &xig, sizeof xig);
893 free(inp_list, M_TEMP);
898 * This is the wrapper function for in_setsockaddr. We just pass down
899 * the pcbinfo for in_setpeeraddr to lock.
902 rip_sockaddr(struct socket *so, struct sockaddr **nam)
904 return (in_setsockaddr(so, nam, &ripcbinfo));
908 * This is the wrapper function for in_setpeeraddr. We just pass down
909 * the pcbinfo for in_setpeeraddr to lock.
912 rip_peeraddr(struct socket *so, struct sockaddr **nam)
914 return (in_setpeeraddr(so, nam, &ripcbinfo));
918 SYSCTL_PROC(_net_inet_raw, OID_AUTO/*XXX*/, pcblist, CTLFLAG_RD, 0, 0,
919 rip_pcblist, "S,xinpcb", "List of active raw IP sockets");
921 struct pr_usrreqs rip_usrreqs = {
922 .pru_abort = rip_abort,
923 .pru_attach = rip_attach,
924 .pru_bind = rip_bind,
925 .pru_connect = rip_connect,
926 .pru_control = in_control,
927 .pru_detach = rip_detach,
928 .pru_disconnect = rip_disconnect,
929 .pru_peeraddr = rip_peeraddr,
930 .pru_send = rip_send,
931 .pru_shutdown = rip_shutdown,
932 .pru_sockaddr = rip_sockaddr,
933 .pru_sosetlabel = in_pcbsosetlabel,
934 .pru_close = rip_close,