patch-2.1.120 linux/net/ipv4/fib_semantics.c

Next file: linux/net/ipv4/icmp.c
Previous file: linux/net/ipv4/fib_rules.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.119/linux/net/ipv4/fib_semantics.c linux/net/ipv4/fib_semantics.c
@@ -5,7 +5,7 @@
  *
  *		IPv4 Forwarding Information Base: semantics.
  *
- * Version:	$Id: fib_semantics.c,v 1.9 1998/06/11 03:15:41 davem Exp $
+ * Version:	$Id: fib_semantics.c,v 1.10 1998/08/26 12:03:32 davem Exp $
  *
  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  *
@@ -181,7 +181,6 @@
 	return 0;
 }
 
-#ifndef CONFIG_RTNL_OLD_IFINFO
 static int
 fib_count_nexthops(struct rtattr *rta)
 {
@@ -189,7 +188,7 @@
 	struct rtnexthop *nhp = RTA_DATA(rta);
 	int nhlen = RTA_PAYLOAD(rta);
 
-	while (nhlen >= sizeof(struct rtnexthop)) {
+	while (nhlen >= (int)sizeof(struct rtnexthop)) {
 		if ((nhlen -= nhp->rtnh_len) < 0)
 			return 0;
 		nhs++;
@@ -197,21 +196,12 @@
 	};
 	return nhs;
 }
-#endif
 
-#ifdef CONFIG_RTNL_OLD_IFINFO
-static int
-fib_get_nhs(struct fib_info *fi, const struct nlmsghdr *nlh, const struct rtmsg *r)
-{
-	struct rtnexthop *nhp = RTM_RTNH(r);
-	int nhlen = RTM_NHLEN(nlh, r);
-#else
 static int
 fib_get_nhs(struct fib_info *fi, const struct rtattr *rta, const struct rtmsg *r)
 {
 	struct rtnexthop *nhp = RTA_DATA(rta);
 	int nhlen = RTA_PAYLOAD(rta);
-#endif
 
 	change_nexthops(fi) {
 		int attrlen = nhlen - sizeof(struct rtnexthop);
@@ -249,18 +239,10 @@
 	}
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	if (r->rtm_nhs == 0)
-		return 0;
-
-	nhp = RTM_RTNH(r);
-	nhlen = RTM_NHLEN(nlh, r);
-#else
 	if (rta->rta_mp == NULL)
 		return 0;
 	nhp = RTA_DATA(rta->rta_mp);
 	nhlen = RTA_PAYLOAD(rta->rta_mp);
-#endif
 	
 	for_nexthops(fi) {
 		int attrlen = nhlen - sizeof(struct rtnexthop);
@@ -397,11 +379,7 @@
 	struct fib_info *fi = NULL;
 	struct fib_info *ofi;
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	int nhs = r->rtm_nhs ? : 1;
-#else
 	int nhs = 1;
-#endif
 #else
 	const int nhs = 1;
 #endif
@@ -411,14 +389,12 @@
 		goto err_inval;
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
-#ifndef CONFIG_RTNL_OLD_IFINFO
 	if (rta->rta_mp) {
 		nhs = fib_count_nexthops(rta->rta_mp);
 		if (nhs == 0)
 			goto err_inval;
 	}
 #endif
-#endif
 
 	fi = kmalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
 	err = -ENOBUFS;
@@ -429,14 +405,6 @@
 	fi->fib_protocol = r->rtm_protocol;
 	fi->fib_nhs = nhs;
 	fi->fib_flags = r->rtm_flags;
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	if (rta->rta_mtu)
-		fi->fib_mtu = *rta->rta_mtu;
-	if (rta->rta_rtt)
-		fi->fib_rtt = *rta->rta_rtt;
-	if (rta->rta_window)
-		fi->fib_window = *rta->rta_window;
-#else
 	if (rta->rta_mx) {
 		int attrlen = RTA_PAYLOAD(rta->rta_mx);
 		struct rtattr *attr = RTA_DATA(rta->rta_mx);
@@ -451,21 +419,12 @@
 			attr = RTA_NEXT(attr, attrlen);
 		}
 	}
-#endif
 	if (rta->rta_prefsrc)
 		memcpy(&fi->fib_prefsrc, rta->rta_prefsrc, 4);
 
-#ifndef CONFIG_RTNL_OLD_IFINFO
 	if (rta->rta_mp) {
-#else
-	if (r->rtm_nhs) {
-#endif
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
-#ifdef CONFIG_RTNL_OLD_IFINFO
-		if ((err = fib_get_nhs(fi, nlh, r)) != 0)
-#else
 		if ((err = fib_get_nhs(fi, rta->rta_mp, r)) != 0)
-#endif
 			goto failure;
 		if (rta->rta_oif && fi->fib_nh->nh_oif != *rta->rta_oif)
 			goto err_inval;
@@ -504,11 +463,7 @@
 #endif
 
 	if (fib_props[r->rtm_type].error) {
-#ifndef CONFIG_RTNL_OLD_IFINFO
 		if (rta->rta_gw || rta->rta_oif || rta->rta_mp)
-#else
-		if (rta->rta_gw || rta->rta_oif || r->rtm_nhs)
-#endif
 			goto err_inval;
 		goto link_it;
 	}
@@ -637,16 +592,13 @@
 #ifdef CONFIG_RTNETLINK
 
 int
-fib_dump_info(struct sk_buff *skb, pid_t pid, u32 seq, int event,
+fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
 	      u8 tb_id, u8 type, u8 scope, void *dst, int dst_len, u8 tos,
 	      struct fib_info *fi)
 {
 	struct rtmsg *rtm;
 	struct nlmsghdr  *nlh;
 	unsigned char	 *b = skb->tail;
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	unsigned char 	 *o;
-#endif
 
 	nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*rtm));
 	rtm = NLMSG_DATA(nlh);
@@ -658,22 +610,9 @@
 	rtm->rtm_type = type;
 	rtm->rtm_flags = fi->fib_flags;
 	rtm->rtm_scope = scope;
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	rtm->rtm_nhs = 0;
-
-	o = skb->tail;
-#endif
 	if (rtm->rtm_dst_len)
 		RTA_PUT(skb, RTA_DST, 4, dst);
 	rtm->rtm_protocol = fi->fib_protocol;
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	if (fi->fib_mtu)
-		RTA_PUT(skb, RTA_MTU, sizeof(unsigned), &fi->fib_mtu);
-	if (fi->fib_window)
-		RTA_PUT(skb, RTA_WINDOW, sizeof(unsigned), &fi->fib_window);
-	if (fi->fib_rtt)
-		RTA_PUT(skb, RTA_RTT, sizeof(unsigned), &fi->fib_rtt);
-#else
 #ifdef CONFIG_NET_CLS_ROUTE
 	if (fi->fib_nh[0].nh_tclassid)
 		RTA_PUT(skb, RTA_FLOW, 4, &fi->fib_nh[0].nh_tclassid);
@@ -688,7 +627,6 @@
 		}
 		mx->rta_len = skb->tail - (u8*)mx;
 	}
-#endif
 	if (fi->fib_prefsrc)
 		RTA_PUT(skb, RTA_PREFSRC, 4, &fi->fib_prefsrc);
 	if (fi->fib_nhs == 1) {
@@ -697,18 +635,14 @@
 		if (fi->fib_nh->nh_oif)
 			RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif);
 	}
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	rtm->rtm_optlen = skb->tail - o;
-#endif
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	if (fi->fib_nhs > 1) {
 		struct rtnexthop *nhp;
-#ifndef CONFIG_RTNL_OLD_IFINFO
 		struct rtattr *mp_head;
 		if (skb_tailroom(skb) <= RTA_SPACE(0))
 			goto rtattr_failure;
 		mp_head = (struct rtattr*)skb_put(skb, RTA_SPACE(0));
-#endif
+
 		for_nexthops(fi) {
 			if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
 				goto rtattr_failure;
@@ -719,14 +653,9 @@
 			if (nh->nh_gw)
 				RTA_PUT(skb, RTA_GATEWAY, 4, &nh->nh_gw);
 			nhp->rtnh_len = skb->tail - (unsigned char*)nhp;
-#ifdef CONFIG_RTNL_OLD_IFINFO
-			rtm->rtm_nhs++;
-#endif
 		} endfor_nexthops(fi);
-#ifndef CONFIG_RTNL_OLD_IFINFO
 		mp_head->rta_type = RTA_MULTIPATH;
 		mp_head->rta_len = skb->tail - (u8*)mp_head;
-#endif
 	}
 #endif
 	nlh->nlmsg_len = skb->tail - b;
@@ -848,24 +777,6 @@
 	if (r->rt_flags&RTF_GATEWAY && rta->rta_gw == NULL)
 		return -EINVAL;
 
-#ifdef CONFIG_RTNL_OLD_IFINFO
-	/* Ugly conversion from rtentry types to unsigned */
-
-	if (r->rt_flags&RTF_IRTT) {
-		rta->rta_rtt = (unsigned*)&r->rt_pad3;
-		*rta->rta_rtt = r->rt_irtt;
-	}
-	if (r->rt_flags&RTF_WINDOW) {
-		rta->rta_window = (unsigned*)&r->rt_window;
-		if (sizeof(*rta->rta_window) != sizeof(r->rt_window))
-			*rta->rta_window = r->rt_window;
-	}
-	if (r->rt_flags&RTF_MTU) {
-		rta->rta_mtu = (unsigned*)&r->rt_mtu;
-		if (sizeof(*rta->rta_mtu) != sizeof(r->rt_mtu))
-			*rta->rta_mtu = r->rt_mtu;
-	}
-#else
 	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);
@@ -896,7 +807,6 @@
 			*(u32*)RTA_DATA(rec) = r->rt_irtt;
 		}
 	}
-#endif
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov