ip_rpcb_pxy.c (153872) | ip_rpcb_pxy.c (170263) |
---|---|
1/* 2 * Copyright (C) 2002-2003 by Ryan Beasley <ryanb@goddamnbastard.org> 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 */ 6/* 7 * Overview: 8 * This is an in-kernel application proxy for Sun's RPCBIND (nee portmap) --- 23 unchanged lines hidden (view full) --- 32 * o Even with the limit on the total amount of recorded transactions, 33 * should there be a timeout on transaction removal? 34 * o There is a potential collision between cloning, wildcard NAT and 35 * state entries. There should be an appr_getport routine for 36 * to avoid this. 37 * o The enclosed hack of STREAMS support is pretty sick and most likely 38 * broken. 39 * | 1/* 2 * Copyright (C) 2002-2003 by Ryan Beasley <ryanb@goddamnbastard.org> 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 */ 6/* 7 * Overview: 8 * This is an in-kernel application proxy for Sun's RPCBIND (nee portmap) --- 23 unchanged lines hidden (view full) --- 32 * o Even with the limit on the total amount of recorded transactions, 33 * should there be a timeout on transaction removal? 34 * o There is a potential collision between cloning, wildcard NAT and 35 * state entries. There should be an appr_getport routine for 36 * to avoid this. 37 * o The enclosed hack of STREAMS support is pretty sick and most likely 38 * broken. 39 * |
40 * $Id: ip_rpcb_pxy.c,v 2.25.2.3 2005/02/04 10:22:56 darrenr Exp $ | 40 * $Id: ip_rpcb_pxy.c,v 2.25.2.6 2007/01/17 11:34:54 darrenr Exp $ |
41 */ 42 43#define IPF_RPCB_PROXY 44 45/* 46 * Function prototypes 47 */ 48int ippr_rpcb_init __P((void)); --- 236 unchanged lines hidden (view full) --- 285 mb_t *m; 286 287 /* Disallow fragmented or illegally short packets. */ 288 if ((fin->fin_flx & (FI_FRAG|FI_SHORT)) != 0) 289 return(APR_ERR(1)); 290 291 /* Perform basic variable initialization. */ 292 rs = (rpcb_session_t *)aps->aps_data; | 41 */ 42 43#define IPF_RPCB_PROXY 44 45/* 46 * Function prototypes 47 */ 48int ippr_rpcb_init __P((void)); --- 236 unchanged lines hidden (view full) --- 285 mb_t *m; 286 287 /* Disallow fragmented or illegally short packets. */ 288 if ((fin->fin_flx & (FI_FRAG|FI_SHORT)) != 0) 289 return(APR_ERR(1)); 290 291 /* Perform basic variable initialization. */ 292 rs = (rpcb_session_t *)aps->aps_data; |
293 rx = NULL; |
|
293 294 m = fin->fin_m; 295 off = (char *)fin->fin_dp - (char *)fin->fin_ip; 296 off += sizeof(udphdr_t) + fin->fin_ipoff; 297 dlen = fin->fin_dlen - sizeof(udphdr_t); 298 diff = 0; 299 300 /* Disallow packets outside legal range for supported requests. */ 301 if ((dlen < RPCB_REPMIN) || (dlen > RPCB_REPMAX)) 302 return(APR_ERR(1)); 303 304 /* Copy packet over to convenience buffer. */ 305 rm = &rpcmsg; 306 bzero((char *)rm, sizeof(*rm)); 307 COPYDATA(m, off, dlen, (caddr_t)&rm->rm_msgbuf); 308 rm->rm_buflen = dlen; 309 | 294 295 m = fin->fin_m; 296 off = (char *)fin->fin_dp - (char *)fin->fin_ip; 297 off += sizeof(udphdr_t) + fin->fin_ipoff; 298 dlen = fin->fin_dlen - sizeof(udphdr_t); 299 diff = 0; 300 301 /* Disallow packets outside legal range for supported requests. */ 302 if ((dlen < RPCB_REPMIN) || (dlen > RPCB_REPMAX)) 303 return(APR_ERR(1)); 304 305 /* Copy packet over to convenience buffer. */ 306 rm = &rpcmsg; 307 bzero((char *)rm, sizeof(*rm)); 308 COPYDATA(m, off, dlen, (caddr_t)&rm->rm_msgbuf); 309 rm->rm_buflen = dlen; 310 |
311 rx = NULL; /* XXX gcc */ 312 |
|
310 /* Send off to decode reply. */ 311 rv = ippr_rpcb_decoderep(fin, nat, rs, rm, &rx); 312 313 switch(rv) 314 { 315 case -1: /* Bad packet */ 316 if (rx != NULL) { 317 MUTEX_ENTER(&rs->rs_rxlock); --- 833 unchanged lines hidden (view full) --- 1151 fr_info_t fi; 1152 nat_t *natl; 1153 int nflags; 1154 1155 ipn = nat->nat_ptr; 1156 1157 /* Generate dummy fr_info */ 1158 bcopy((char *)fin, (char *)&fi, sizeof(fi)); | 313 /* Send off to decode reply. */ 314 rv = ippr_rpcb_decoderep(fin, nat, rs, rm, &rx); 315 316 switch(rv) 317 { 318 case -1: /* Bad packet */ 319 if (rx != NULL) { 320 MUTEX_ENTER(&rs->rs_rxlock); --- 833 unchanged lines hidden (view full) --- 1154 fr_info_t fi; 1155 nat_t *natl; 1156 int nflags; 1157 1158 ipn = nat->nat_ptr; 1159 1160 /* Generate dummy fr_info */ 1161 bcopy((char *)fin, (char *)&fi, sizeof(fi)); |
1162 fi.fin_state = NULL; 1163 fi.fin_nat = NULL; |
|
1159 fi.fin_out = 0; 1160 fi.fin_src = fin->fin_dst; 1161 fi.fin_dst = nat->nat_outip; 1162 fi.fin_p = proto; 1163 fi.fin_sport = 0; 1164 fi.fin_dport = port & 0xffff; 1165 fi.fin_flx |= FI_IGNORE; 1166 --- 19 unchanged lines hidden (view full) --- 1186 * Search for existing NAT & state entries. Pay close attention to 1187 * mutexes / locks grabbed from lookup routines, as not doing so could 1188 * lead to bad things. 1189 * 1190 * If successful, fr_stlookup returns with ipf_state locked. We have 1191 * no use for this lock, so simply unlock it if necessary. 1192 */ 1193 is = fr_stlookup(&fi, &tcp, NULL); | 1164 fi.fin_out = 0; 1165 fi.fin_src = fin->fin_dst; 1166 fi.fin_dst = nat->nat_outip; 1167 fi.fin_p = proto; 1168 fi.fin_sport = 0; 1169 fi.fin_dport = port & 0xffff; 1170 fi.fin_flx |= FI_IGNORE; 1171 --- 19 unchanged lines hidden (view full) --- 1191 * Search for existing NAT & state entries. Pay close attention to 1192 * mutexes / locks grabbed from lookup routines, as not doing so could 1193 * lead to bad things. 1194 * 1195 * If successful, fr_stlookup returns with ipf_state locked. We have 1196 * no use for this lock, so simply unlock it if necessary. 1197 */ 1198 is = fr_stlookup(&fi, &tcp, NULL); |
1194 if (is != NULL) | 1199 if (is != NULL) { |
1195 RWLOCK_EXIT(&ipf_state); | 1200 RWLOCK_EXIT(&ipf_state); |
1201 } |
|
1196 1197 RWLOCK_EXIT(&ipf_nat); 1198 1199 WRITE_ENTER(&ipf_nat); 1200 natl = nat_inlookup(&fi, nflags, proto, fi.fin_src, fi.fin_dst); 1201 1202 if ((natl != NULL) && (is != NULL)) { 1203 MUTEX_DOWNGRADE(&ipf_nat); --- 62 unchanged lines hidden (view full) --- 1266 * XXX nat_delete is private to ip_nat.c. Should 1267 * check w/ Darren about this one. 1268 * 1269 * nat_delete(natl, NL_EXPIRE); 1270 */ 1271 return(-1); 1272 } 1273 if (fi.fin_state != NULL) | 1202 1203 RWLOCK_EXIT(&ipf_nat); 1204 1205 WRITE_ENTER(&ipf_nat); 1206 natl = nat_inlookup(&fi, nflags, proto, fi.fin_src, fi.fin_dst); 1207 1208 if ((natl != NULL) && (is != NULL)) { 1209 MUTEX_DOWNGRADE(&ipf_nat); --- 62 unchanged lines hidden (view full) --- 1272 * XXX nat_delete is private to ip_nat.c. Should 1273 * check w/ Darren about this one. 1274 * 1275 * nat_delete(natl, NL_EXPIRE); 1276 */ 1277 return(-1); 1278 } 1279 if (fi.fin_state != NULL) |
1274 fr_statederef(&fi, (ipstate_t **)&fi.fin_state); | 1280 fr_statederef((ipstate_t **)&fi.fin_state); |
1275 } 1276 1277 return(0); 1278} 1279 1280/* -------------------------------------------------------------------- */ 1281/* Function: ippr_rpcb_modv3 */ 1282/* Returns: int -- change in packet length */ --- 176 unchanged lines hidden --- | 1281 } 1282 1283 return(0); 1284} 1285 1286/* -------------------------------------------------------------------- */ 1287/* Function: ippr_rpcb_modv3 */ 1288/* Returns: int -- change in packet length */ --- 176 unchanged lines hidden --- |