nl->nlmsg_pid = 0; 
nl->nlmsg_pid = current->pid; 
fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm,		    struct kern_rta *rta, struct rtentry *r){	int    plen;	u32    *ptr;	memset(rtm, 0, sizeof(*rtm));	memset(rta, 0, sizeof(*rta));	if (r->rt_dst.sa_family != AF_INET)		return -EAFNOSUPPORT;	/* Check mask for validity:	   a) it must be contiguous.	   b) destination must have all host bits clear.	   c) if application forgot to set correct family (AF_INET),	      reject request unless it is absolutely clear i.e.	      both family and mask are zero.	 */	plen = 32;	ptr = &((struct sockaddr_in*)&r->rt_dst)->sin_addr.s_addr;	if (!(r->rt_flags&RTF_HOST)) {		u32 mask = ((struct sockaddr_in*)&r->rt_genmask)->sin_addr.s_addr;		if (r->rt_genmask.sa_family != AF_INET) {			if (mask || r->rt_genmask.sa_family)				return -EAFNOSUPPORT;		}		if (bad_mask(mask, *ptr))			return -EINVAL;		plen = inet_mask_len(mask);	}	nl->nlmsg_flags = NLM_F_REQUEST;	nl->nlmsg_pid = 0;	nl->nlmsg_seq = 0;	nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));	if (cmd == SIOCDELRT) {		nl->nlmsg_type = RTM_DELROUTE;		nl->nlmsg_flags = 0;	} else {		nl->nlmsg_type = RTM_NEWROUTE;		nl->nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE;		rtm->rtm_protocol = RTPROT_BOOT;	}	rtm->rtm_dst_len = plen;	rta->rta_dst = ptr;	if (r->rt_metric) {		*(u32*)&r->rt_pad3 = r->rt_metric - 1;		rta->rta_priority = (u32*)&r->rt_pad3;	}	if (r->rt_flags&RTF_REJECT) {		rtm->rtm_scope = RT_SCOPE_HOST;		rtm->rtm_type = RTN_UNREACHABLE;		return 0;	}	rtm->rtm_scope = RT_SCOPE_NOWHERE;	rtm->rtm_type = RTN_UNICAST;	if (r->rt_dev) {		char *colon;		struct net_device *dev;		char   devname[IFNAMSIZ];		if (copy_from_user(devname, r->rt_dev, IFNAMSIZ-1))			return -EFAULT;		devname[IFNAMSIZ-1] = 0;		colon = strchr(devname, ':');		if (colon)			*colon = 0;		dev = __dev_get_by_name(devname);		if (!dev)			return -ENODEV;		rta->rta_oif = &dev->ifindex;		if (colon) {			struct in_ifaddr *ifa;			struct in_device *in_dev = __in_dev_get(dev);			if (!in_dev)				return -ENODEV;			*colon = ':';			for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next)				if (strcmp(ifa->ifa_label, devname) == 0)					break;			if (ifa == NULL)				return -ENODEV;			rta->rta_prefsrc = &ifa->ifa_local;		}	}	ptr = &((struct sockaddr_in*)&r->rt_gateway)->sin_addr.s_addr;	if (r->rt_gateway.sa_family == AF_INET && *ptr) {		rta->rta_gw = ptr;		if (r->rt_flags&RTF_GATEWAY && inet_addr_type(*ptr) == RTN_UNICAST)			rtm->rtm_scope = RT_SCOPE_UNIVERSE;	}	if (cmd == SIOCDELRT)		return 0;	if (r->rt_flags&RTF_GATEWAY && rta->rta_gw == NULL)		return -EINVAL;	if (rtm->rtm_scope == RT_SCOPE_NOWHERE)		rtm->rtm_scope = RT_SCOPE_LINK;	if (r->rt_flags&(RTF_MTU|RTF_WINDOW|RTF_IRTT)) {		struct rtattr *rec;		struct rtattr *mx = kmalloc(RTA_LENGTH(3*RTA_LENGTH(4)), GFP_KERNEL);		if (mx == NULL)			return -ENOMEM;		rta->rta_mx = mx;		mx->rta_type = RTA_METRICS;		mx->rta_len  = RTA_LENGTH(0);		if (r->rt_flags&RTF_MTU) {			rec = (void*)((char*)mx + RTA_ALIGN(mx->rta_len));			rec->rta_type = RTAX_ADVMSS;			rec->rta_len = RTA_LENGTH(4);			mx->rta_len += RTA_LENGTH(4);			*(u32*)RTA_DATA(rec) = r->rt_mtu - 40;		}		if (r->rt_flags&RTF_WINDOW) {			rec = (void*)((char*)mx + RTA_ALIGN(mx->rta_len));			rec->rta_type = RTAX_WINDOW;			rec->rta_len = RTA_LENGTH(4);			mx->rta_len += RTA_LENGTH(4);			*(u32*)RTA_DATA(rec) = r->rt_window;		}		if (r->rt_flags&RTF_IRTT) {			rec = (void*)((char*)mx + RTA_ALIGN(mx->rta_len));			rec->rta_type = RTAX_RTT;			rec->rta_len = RTA_LENGTH(4);			mx->rta_len += RTA_LENGTH(4);			*(u32*)RTA_DATA(rec) = r->rt_irtt<<3;		}	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/9ed19f339e12e731986de84134ac293cd15910a7/fib_semantics.c/buggy/net/ipv4/fib_semantics.c