| 1219 | #define TUNNEL_LEN 12 /* # bytes of IP option for tunnel encapsulation */ |
| 1220 | |
| 1221 | static int |
| 1222 | X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, |
| 1223 | struct ip_moptions *imo) |
| 1224 | { |
| 1225 | struct mfc *rt; |
| 1226 | int error; |
| 1227 | vifi_t vifi; |
| 1228 | |
| 1229 | CTR3(KTR_IPMF, "ip_mforward: delete mfc orig 0x%08x group %lx ifp %p", |
| 1230 | ntohl(ip->ip_src.s_addr), (u_long)ntohl(ip->ip_dst.s_addr), ifp); |
| 1231 | |
| 1232 | if (ip->ip_hl < (sizeof(struct ip) + TUNNEL_LEN) >> 2 || |
| 1233 | ((u_char *)(ip + 1))[1] != IPOPT_LSRR ) { |
| 1234 | /* |
| 1235 | * Packet arrived via a physical interface or |
| 1236 | * an encapsulated tunnel or a register_vif. |
| 1237 | */ |
| 1238 | } else { |
| 1239 | /* |
| 1240 | * Packet arrived through a source-route tunnel. |
| 1241 | * Source-route tunnels are no longer supported. |
| 1242 | */ |
| 1243 | return (1); |
| 1244 | } |
| 1245 | |
| 1246 | VIF_LOCK(); |
| 1247 | MFC_LOCK(); |
| 1248 | if (imo && ((vifi = imo->imo_multicast_vif) < V_numvifs)) { |
| 1249 | if (ip->ip_ttl < MAXTTL) |
| 1250 | ip->ip_ttl++; /* compensate for -1 in *_send routines */ |
| 1251 | error = ip_mdq(m, ifp, NULL, vifi); |
| 1252 | MFC_UNLOCK(); |
| 1253 | VIF_UNLOCK(); |
| 1254 | return error; |
| 1255 | } |
| 1256 | |
| 1257 | /* |
| 1258 | * Don't forward a packet with time-to-live of zero or one, |
| 1259 | * or a packet destined to a local-only group. |
| 1260 | */ |
| 1261 | if (ip->ip_ttl <= 1 || IN_LOCAL_GROUP(ntohl(ip->ip_dst.s_addr))) { |
| 1262 | MFC_UNLOCK(); |
| 1263 | VIF_UNLOCK(); |
| 1264 | return 0; |
| 1265 | } |
| 1266 | |
| 1267 | /* |
| 1268 | * Determine forwarding vifs from the forwarding cache table |
| 1269 | */ |
| 1270 | MRTSTAT_INC(mrts_mfc_lookups); |
| 1271 | rt = mfc_find(&ip->ip_src, &ip->ip_dst); |
| 1272 | |
| 1273 | /* Entry exists, so forward if necessary */ |
| 1274 | if (rt != NULL) { |
| 1275 | error = ip_mdq(m, ifp, rt, -1); |
| 1276 | MFC_UNLOCK(); |
| 1277 | VIF_UNLOCK(); |
| 1278 | return error; |
nothing calls this directly
no test coverage detected