12393Syz155240 /*
22393Syz155240 * Copyright (C) 1997-2003 by Darren Reed.
32393Syz155240 *
42393Syz155240 * See the IPFILTER.LICENCE file for details on licencing.
52393Syz155240 *
67433SJohn.Ojemann@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
72393Syz155240 * Use is subject to license terms.
82393Syz155240 */
92393Syz155240
102393Syz155240 #if defined(KERNEL) || defined(_KERNEL)
112393Syz155240 # undef KERNEL
122393Syz155240 # undef _KERNEL
132393Syz155240 # define KERNEL 1
142393Syz155240 # define _KERNEL 1
152393Syz155240 #endif
162393Syz155240 #include <sys/errno.h>
172393Syz155240 #include <sys/types.h>
182393Syz155240 #include <sys/param.h>
192393Syz155240 #include <sys/time.h>
202393Syz155240 #include <sys/file.h>
212393Syz155240 #if !defined(AIX)
222393Syz155240 # include <sys/fcntl.h>
232393Syz155240 #endif
242393Syz155240 #if !defined(_KERNEL) && !defined(__KERNEL__)
252393Syz155240 # include <stdio.h>
262393Syz155240 # include <string.h>
272393Syz155240 # include <stdlib.h>
282393Syz155240 # include <ctype.h>
292393Syz155240 # define _KERNEL
302393Syz155240 # ifdef __OpenBSD__
312393Syz155240 struct file;
322393Syz155240 # endif
332393Syz155240 # include <sys/uio.h>
342393Syz155240 # undef _KERNEL
352393Syz155240 #endif
362393Syz155240 #if !defined(linux)
372393Syz155240 # include <sys/protosw.h>
382393Syz155240 #endif
392393Syz155240 #include <sys/socket.h>
402393Syz155240 #if defined(_KERNEL)
412393Syz155240 # if !defined(__NetBSD__) && !defined(sun) && !defined(__osf__) && \
422393Syz155240 !defined(__OpenBSD__) && !defined(__hpux) && !defined(__sgi) && \
432393Syz155240 !defined(AIX)
442393Syz155240 # include <sys/ctype.h>
452393Syz155240 # endif
462393Syz155240 # include <sys/systm.h>
472393Syz155240 # if !defined(__SVR4) && !defined(__svr4__)
482393Syz155240 # include <sys/mbuf.h>
492393Syz155240 # endif
502393Syz155240 #endif
512393Syz155240 #if defined(_KERNEL) && (__FreeBSD_version >= 220000)
522393Syz155240 # include <sys/filio.h>
532393Syz155240 # include <sys/fcntl.h>
542393Syz155240 # if (__FreeBSD_version >= 300000) && !defined(IPFILTER_LKM)
552393Syz155240 # include "opt_ipfilter.h"
562393Syz155240 # endif
572393Syz155240 #else
582393Syz155240 # include <sys/ioctl.h>
592393Syz155240 #endif
602393Syz155240 #if defined(__SVR4) || defined(__svr4__)
612393Syz155240 # include <sys/byteorder.h>
622393Syz155240 # ifdef _KERNEL
632393Syz155240 # include <sys/dditypes.h>
645274Syx160601 # include <sys/strsubr.h>
652393Syz155240 # endif
662393Syz155240 # include <sys/stream.h>
672393Syz155240 # include <sys/kmem.h>
685274Syx160601 # include <sys/pattr.h>
692393Syz155240 #endif
702393Syz155240 #if __FreeBSD__ > 2
712393Syz155240 # include <sys/queue.h>
722393Syz155240 #endif
732393Syz155240 #include <net/if.h>
742393Syz155240 #ifdef sun
752393Syz155240 # include <net/af.h>
762393Syz155240 #endif
772393Syz155240 #include <net/route.h>
782393Syz155240 #include <netinet/in.h>
792393Syz155240 #include <netinet/in_systm.h>
802393Syz155240 #include <netinet/ip.h>
812393Syz155240 #ifndef linux
822393Syz155240 # include <netinet/ip_var.h>
832393Syz155240 #endif
842393Syz155240 #include <netinet/tcp.h>
852393Syz155240 #include <netinet/udp.h>
862393Syz155240 #include <netinet/ip_icmp.h>
872393Syz155240 #include "netinet/ip_compat.h"
882393Syz155240 #include <netinet/tcpip.h>
893448Sdh155122 #include "netinet/ipf_stack.h"
902393Syz155240 #include "netinet/ip_fil.h"
912393Syz155240 #include "netinet/ip_nat.h"
922393Syz155240 #include "netinet/ip_state.h"
932393Syz155240 #include "netinet/ip_proxy.h"
942393Syz155240 #if (__FreeBSD_version >= 300000)
952393Syz155240 # include <sys/malloc.h>
962393Syz155240 #endif
972393Syz155240
982393Syz155240 #include "netinet/ip_ftp_pxy.c"
992393Syz155240 #include "netinet/ip_rcmd_pxy.c"
1002393Syz155240 # include "netinet/ip_pptp_pxy.c"
1012393Syz155240 #if defined(_KERNEL)
1022393Syz155240 # include "netinet/ip_irc_pxy.c"
1032393Syz155240 # include "netinet/ip_raudio_pxy.c"
1042393Syz155240 # include "netinet/ip_h323_pxy.c"
1052393Syz155240 # include "netinet/ip_netbios_pxy.c"
1062393Syz155240 #endif
1072393Syz155240 #include "netinet/ip_ipsec_pxy.c"
1082393Syz155240 #include "netinet/ip_rpcb_pxy.c"
1092393Syz155240
1102393Syz155240 /* END OF INCLUDES */
1112393Syz155240
1122393Syz155240 #if !defined(lint)
1132393Syz155240 static const char rcsid[] = "@(#)$Id: ip_proxy.c,v 2.62.2.14 2005/06/18 02:41:33 darrenr Exp $";
1142393Syz155240 #endif
1152393Syz155240
1162393Syz155240 static int appr_fixseqack __P((fr_info_t *, ip_t *, ap_session_t *, int ));
1172393Syz155240
1182393Syz155240 #define AP_SESS_SIZE 53
1192393Syz155240
1202393Syz155240 #if defined(_KERNEL)
1212393Syz155240 int ipf_proxy_debug = 0;
1222393Syz155240 #else
1232393Syz155240 int ipf_proxy_debug = 2;
1242393Syz155240 #endif
1253448Sdh155122
1263448Sdh155122 static aproxy_t lcl_ap_proxies[] = {
1272393Syz155240 #ifdef IPF_FTP_PROXY
1283448Sdh155122 { NULL, "ftp", (char)IPPROTO_TCP, 0, 0, NULL, ippr_ftp_init, ippr_ftp_fini,
1292393Syz155240 ippr_ftp_new, NULL, ippr_ftp_in, ippr_ftp_out, NULL },
1302393Syz155240 #endif
1312393Syz155240 #ifdef IPF_IRC_PROXY
1323448Sdh155122 { NULL, "irc", (char)IPPROTO_TCP, 0, 0, NULL, ippr_irc_init, ippr_irc_fini,
1332393Syz155240 ippr_irc_new, NULL, NULL, ippr_irc_out, NULL, NULL },
1342393Syz155240 #endif
1352393Syz155240 #ifdef IPF_RCMD_PROXY
1363448Sdh155122 { NULL, "rcmd", (char)IPPROTO_TCP, 0, 0, NULL, ippr_rcmd_init, ippr_rcmd_fini,
1372393Syz155240 ippr_rcmd_new, NULL, ippr_rcmd_in, ippr_rcmd_out, NULL, NULL },
1382393Syz155240 #endif
1392393Syz155240 #ifdef IPF_RAUDIO_PROXY
1403448Sdh155122 { NULL, "raudio", (char)IPPROTO_TCP, 0, 0, NULL, ippr_raudio_init, ippr_raudio_fini,
1412393Syz155240 ippr_raudio_new, NULL, ippr_raudio_in, ippr_raudio_out, NULL, NULL },
1422393Syz155240 #endif
1432393Syz155240 #ifdef IPF_MSNRPC_PROXY
1443448Sdh155122 { NULL, "msnrpc", (char)IPPROTO_TCP, 0, 0, NULL, ippr_msnrpc_init, ippr_msnrpc_fini,
1452393Syz155240 ippr_msnrpc_new, NULL, ippr_msnrpc_in, ippr_msnrpc_out, NULL, NULL },
1462393Syz155240 #endif
1472393Syz155240 #ifdef IPF_NETBIOS_PROXY
1483448Sdh155122 { NULL, "netbios", (char)IPPROTO_UDP, 0, 0, NULL, ippr_netbios_init, ippr_netbios_fini,
1492393Syz155240 NULL, NULL, NULL, ippr_netbios_out, NULL, NULL },
1502393Syz155240 #endif
1512393Syz155240 #ifdef IPF_IPSEC_PROXY
1523448Sdh155122 { NULL, "ipsec", (char)IPPROTO_UDP, 0, 0, NULL,
1532393Syz155240 ippr_ipsec_init, ippr_ipsec_fini, ippr_ipsec_new, ippr_ipsec_del,
1542393Syz155240 ippr_ipsec_inout, ippr_ipsec_inout, ippr_ipsec_match, NULL },
1552393Syz155240 #endif
1562393Syz155240 #ifdef IPF_PPTP_PROXY
1573448Sdh155122 { NULL, "pptp", (char)IPPROTO_TCP, 0, 0, NULL,
1582393Syz155240 ippr_pptp_init, ippr_pptp_fini, ippr_pptp_new, ippr_pptp_del,
1592393Syz155240 ippr_pptp_inout, ippr_pptp_inout, NULL, NULL },
1602393Syz155240 #endif
1612393Syz155240 #ifdef IPF_H323_PROXY
1623448Sdh155122 { NULL, "h323", (char)IPPROTO_TCP, 0, 0, NULL, ippr_h323_init, ippr_h323_fini,
1632393Syz155240 ippr_h323_new, ippr_h323_del, ippr_h323_in, NULL, NULL },
1643448Sdh155122 { NULL, "h245", (char)IPPROTO_TCP, 0, 0, NULL, NULL, NULL,
1652393Syz155240 ippr_h245_new, NULL, NULL, ippr_h245_out, NULL },
1662393Syz155240 #endif
1672393Syz155240 #ifdef IPF_RPCB_PROXY
1682393Syz155240 # if 0
1693448Sdh155122 { NULL, "rpcbt", (char)IPPROTO_TCP, 0, 0, NULL,
1702393Syz155240 ippr_rpcb_init, ippr_rpcb_fini, ippr_rpcb_new, ippr_rpcb_del,
1712393Syz155240 ippr_rpcb_in, ippr_rpcb_out, NULL, NULL },
1722393Syz155240 # endif
1733448Sdh155122 { NULL, "rpcbu", (char)IPPROTO_UDP, 0, 0, NULL,
1742393Syz155240 ippr_rpcb_init, ippr_rpcb_fini, ippr_rpcb_new, ippr_rpcb_del,
1752393Syz155240 ippr_rpcb_in, ippr_rpcb_out, NULL, NULL },
1762393Syz155240 #endif
1773448Sdh155122 { NULL, "", '\0', 0, 0, NULL, NULL, NULL, NULL, NULL }
1782393Syz155240 };
1792393Syz155240
1802393Syz155240 /*
1812393Syz155240 * Dynamically add a new kernel proxy. Ensure that it is unique in the
1822393Syz155240 * collection compiled in and dynamically added.
1832393Syz155240 */
appr_add(ap,ifs)1843448Sdh155122 int appr_add(ap, ifs)
1852393Syz155240 aproxy_t *ap;
1863448Sdh155122 ipf_stack_t *ifs;
1872393Syz155240 {
1882393Syz155240 aproxy_t *a;
1892393Syz155240
1903448Sdh155122 for (a = ifs->ifs_ap_proxies; a->apr_p; a++)
1912393Syz155240 if ((a->apr_p == ap->apr_p) &&
1922393Syz155240 !strncmp(a->apr_label, ap->apr_label,
1932393Syz155240 sizeof(ap->apr_label))) {
1942393Syz155240 if (ipf_proxy_debug > 1)
1952393Syz155240 printf("appr_add: %s/%d already present (B)\n",
1962393Syz155240 a->apr_label, a->apr_p);
1972393Syz155240 return -1;
1982393Syz155240 }
1992393Syz155240
2003448Sdh155122 for (a = ifs->ifs_ap_proxylist; a->apr_p; a = a->apr_next)
2012393Syz155240 if ((a->apr_p == ap->apr_p) &&
2022393Syz155240 !strncmp(a->apr_label, ap->apr_label,
2032393Syz155240 sizeof(ap->apr_label))) {
2042393Syz155240 if (ipf_proxy_debug > 1)
2052393Syz155240 printf("appr_add: %s/%d already present (D)\n",
2062393Syz155240 a->apr_label, a->apr_p);
2072393Syz155240 return -1;
2082393Syz155240 }
2093448Sdh155122 ap->apr_next = ifs->ifs_ap_proxylist;
2103448Sdh155122 ifs->ifs_ap_proxylist = ap;
2112393Syz155240 if (ap->apr_init != NULL)
2123448Sdh155122 return (*ap->apr_init)(&ap->apr_private, ifs);
2133448Sdh155122
2142393Syz155240 return 0;
2152393Syz155240 }
2162393Syz155240
2172393Syz155240
2182393Syz155240 /*
2192393Syz155240 * Check to see if the proxy this control request has come through for
2202393Syz155240 * exists, and if it does and it has a control function then invoke that
2212393Syz155240 * control function.
2222393Syz155240 */
appr_ctl(ctl,ifs)2233448Sdh155122 int appr_ctl(ctl, ifs)
2242393Syz155240 ap_ctl_t *ctl;
2253448Sdh155122 ipf_stack_t *ifs;
2262393Syz155240 {
2272393Syz155240 aproxy_t *a;
2282393Syz155240 int error;
2292393Syz155240
2303448Sdh155122 a = appr_lookup(ctl->apc_p, ctl->apc_label, ifs);
2312393Syz155240 if (a == NULL) {
2322393Syz155240 if (ipf_proxy_debug > 1)
2332393Syz155240 printf("appr_ctl: can't find %s/%d\n",
2342393Syz155240 ctl->apc_label, ctl->apc_p);
2352393Syz155240 error = ESRCH;
2362393Syz155240 } else if (a->apr_ctl == NULL) {
2372393Syz155240 if (ipf_proxy_debug > 1)
2382393Syz155240 printf("appr_ctl: no ctl function for %s/%d\n",
2392393Syz155240 ctl->apc_label, ctl->apc_p);
2402393Syz155240 error = ENXIO;
2412393Syz155240 } else {
2423448Sdh155122 error = (*a->apr_ctl)(a, ctl, a->apr_private);
2432393Syz155240 if ((error != 0) && (ipf_proxy_debug > 1))
2442393Syz155240 printf("appr_ctl: %s/%d ctl error %d\n",
2452393Syz155240 a->apr_label, a->apr_p, error);
2462393Syz155240 }
2472393Syz155240 return error;
2482393Syz155240 }
2492393Syz155240
2502393Syz155240
2512393Syz155240 /*
2522393Syz155240 * Delete a proxy that has been added dynamically from those available.
2532393Syz155240 * If it is in use, return 1 (do not destroy NOW), not in use 0 or -1
2542393Syz155240 * if it cannot be matched.
2552393Syz155240 */
appr_del(ap,ifs)2563448Sdh155122 int appr_del(ap, ifs)
2572393Syz155240 aproxy_t *ap;
2583448Sdh155122 ipf_stack_t *ifs;
2592393Syz155240 {
2602393Syz155240 aproxy_t *a, **app;
2612393Syz155240
2623448Sdh155122 for (app = &ifs->ifs_ap_proxylist; ((a = *app) != NULL);
2633448Sdh155122 app = &a->apr_next)
2642393Syz155240 if (a == ap) {
2652393Syz155240 a->apr_flags |= APR_DELETE;
2662393Syz155240 *app = a->apr_next;
2672393Syz155240 if (ap->apr_ref != 0) {
2682393Syz155240 if (ipf_proxy_debug > 2)
2692393Syz155240 printf("appr_del: orphaning %s/%d\n",
2702393Syz155240 ap->apr_label, ap->apr_p);
2712393Syz155240 return 1;
2722393Syz155240 }
2732393Syz155240 return 0;
2742393Syz155240 }
2752393Syz155240 if (ipf_proxy_debug > 1)
2762393Syz155240 printf("appr_del: proxy %lx not found\n", (u_long)ap);
2772393Syz155240 return -1;
2782393Syz155240 }
2792393Syz155240
2802393Syz155240
2812393Syz155240 /*
2822393Syz155240 * Return 1 if the packet is a good match against a proxy, else 0.
2832393Syz155240 */
appr_ok(fin,tcp,nat)2842393Syz155240 int appr_ok(fin, tcp, nat)
2852393Syz155240 fr_info_t *fin;
2862393Syz155240 tcphdr_t *tcp;
2872393Syz155240 ipnat_t *nat;
2882393Syz155240 {
2892393Syz155240 aproxy_t *apr = nat->in_apr;
2902393Syz155240 u_short dport = nat->in_dport;
2912393Syz155240
2922393Syz155240 if ((apr == NULL) || (apr->apr_flags & APR_DELETE) ||
2932393Syz155240 (fin->fin_p != apr->apr_p))
2942393Syz155240 return 0;
2952393Syz155240 if ((tcp == NULL) && dport)
2962393Syz155240 return 0;
2972393Syz155240 return 1;
2982393Syz155240 }
2992393Syz155240
3002393Syz155240
appr_ioctl(data,cmd,mode,ifs)3013448Sdh155122 int appr_ioctl(data, cmd, mode, ifs)
3022393Syz155240 caddr_t data;
3032393Syz155240 ioctlcmd_t cmd;
3042393Syz155240 int mode;
3053448Sdh155122 ipf_stack_t *ifs;
3062393Syz155240 {
3072393Syz155240 ap_ctl_t ctl;
3082393Syz155240 caddr_t ptr;
3092393Syz155240 int error;
3102393Syz155240
3112393Syz155240 mode = mode; /* LINT */
3122393Syz155240
3132393Syz155240 switch (cmd)
3142393Syz155240 {
3152393Syz155240 case SIOCPROXY :
3167433SJohn.Ojemann@Sun.COM error = BCOPYIN(data, &ctl, sizeof(ctl));
3177433SJohn.Ojemann@Sun.COM if (error != 0)
3187433SJohn.Ojemann@Sun.COM return EFAULT;
3197433SJohn.Ojemann@Sun.COM
3202393Syz155240 ptr = NULL;
3212393Syz155240
3222393Syz155240 if (ctl.apc_dsize > 0) {
3232393Syz155240 KMALLOCS(ptr, caddr_t, ctl.apc_dsize);
3242393Syz155240 if (ptr == NULL)
3252393Syz155240 error = ENOMEM;
3262393Syz155240 else {
3272393Syz155240 error = copyinptr(ctl.apc_data, ptr,
3282393Syz155240 ctl.apc_dsize);
3292393Syz155240 if (error == 0)
3302393Syz155240 ctl.apc_data = ptr;
3312393Syz155240 }
3322393Syz155240 } else {
3332393Syz155240 ctl.apc_data = NULL;
3342393Syz155240 error = 0;
3352393Syz155240 }
3362393Syz155240
3372393Syz155240 if (error == 0)
3383448Sdh155122 error = appr_ctl(&ctl, ifs);
3392393Syz155240
3402393Syz155240 if ((ctl.apc_dsize > 0) && (ptr != NULL) &&
3412393Syz155240 (ctl.apc_data == ptr)) {
3422393Syz155240 KFREES(ptr, ctl.apc_dsize);
3432393Syz155240 }
3442393Syz155240 break;
3452393Syz155240
3462393Syz155240 default :
3472393Syz155240 error = EINVAL;
3482393Syz155240 }
3492393Syz155240 return error;
3502393Syz155240 }
3512393Syz155240
3522393Syz155240
3532393Syz155240 /*
3542393Syz155240 * If a proxy has a match function, call that to do extended packet
3552393Syz155240 * matching.
3562393Syz155240 */
appr_match(fin,nat)3572393Syz155240 int appr_match(fin, nat)
3582393Syz155240 fr_info_t *fin;
3592393Syz155240 nat_t *nat;
3602393Syz155240 {
3612393Syz155240 aproxy_t *apr;
3622393Syz155240 ipnat_t *ipn;
3632393Syz155240 int result;
3642393Syz155240
3652393Syz155240 ipn = nat->nat_ptr;
3662393Syz155240 if (ipf_proxy_debug > 8)
3672393Syz155240 printf("appr_match(%lx,%lx) aps %lx ptr %lx\n",
3682393Syz155240 (u_long)fin, (u_long)nat, (u_long)nat->nat_aps,
3692393Syz155240 (u_long)ipn);
3702393Syz155240
3712393Syz155240 if ((fin->fin_flx & (FI_SHORT|FI_BAD)) != 0) {
3722393Syz155240 if (ipf_proxy_debug > 0)
3732393Syz155240 printf("appr_match: flx 0x%x (BAD|SHORT)\n",
3742393Syz155240 fin->fin_flx);
3752393Syz155240 return -1;
3762393Syz155240 }
3772393Syz155240
3782393Syz155240 apr = ipn->in_apr;
3792393Syz155240 if ((apr == NULL) || (apr->apr_flags & APR_DELETE)) {
3802393Syz155240 if (ipf_proxy_debug > 0)
3812393Syz155240 printf("appr_match:apr %lx apr_flags 0x%x\n",
3822393Syz155240 (u_long)apr, apr ? apr->apr_flags : 0);
3832393Syz155240 return -1;
3842393Syz155240 }
3852393Syz155240
3862393Syz155240 if (apr->apr_match != NULL) {
3873448Sdh155122 result = (*apr->apr_match)(fin, nat->nat_aps, nat, apr->apr_private);
3882393Syz155240 if (result != 0) {
3892393Syz155240 if (ipf_proxy_debug > 4)
3902393Syz155240 printf("appr_match: result %d\n", result);
3912393Syz155240 return -1;
3922393Syz155240 }
3932393Syz155240 }
3942393Syz155240 return 0;
3952393Syz155240 }
3962393Syz155240
3972393Syz155240
3982393Syz155240 /*
3992393Syz155240 * Allocate a new application proxy structure and fill it in with the
4002393Syz155240 * relevant details. call the init function once complete, prior to
4012393Syz155240 * returning.
4022393Syz155240 */
appr_new(fin,nat)4032393Syz155240 int appr_new(fin, nat)
4042393Syz155240 fr_info_t *fin;
4052393Syz155240 nat_t *nat;
4062393Syz155240 {
4072393Syz155240 register ap_session_t *aps;
4082393Syz155240 aproxy_t *apr;
4093448Sdh155122 ipf_stack_t *ifs = fin->fin_ifs;
4102393Syz155240
4112393Syz155240 if (ipf_proxy_debug > 8)
4122393Syz155240 printf("appr_new(%lx,%lx) \n", (u_long)fin, (u_long)nat);
4132393Syz155240
4142393Syz155240 if ((nat->nat_ptr == NULL) || (nat->nat_aps != NULL)) {
4152393Syz155240 if (ipf_proxy_debug > 0)
4162393Syz155240 printf("appr_new: nat_ptr %lx nat_aps %lx\n",
4172393Syz155240 (u_long)nat->nat_ptr, (u_long)nat->nat_aps);
4182393Syz155240 return -1;
4192393Syz155240 }
4202393Syz155240
4212393Syz155240 apr = nat->nat_ptr->in_apr;
4222393Syz155240
4232393Syz155240 if ((apr->apr_flags & APR_DELETE) ||
4242393Syz155240 (fin->fin_p != apr->apr_p)) {
4252393Syz155240 if (ipf_proxy_debug > 2)
4262393Syz155240 printf("appr_new: apr_flags 0x%x p %d/%d\n",
4272393Syz155240 apr->apr_flags, fin->fin_p, apr->apr_p);
4282393Syz155240 return -1;
4292393Syz155240 }
4302393Syz155240
4312393Syz155240 KMALLOC(aps, ap_session_t *);
4322393Syz155240 if (!aps) {
4332393Syz155240 if (ipf_proxy_debug > 0)
4342393Syz155240 printf("appr_new: malloc failed (%lu)\n",
4352393Syz155240 (u_long)sizeof(ap_session_t));
4362393Syz155240 return -1;
4372393Syz155240 }
4382393Syz155240
4392393Syz155240 bzero((char *)aps, sizeof(*aps));
4402393Syz155240 aps->aps_p = fin->fin_p;
4412393Syz155240 aps->aps_data = NULL;
4422393Syz155240 aps->aps_apr = apr;
4432393Syz155240 aps->aps_psiz = 0;
4442393Syz155240 if (apr->apr_new != NULL)
4453448Sdh155122 if ((*apr->apr_new)(fin, aps, nat, apr->apr_private) == -1) {
4462393Syz155240 if ((aps->aps_data != NULL) && (aps->aps_psiz != 0)) {
4472393Syz155240 KFREES(aps->aps_data, aps->aps_psiz);
4482393Syz155240 }
4492393Syz155240 KFREE(aps);
4502393Syz155240 if (ipf_proxy_debug > 2)
4512393Syz155240 printf("appr_new: new(%lx) failed\n",
4522393Syz155240 (u_long)apr->apr_new);
4532393Syz155240 return -1;
4542393Syz155240 }
4552393Syz155240 aps->aps_nat = nat;
4563448Sdh155122 aps->aps_next = ifs->ifs_ap_sess_list;
4573448Sdh155122 ifs->ifs_ap_sess_list = aps;
4582393Syz155240 nat->nat_aps = aps;
4592393Syz155240
4602393Syz155240 return 0;
4612393Syz155240 }
4622393Syz155240
4632393Syz155240
4642393Syz155240 /*
4652393Syz155240 * Check to see if a packet should be passed through an active proxy routine
4662393Syz155240 * if one has been setup for it. We don't need to check the checksum here if
4672393Syz155240 * IPFILTER_CKSUM is defined because if it is, a failed check causes FI_BAD
4682393Syz155240 * to be set.
4692393Syz155240 */
appr_check(fin,nat)4702393Syz155240 int appr_check(fin, nat)
4712393Syz155240 fr_info_t *fin;
4722393Syz155240 nat_t *nat;
4732393Syz155240 {
4742958Sdr146992 #if SOLARIS && defined(_KERNEL) && (SOLARIS2 >= 6) && defined(ICK_VALID)
4752393Syz155240 mb_t *m;
4762393Syz155240 int dosum = 1;
4772393Syz155240 #endif
4782393Syz155240 tcphdr_t *tcp = NULL;
4792393Syz155240 udphdr_t *udp = NULL;
4805274Syx160601 void *tcpudp = NULL;
4815274Syx160601 u_short *csump;
4822393Syz155240 ap_session_t *aps;
4832393Syz155240 aproxy_t *apr;
4842393Syz155240 ip_t *ip;
4852393Syz155240 short rv;
4862393Syz155240 int err;
4872393Syz155240 #if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi)
4882393Syz155240 u_32_t s1, s2, sd;
4892393Syz155240 #endif
4903448Sdh155122 ipf_stack_t *ifs = fin->fin_ifs;
4913448Sdh155122
4922958Sdr146992 #if SOLARIS && defined(_KERNEL) && (SOLARIS2 >= 6)
493*7513SDarren.Reed@Sun.COM net_handle_t net_data_p;
4942958Sdr146992 if (fin->fin_v == 4)
4953448Sdh155122 net_data_p = ifs->ifs_ipf_ipv4;
4962958Sdr146992 else
4973448Sdh155122 net_data_p = ifs->ifs_ipf_ipv6;
4982958Sdr146992 #endif
4992393Syz155240
5002393Syz155240 if (fin->fin_flx & FI_BAD) {
5012393Syz155240 if (ipf_proxy_debug > 0)
5022393Syz155240 printf("appr_check: flx 0x%x (BAD)\n", fin->fin_flx);
5032393Syz155240 return -1;
5042393Syz155240 }
5052393Syz155240
5062393Syz155240 #ifndef IPFILTER_CKSUM
5072393Syz155240 if ((fin->fin_out == 0) && (fr_checkl4sum(fin) == -1)) {
5082393Syz155240 if (ipf_proxy_debug > 0)
5092393Syz155240 printf("appr_check: l4 checksum failure %d\n",
5102393Syz155240 fin->fin_p);
5112393Syz155240 if (fin->fin_p == IPPROTO_TCP)
5123448Sdh155122 ifs->ifs_frstats[fin->fin_out].fr_tcpbad++;
5132393Syz155240 return -1;
5142393Syz155240 }
5152393Syz155240 #endif
5162393Syz155240
5172393Syz155240 aps = nat->nat_aps;
5182393Syz155240 if ((aps != NULL) && (aps->aps_p == fin->fin_p)) {
5192393Syz155240 /*
5202393Syz155240 * If there is data in this packet to be proxied then try and
5212393Syz155240 * get it all into the one buffer, else drop it.
5222393Syz155240 */
5232393Syz155240 #if defined(MENTAT) || defined(HAVE_M_PULLDOWN)
5242393Syz155240 if ((fin->fin_dlen > 0) && !(fin->fin_flx & FI_COALESCE))
5252393Syz155240 if (fr_coalesce(fin) == -1) {
5262393Syz155240 if (ipf_proxy_debug > 0)
5272393Syz155240 printf("appr_check: fr_coalesce failed %x\n", fin->fin_flx);
5282393Syz155240 return -1;
5292393Syz155240 }
5302393Syz155240 #endif
5312393Syz155240 ip = fin->fin_ip;
5322393Syz155240
5332393Syz155240 switch (fin->fin_p)
5342393Syz155240 {
5352393Syz155240 case IPPROTO_TCP :
5362393Syz155240 tcp = (tcphdr_t *)fin->fin_dp;
5372393Syz155240
5382393Syz155240 #if SOLARIS && defined(_KERNEL) && (SOLARIS2 >= 6) && defined(ICK_VALID)
5392393Syz155240 m = fin->fin_qfm;
5402393Syz155240 if (dohwcksum && (m->b_ick_flag == ICK_VALID))
5412393Syz155240 dosum = 0;
5422393Syz155240 #endif
5432393Syz155240 /*
5442393Syz155240 * Don't bother the proxy with these...or in fact,
5452393Syz155240 * should we free up proxy stuff when seen?
5462393Syz155240 */
5472393Syz155240 if ((fin->fin_tcpf & TH_RST) != 0)
5482393Syz155240 break;
5492393Syz155240 /*FALLTHROUGH*/
5502393Syz155240 case IPPROTO_UDP :
5512393Syz155240 udp = (udphdr_t *)fin->fin_dp;
5522393Syz155240 break;
5532393Syz155240 default :
5542393Syz155240 break;
5552393Syz155240 }
5562393Syz155240
5572393Syz155240 apr = aps->aps_apr;
5582393Syz155240 err = 0;
5592393Syz155240 if (fin->fin_out != 0) {
5602393Syz155240 if (apr->apr_outpkt != NULL)
5613448Sdh155122 err = (*apr->apr_outpkt)(fin, aps, nat, apr->apr_private);
5622393Syz155240 } else {
5632393Syz155240 if (apr->apr_inpkt != NULL)
5643448Sdh155122 err = (*apr->apr_inpkt)(fin, aps, nat, apr->apr_private);
5652393Syz155240 }
5662393Syz155240
5672393Syz155240 rv = APR_EXIT(err);
5682393Syz155240 if (((ipf_proxy_debug > 0) && (rv != 0)) ||
5692393Syz155240 (ipf_proxy_debug > 8))
5702393Syz155240 printf("appr_check: out %d err %x rv %d\n",
5712393Syz155240 fin->fin_out, err, rv);
5722393Syz155240 if (rv == 1)
5732393Syz155240 return -1;
5742393Syz155240
5752393Syz155240 if (rv == 2) {
5762393Syz155240 appr_free(apr);
5772393Syz155240 nat->nat_aps = NULL;
5782393Syz155240 return -1;
5792393Syz155240 }
5802393Syz155240
5812393Syz155240 /*
5822393Syz155240 * If err != 0 then the data size of the packet has changed
5832393Syz155240 * so we need to recalculate the header checksums for the
5842393Syz155240 * packet.
5852958Sdr146992 * inbound packets always need to be adjusted.
5862393Syz155240 */
5872393Syz155240 #if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi)
5885274Syx160601 if (err != 0) {
5892393Syz155240 short adjlen = err & 0xffff;
5902393Syz155240
5912393Syz155240 s1 = LONG_SUM(ip->ip_len - adjlen);
5922393Syz155240 s2 = LONG_SUM(ip->ip_len);
5932393Syz155240 CALC_SUMD(s1, s2, sd);
5945274Syx160601 sd = (sd & 0xffff) + (sd >> 16);
5955274Syx160601 if (!fin->fin_out ||
5965274Syx160601 !NET_IS_HCK_L3_FULL(net_data_p, fin->fin_m))
5975274Syx160601 fix_outcksum(&ip->ip_sum, sd);
5982393Syz155240 }
5992393Syz155240 #endif
6002393Syz155240
6012393Syz155240 /*
6022393Syz155240 * For TCP packets, we may need to adjust the sequence and
6032393Syz155240 * acknowledgement numbers to reflect changes in size of the
6042393Syz155240 * data stream.
6052393Syz155240 *
6065274Syx160601 * For both TCP and UDP, recalculate the layer 4 checksum in
6075274Syx160601 * software checksum case, as we can't tell if data has been
6082393Syz155240 * changed or not.
6092393Syz155240 */
6102393Syz155240 if (tcp != NULL) {
6115274Syx160601 tcpudp = tcp;
6125274Syx160601 csump = &tcp->th_sum;
6135274Syx160601 (void) appr_fixseqack(fin, ip, aps, APR_INC(err));
6145274Syx160601 } else if (udp != NULL) {
6155274Syx160601 tcpudp = udp;
6165274Syx160601 csump = &udp->uh_sum;
6175274Syx160601 }
6185274Syx160601
6195274Syx160601 if (tcpudp) {
6205274Syx160601 #if SOLARIS && defined(_KERNEL) && (SOLARIS2 >= 6) && defined(MENTAT)
6215274Syx160601 if (!fin->fin_out) {
6225274Syx160601 /*
6235274Syx160601 * We are incapable of adjusting partial hcksum
6245274Syx160601 * result for inbound packets here, as the
6255274Syx160601 * partial hcksum calculation range might not
6265274Syx160601 * cover the whole payload, and the payload data
6275274Syx160601 * might be changed by proxy.
6285274Syx160601 */
6295274Syx160601 DB_CKSUMFLAGS(fin->fin_m) &= ~HCK_PARTIALCKSUM;
6305274Syx160601
6315274Syx160601 /* Inbound packets always need recalculation. */
6325274Syx160601 *csump = fr_cksum(fin->fin_qfm, ip,
6335274Syx160601 fin->fin_p, tcpudp);
6345274Syx160601 } else if (NET_IS_HCK_L4_PART(net_data_p, fin->fin_m)) {
6355274Syx160601 if (err != 0) {
6365274Syx160601 DB_CKSUMEND(fin->fin_m) += (short)err;
6375274Syx160601 fix_incksum(csump, sd);
6385274Syx160601 }
6395274Syx160601 } else if (!NET_IS_HCK_L4_FULL(net_data_p, fin->fin_m))
6405274Syx160601 *csump = fr_cksum(fin->fin_qfm, ip,
6415274Syx160601 fin->fin_p, tcpudp);
6422393Syz155240 #else
6435274Syx160601 *csump = fr_cksum(fin->fin_m, ip, fin->fin_p, tcpudp);
6442393Syz155240 #endif
6452393Syz155240 }
6462393Syz155240 aps->aps_bytes += fin->fin_plen;
6472393Syz155240 aps->aps_pkts++;
6482393Syz155240 return 1;
6492393Syz155240 }
6502393Syz155240 return 0;
6512393Syz155240 }
6522393Syz155240
6532393Syz155240
6542393Syz155240 /*
6552393Syz155240 * Search for an proxy by the protocol it is being used with and its name.
6562393Syz155240 */
appr_lookup(pr,name,ifs)6573448Sdh155122 aproxy_t *appr_lookup(pr, name, ifs)
6582393Syz155240 u_int pr;
6592393Syz155240 char *name;
6603448Sdh155122 ipf_stack_t *ifs;
6612393Syz155240 {
6622393Syz155240 aproxy_t *ap;
6632393Syz155240
6642393Syz155240 if (ipf_proxy_debug > 8)
6652393Syz155240 printf("appr_lookup(%d,%s)\n", pr, name);
6662393Syz155240
6673448Sdh155122 for (ap = ifs->ifs_ap_proxies; ap->apr_p; ap++)
6682393Syz155240 if ((ap->apr_p == pr) &&
6692393Syz155240 !strncmp(name, ap->apr_label, sizeof(ap->apr_label))) {
6702393Syz155240 ap->apr_ref++;
6712393Syz155240 return ap;
6722393Syz155240 }
6732393Syz155240
6743448Sdh155122 for (ap = ifs->ifs_ap_proxylist; ap; ap = ap->apr_next)
6752393Syz155240 if ((ap->apr_p == pr) &&
6762393Syz155240 !strncmp(name, ap->apr_label, sizeof(ap->apr_label))) {
6772393Syz155240 ap->apr_ref++;
6782393Syz155240 return ap;
6792393Syz155240 }
6802393Syz155240 if (ipf_proxy_debug > 2)
6812393Syz155240 printf("appr_lookup: failed for %d/%s\n", pr, name);
6822393Syz155240 return NULL;
6832393Syz155240 }
6842393Syz155240
6852393Syz155240
appr_free(ap)6862393Syz155240 void appr_free(ap)
6872393Syz155240 aproxy_t *ap;
6882393Syz155240 {
6892393Syz155240 ap->apr_ref--;
6902393Syz155240 }
6912393Syz155240
6922393Syz155240
aps_free(aps,ifs)6933448Sdh155122 void aps_free(aps, ifs)
6942393Syz155240 ap_session_t *aps;
6953448Sdh155122 ipf_stack_t *ifs;
6962393Syz155240 {
6972393Syz155240 ap_session_t *a, **ap;
6982393Syz155240 aproxy_t *apr;
6992393Syz155240
7002393Syz155240 if (!aps)
7012393Syz155240 return;
7022393Syz155240
7033448Sdh155122 for (ap = &ifs->ifs_ap_sess_list; ((a = *ap) != NULL); ap = &a->aps_next)
7042393Syz155240 if (a == aps) {
7052393Syz155240 *ap = a->aps_next;
7062393Syz155240 break;
7072393Syz155240 }
7082393Syz155240
7092393Syz155240 apr = aps->aps_apr;
7102393Syz155240 if ((apr != NULL) && (apr->apr_del != NULL))
7113448Sdh155122 (*apr->apr_del)(aps, apr->apr_private, ifs);
7122393Syz155240
7132393Syz155240 if ((aps->aps_data != NULL) && (aps->aps_psiz != 0))
7142393Syz155240 KFREES(aps->aps_data, aps->aps_psiz);
7152393Syz155240 KFREE(aps);
7162393Syz155240 }
7172393Syz155240
7182393Syz155240
7192393Syz155240 /*
7202393Syz155240 * returns 2 if ack or seq number in TCP header is changed, returns 0 otherwise
7212393Syz155240 */
appr_fixseqack(fin,ip,aps,inc)7222393Syz155240 static int appr_fixseqack(fin, ip, aps, inc)
7232393Syz155240 fr_info_t *fin;
7242393Syz155240 ip_t *ip;
7252393Syz155240 ap_session_t *aps;
7262393Syz155240 int inc;
7272393Syz155240 {
7282393Syz155240 int sel, ch = 0, out, nlen;
7292393Syz155240 u_32_t seq1, seq2;
7302393Syz155240 tcphdr_t *tcp;
7312393Syz155240 short inc2;
7322393Syz155240
7332393Syz155240 tcp = (tcphdr_t *)fin->fin_dp;
7342393Syz155240 out = fin->fin_out;
7352393Syz155240 /*
7362393Syz155240 * ip_len has already been adjusted by 'inc'.
7372393Syz155240 */
7382393Syz155240 nlen = ip->ip_len;
7392393Syz155240 nlen -= (IP_HL(ip) << 2) + (TCP_OFF(tcp) << 2);
7402393Syz155240
7412393Syz155240 inc2 = inc;
7422393Syz155240 inc = (int)inc2;
7432393Syz155240
7442393Syz155240 if (out != 0) {
7452393Syz155240 seq1 = (u_32_t)ntohl(tcp->th_seq);
7462393Syz155240 sel = aps->aps_sel[out];
7472393Syz155240
7482393Syz155240 /* switch to other set ? */
7492393Syz155240 if ((aps->aps_seqmin[!sel] > aps->aps_seqmin[sel]) &&
7502393Syz155240 (seq1 > aps->aps_seqmin[!sel])) {
7512393Syz155240 if (ipf_proxy_debug > 7)
7522393Syz155240 printf("proxy out switch set seq %d -> %d %x > %x\n",
7532393Syz155240 sel, !sel, seq1,
7542393Syz155240 aps->aps_seqmin[!sel]);
7552393Syz155240 sel = aps->aps_sel[out] = !sel;
7562393Syz155240 }
7572393Syz155240
7582393Syz155240 if (aps->aps_seqoff[sel]) {
7592393Syz155240 seq2 = aps->aps_seqmin[sel] - aps->aps_seqoff[sel];
7602393Syz155240 if (seq1 > seq2) {
7612393Syz155240 seq2 = aps->aps_seqoff[sel];
7622393Syz155240 seq1 += seq2;
7632393Syz155240 tcp->th_seq = htonl(seq1);
7642393Syz155240 ch = 1;
7652393Syz155240 }
7662393Syz155240 }
7672393Syz155240
7682393Syz155240 if (inc && (seq1 > aps->aps_seqmin[!sel])) {
7692393Syz155240 aps->aps_seqmin[sel] = seq1 + nlen - 1;
7702393Syz155240 aps->aps_seqoff[sel] = aps->aps_seqoff[sel] + inc;
7712393Syz155240 if (ipf_proxy_debug > 7)
7722393Syz155240 printf("proxy seq set %d at %x to %d + %d\n",
7732393Syz155240 sel, aps->aps_seqmin[sel],
7742393Syz155240 aps->aps_seqoff[sel], inc);
7752393Syz155240 }
7762393Syz155240
7772393Syz155240 /***/
7782393Syz155240
7792393Syz155240 seq1 = ntohl(tcp->th_ack);
7802393Syz155240 sel = aps->aps_sel[1 - out];
7812393Syz155240
7822393Syz155240 /* switch to other set ? */
7832393Syz155240 if ((aps->aps_ackmin[!sel] > aps->aps_ackmin[sel]) &&
7842393Syz155240 (seq1 > aps->aps_ackmin[!sel])) {
7852393Syz155240 if (ipf_proxy_debug > 7)
7862393Syz155240 printf("proxy out switch set ack %d -> %d %x > %x\n",
7872393Syz155240 sel, !sel, seq1,
7882393Syz155240 aps->aps_ackmin[!sel]);
7892393Syz155240 sel = aps->aps_sel[1 - out] = !sel;
7902393Syz155240 }
7912393Syz155240
7922393Syz155240 if (aps->aps_ackoff[sel] && (seq1 > aps->aps_ackmin[sel])) {
7932393Syz155240 seq2 = aps->aps_ackoff[sel];
7942393Syz155240 tcp->th_ack = htonl(seq1 - seq2);
7952393Syz155240 ch = 1;
7962393Syz155240 }
7972393Syz155240 } else {
7982393Syz155240 seq1 = ntohl(tcp->th_seq);
7992393Syz155240 sel = aps->aps_sel[out];
8002393Syz155240
8012393Syz155240 /* switch to other set ? */
8022393Syz155240 if ((aps->aps_ackmin[!sel] > aps->aps_ackmin[sel]) &&
8032393Syz155240 (seq1 > aps->aps_ackmin[!sel])) {
8042393Syz155240 if (ipf_proxy_debug > 7)
8052393Syz155240 printf("proxy in switch set ack %d -> %d %x > %x\n",
8062393Syz155240 sel, !sel, seq1, aps->aps_ackmin[!sel]);
8072393Syz155240 sel = aps->aps_sel[out] = !sel;
8082393Syz155240 }
8092393Syz155240
8102393Syz155240 if (aps->aps_ackoff[sel]) {
8112393Syz155240 seq2 = aps->aps_ackmin[sel] - aps->aps_ackoff[sel];
8122393Syz155240 if (seq1 > seq2) {
8132393Syz155240 seq2 = aps->aps_ackoff[sel];
8142393Syz155240 seq1 += seq2;
8152393Syz155240 tcp->th_seq = htonl(seq1);
8162393Syz155240 ch = 1;
8172393Syz155240 }
8182393Syz155240 }
8192393Syz155240
8202393Syz155240 if (inc && (seq1 > aps->aps_ackmin[!sel])) {
8212393Syz155240 aps->aps_ackmin[!sel] = seq1 + nlen - 1;
8222393Syz155240 aps->aps_ackoff[!sel] = aps->aps_ackoff[sel] + inc;
8232393Syz155240
8242393Syz155240 if (ipf_proxy_debug > 7)
8252393Syz155240 printf("proxy ack set %d at %x to %d + %d\n",
8262393Syz155240 !sel, aps->aps_seqmin[!sel],
8272393Syz155240 aps->aps_seqoff[sel], inc);
8282393Syz155240 }
8292393Syz155240
8302393Syz155240 /***/
8312393Syz155240
8322393Syz155240 seq1 = ntohl(tcp->th_ack);
8332393Syz155240 sel = aps->aps_sel[1 - out];
8342393Syz155240
8352393Syz155240 /* switch to other set ? */
8362393Syz155240 if ((aps->aps_seqmin[!sel] > aps->aps_seqmin[sel]) &&
8372393Syz155240 (seq1 > aps->aps_seqmin[!sel])) {
8382393Syz155240 if (ipf_proxy_debug > 7)
8392393Syz155240 printf("proxy in switch set seq %d -> %d %x > %x\n",
8402393Syz155240 sel, !sel, seq1, aps->aps_seqmin[!sel]);
8412393Syz155240 sel = aps->aps_sel[1 - out] = !sel;
8422393Syz155240 }
8432393Syz155240
8442393Syz155240 if (aps->aps_seqoff[sel] != 0) {
8452393Syz155240 if (ipf_proxy_debug > 7)
8462393Syz155240 printf("sel %d seqoff %d seq1 %x seqmin %x\n",
8472393Syz155240 sel, aps->aps_seqoff[sel], seq1,
8482393Syz155240 aps->aps_seqmin[sel]);
8492393Syz155240 if (seq1 > aps->aps_seqmin[sel]) {
8502393Syz155240 seq2 = aps->aps_seqoff[sel];
8512393Syz155240 tcp->th_ack = htonl(seq1 - seq2);
8522393Syz155240 ch = 1;
8532393Syz155240 }
8542393Syz155240 }
8552393Syz155240 }
8562393Syz155240
8572393Syz155240 if (ipf_proxy_debug > 8)
8582393Syz155240 printf("appr_fixseqack: seq %x ack %x\n",
8592393Syz155240 ntohl(tcp->th_seq), ntohl(tcp->th_ack));
8602393Syz155240 return ch ? 2 : 0;
8612393Syz155240 }
8622393Syz155240
8632393Syz155240
8642393Syz155240 /*
8652393Syz155240 * Initialise hook for kernel application proxies.
8662393Syz155240 * Call the initialise routine for all the compiled in kernel proxies.
8672393Syz155240 */
appr_init(ifs)8683448Sdh155122 int appr_init(ifs)
8693448Sdh155122 ipf_stack_t *ifs;
8702393Syz155240 {
8712393Syz155240 aproxy_t *ap;
8723448Sdh155122 int err = 0;
8732393Syz155240
8743448Sdh155122 /* Since the refcnt is used we make a copy of lcl_ap_proxies */
8753448Sdh155122 KMALLOCS(ifs->ifs_ap_proxies, aproxy_t *, sizeof (lcl_ap_proxies));
8763448Sdh155122 bcopy(lcl_ap_proxies, ifs->ifs_ap_proxies, sizeof (lcl_ap_proxies));
8773448Sdh155122
8783448Sdh155122 for (ap = ifs->ifs_ap_proxies; ap->apr_p; ap++) {
8792393Syz155240 if (ap->apr_init != NULL) {
8803448Sdh155122 err = (*ap->apr_init)(&ap->apr_private, ifs);
8812393Syz155240 if (err != 0)
8822393Syz155240 break;
8832393Syz155240 }
8842393Syz155240 }
8853448Sdh155122 return 0;
8862393Syz155240 }
8872393Syz155240
8882393Syz155240
8892393Syz155240 /*
8902393Syz155240 * Unload hook for kernel application proxies.
8912393Syz155240 * Call the finialise routine for all the compiled in kernel proxies.
8922393Syz155240 */
appr_unload(ifs)8933448Sdh155122 void appr_unload(ifs)
8943448Sdh155122 ipf_stack_t *ifs;
8952393Syz155240 {
8962393Syz155240 aproxy_t *ap;
8973448Sdh155122 if(ifs->ifs_ap_proxies == NULL)
8983448Sdh155122 return;
8992393Syz155240
9003448Sdh155122 for (ap = ifs->ifs_ap_proxies; ap->apr_p; ap++)
9012393Syz155240 if (ap->apr_fini != NULL)
9023448Sdh155122 (*ap->apr_fini)(&ap->apr_private, ifs);
9033448Sdh155122 for (ap = ifs->ifs_ap_proxylist; ap; ap = ap->apr_next)
9042393Syz155240 if (ap->apr_fini != NULL)
9053448Sdh155122 (*ap->apr_fini)(&ap->apr_private, ifs);
9063448Sdh155122
9073448Sdh155122 KFREES(ifs->ifs_ap_proxies, sizeof (lcl_ap_proxies));
9083448Sdh155122 ifs->ifs_ap_proxies = NULL;
9092393Syz155240 }
910