/*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#endif
-#ifndef MROUTING
+#if !MROUTING
extern u_int32_t _ip_mcast_src(int vifi);
extern int _ip_mforward(struct ip *ip, struct ifnet *ifp,
struct mbuf *m, struct ip_moptions *imo);
struct ip_moptions *) = _ip_mforward;
int
-_mrt_ioctl(__unused int req, __unused caddr_t data, __unused struct proc *p)
+_mrt_ioctl(__unused u_long req, __unused caddr_t data, __unused struct proc *p)
{
return EOPNOTSUPP;
}
-int (*mrt_ioctl)(int, caddr_t, struct proc *) = _mrt_ioctl;
+int (*mrt_ioctl)(u_long, caddr_t, struct proc *) = _mrt_ioctl;
void
rsvp_input(struct mbuf *m, int iphlen) /* XXX must fixup manually */
static int X_ip_mrouter_get(struct socket *so, struct sockopt *m);
static int X_ip_mrouter_set(struct socket *so, struct sockopt *m);
static int X_legal_vif_num(int vif);
-static int X_mrt_ioctl(int cmd, caddr_t data);
+static int X_mrt_ioctl(u_long cmd, caddr_t data);
static int get_sg_cnt(struct sioc_sg_req *);
static int get_vif_cnt(struct sioc_vif_req *);
* Handle ioctl commands to obtain information from the cache
*/
static int
-X_mrt_ioctl(int cmd, caddr_t data)
+X_mrt_ioctl(u_long cmd, caddr_t data)
{
int error = 0;
}
#if !defined(MROUTE_LKM) || !MROUTE_LKM
-int (*mrt_ioctl)(int, caddr_t) = X_mrt_ioctl;
+int (*mrt_ioctl)(u_long, caddr_t) = X_mrt_ioctl;
#endif
/*
ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
if (ifa == 0) return EADDRNOTAVAIL;
ifp = ifa->ifa_ifp;
- ifafree(ifa);
+ IFA_REMREF(ifa);
ifa = NULL;
if (vifcp->vifc_flags & VIFF_TUNNEL) {
* Set interface to fake encapsulator interface
*/
ifp = &multicast_decap_if[vifcp->vifc_vifi];
- /*
- * Prepare cached route entry
- */
- bzero(&vifp->v_route, sizeof(vifp->v_route));
} else {
log(LOG_ERR, "source routed tunnels not supported\n");
return EOPNOTSUPP;
return 1;
}
+ if (imo != NULL)
+ IMO_LOCK(imo);
if ((imo) && ((vifi = imo->imo_multicast_vif) < numvifs)) {
+ IMO_UNLOCK(imo);
if (ip->ip_ttl < 255)
ip->ip_ttl++; /* compensate for -1 in *_send routines */
if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) {
vifp = viftable + vifi;
- printf("Sending IPPROTO_RSVP from %x to %x on vif %d (%s%s%d)\n",
+ printf("Sending IPPROTO_RSVP from %x to %x on vif %d (%s%s)\n",
ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr), vifi,
(vifp->v_flags & VIFF_TUNNEL) ? "tunnel on " : "",
- vifp->v_ifp->if_name, vifp->v_ifp->if_unit);
+ if_name(vifp->v_ifp));
}
return (ip_mdq(m, ifp, NULL, vifi));
+ } else if (imo != NULL) {
+ IMO_UNLOCK(imo);
}
if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) {
printf("Warning: IPPROTO_RSVP from %x to %x without vif option\n",
*/
ip_copy = mtod(mb_copy, struct ip *);
*ip_copy = multicast_encap_iphdr;
-#if RANDOM_IP_ID
ip_copy->ip_id = ip_randomid();
-#else
- ip_copy->ip_id = htons(ip_id++);
-#endif
ip_copy->ip_len += len;
ip_copy->ip_src = vifp->v_lcl_addr;
ip_copy->ip_dst = vifp->v_rmt_addr;
static void
tbf_send_packet(struct vif *vifp, struct mbuf *m)
{
- struct ip_moptions imo;
int error;
- static struct route ro;
+ struct route ro;
+ bzero(&ro, sizeof (ro));
if (vifp->v_flags & VIFF_TUNNEL) {
/* If tunnel options */
- ip_output(m, (struct mbuf *)0, &vifp->v_route,
+ ip_output(m, (struct mbuf *)0, &ro,
IP_FORWARDING, (struct ip_moptions *)0, NULL);
} else {
- imo.imo_multicast_ifp = vifp->v_ifp;
- imo.imo_multicast_ttl = mtod(m, struct ip *)->ip_ttl - 1;
- imo.imo_multicast_loop = 1;
- imo.imo_multicast_vif = -1;
+ struct ip_moptions *imo;
+
+ imo = ip_allocmoptions(M_DONTWAIT);
+ if (imo == NULL) {
+ error = ENOMEM;
+ goto done;
+ }
+
+ imo->imo_multicast_ifp = vifp->v_ifp;
+ imo->imo_multicast_ttl = mtod(m, struct ip *)->ip_ttl - 1;
+ imo->imo_multicast_loop = 1;
+ imo->imo_multicast_vif = -1;
/*
* Re-entrancy should not be a problem here, because
* the loopback interface, thus preventing looping.
*/
error = ip_output(m, (struct mbuf *)0, &ro,
- IP_FORWARDING, &imo, NULL);
+ IP_FORWARDING, imo, NULL);
+ IMO_REMREF(imo);
+done:
if (mrtdebug & DEBUG_XMIT)
log(LOG_DEBUG, "phyint_send on vif %d err %d\n",
vifp - viftable, error);
}
+ ROUTE_RELEASE(&ro);
}
/* determine the current time and then
static int (*old_mrt_ioctl)();
static void (*old_proto4_input)();
static int (*old_legal_vif_num)();
- extern struct protosw inetsw[];
case LKM_E_LOAD:
if(lkmexists(lkmtp) || ip_mrtproto)