Author: mguevara                     Date: Thu Feb 21 12:56:22 2008 GMT
Module: SOURCES                       Tag: LINUX_2_6
---- Log message:
- http://www.ssi.bg/~ja/routes-2.6.24-15.diff
- obsoletes kernel-routes-2.6.22-15.diff for 2.6.24.x

---- Files affected:
SOURCES:
   kernel-routes-2.6.24-15.diff (NONE -> 1.1.2.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/kernel-routes-2.6.24-15.diff
diff -u /dev/null SOURCES/kernel-routes-2.6.24-15.diff:1.1.2.1
--- /dev/null   Thu Feb 21 13:56:22 2008
+++ SOURCES/kernel-routes-2.6.24-15.diff        Thu Feb 21 13:56:17 2008
@@ -0,0 +1,1221 @@
+diff -urp v2.6.24/linux/include/linux/rtnetlink.h 
linux/include/linux/rtnetlink.h
+--- v2.6.24/linux/include/linux/rtnetlink.h    2008-01-25 10:45:05.000000000 
+0200
++++ linux/include/linux/rtnetlink.h    2008-01-27 16:03:55.000000000 +0200
+@@ -296,6 +296,8 @@ struct rtnexthop
+ #define RTNH_F_DEAD           1       /* Nexthop is dead (used by multipath)  
*/
+ #define RTNH_F_PERVASIVE      2       /* Do recursive gateway lookup  */
+ #define RTNH_F_ONLINK         4       /* Gateway is forced on link    */
++#define RTNH_F_SUSPECT                8       /* We don't know the real state 
*/
++#define RTNH_F_BADSTATE               (RTNH_F_DEAD | RTNH_F_SUSPECT)
+ 
+ /* Macros to handle hexthops */
+ 
+diff -urp v2.6.24/linux/include/net/flow.h linux/include/net/flow.h
+--- v2.6.24/linux/include/net/flow.h   2007-10-10 11:12:13.000000000 +0300
++++ linux/include/net/flow.h   2008-01-27 16:04:16.000000000 +0200
+@@ -19,6 +19,8 @@ struct flowi {
+               struct {
+                       __be32                  daddr;
+                       __be32                  saddr;
++                      __be32                  lsrc;
++                      __be32                  gw;
+                       __u8                    tos;
+                       __u8                    scope;
+               } ip4_u;
+@@ -43,6 +45,8 @@ struct flowi {
+ #define fl6_flowlabel nl_u.ip6_u.flowlabel
+ #define fl4_dst               nl_u.ip4_u.daddr
+ #define fl4_src               nl_u.ip4_u.saddr
++#define fl4_lsrc      nl_u.ip4_u.lsrc
++#define fl4_gw                nl_u.ip4_u.gw
+ #define fl4_tos               nl_u.ip4_u.tos
+ #define fl4_scope     nl_u.ip4_u.scope
+ 
+diff -urp v2.6.24/linux/include/net/ip_fib.h linux/include/net/ip_fib.h
+--- v2.6.24/linux/include/net/ip_fib.h 2008-01-25 10:45:05.000000000 +0200
++++ linux/include/net/ip_fib.h 2008-01-27 16:03:55.000000000 +0200
+@@ -180,7 +180,8 @@ static inline int fib_lookup(const struc
+ 
+ static inline void fib_select_default(const struct flowi *flp, struct 
fib_result *res)
+ {
+-      if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK)
++      if ((FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) ||
++          FIB_RES_NH(*res).nh_scope == RT_SCOPE_HOST)
+               ip_fib_main_table->tb_select_default(ip_fib_main_table, flp, 
res);
+ }
+ 
+@@ -199,6 +200,7 @@ extern int fib_lookup(struct flowi *flp,
+ extern struct fib_table *fib_new_table(u32 id);
+ extern struct fib_table *fib_get_table(u32 id);
+ extern void fib_select_default(const struct flowi *flp, struct fib_result 
*res);
++extern int fib_result_table(struct fib_result *res);
+ 
+ #endif /* CONFIG_IP_MULTIPLE_TABLES */
+ 
+@@ -259,4 +261,6 @@ extern int  fib_proc_init(void);
+ extern void fib_proc_exit(void);
+ #endif
+ 
++extern rwlock_t fib_nhflags_lock;
++
+ #endif  /* _NET_FIB_H */
+diff -urp v2.6.24/linux/include/net/netfilter/nf_nat.h 
linux/include/net/netfilter/nf_nat.h
+--- v2.6.24/linux/include/net/netfilter/nf_nat.h       2007-10-10 
11:12:13.000000000 +0300
++++ linux/include/net/netfilter/nf_nat.h       2008-01-27 16:04:16.000000000 
+0200
+@@ -76,6 +76,13 @@ struct nf_conn_nat
+ #endif
+ };
+ 
++/* Call input routing for SNAT-ed traffic */
++extern unsigned int ip_nat_route_input(unsigned int hooknum,
++                                     struct sk_buff *skb,
++                                     const struct net_device *in,
++                                     const struct net_device *out,
++                                     int (*okfn)(struct sk_buff *));
++
+ /* Set up the info structure to map into this range. */
+ extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
+                                     const struct nf_nat_range *range,
+diff -urp v2.6.24/linux/include/net/route.h linux/include/net/route.h
+--- v2.6.24/linux/include/net/route.h  2008-01-25 10:45:05.000000000 +0200
++++ linux/include/net/route.h  2008-01-27 16:04:16.000000000 +0200
+@@ -114,6 +114,7 @@ extern int         __ip_route_output_key(struct
+ extern int            ip_route_output_key(struct rtable **, struct flowi 
*flp);
+ extern int            ip_route_output_flow(struct rtable **rp, struct flowi 
*flp, struct sock *sk, int flags);
+ extern int            ip_route_input(struct sk_buff*, __be32 dst, __be32 src, 
u8 tos, struct net_device *devin);
++extern int            ip_route_input_lookup(struct sk_buff*, __be32 dst, 
__be32 src, u8 tos, struct net_device *devin, __be32 lsrc);
+ extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short 
new_mtu);
+ extern void           ip_rt_send_redirect(struct sk_buff *skb);
+ 
+diff -urp v2.6.24/linux/net/bridge/br_netfilter.c 
linux/net/bridge/br_netfilter.c
+--- v2.6.24/linux/net/bridge/br_netfilter.c    2008-01-25 10:45:06.000000000 
+0200
++++ linux/net/bridge/br_netfilter.c    2008-01-27 16:04:16.000000000 +0200
+@@ -324,6 +324,10 @@ static int br_nf_pre_routing_finish(stru
+       struct nf_bridge_info *nf_bridge = skb->nf_bridge;
+       int err;
+ 
++      /* Old skb->dst is not expected, it is lost in all cases */
++      dst_release(skb->dst);
++      skb->dst = NULL;
++
+       if (nf_bridge->mask & BRNF_PKT_TYPE) {
+               skb->pkt_type = PACKET_OTHERHOST;
+               nf_bridge->mask ^= BRNF_PKT_TYPE;
+diff -urp v2.6.24/linux/net/ipv4/fib_frontend.c linux/net/ipv4/fib_frontend.c
+--- v2.6.24/linux/net/ipv4/fib_frontend.c      2008-01-25 10:45:06.000000000 
+0200
++++ linux/net/ipv4/fib_frontend.c      2008-01-27 16:03:55.000000000 +0200
+@@ -59,6 +59,8 @@ struct fib_table *ip_fib_main_table;
+ #define FIB_TABLE_HASHSZ 1
+ static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ];
+ 
++#define FIB_RES_TABLE(r) (RT_TABLE_MAIN)
++
+ static void __init fib4_rules_init(void)
+ {
+       ip_fib_local_table = fib_hash_init(RT_TABLE_LOCAL);
+@@ -68,6 +70,8 @@ static void __init fib4_rules_init(void)
+ }
+ #else
+ 
++#define FIB_RES_TABLE(r) (fib_result_table(r))
++
+ #define FIB_TABLE_HASHSZ 256
+ static struct hlist_head fib_table_hash[FIB_TABLE_HASHSZ];
+ 
+@@ -200,6 +204,9 @@ int fib_validate_source(__be32 src, __be
+                                       .tos = tos } },
+                           .iif = oif };
+       struct fib_result res;
++      int table;
++      unsigned char prefixlen;
++      unsigned char scope;
+       int no_addr, rpf;
+       int ret;
+ 
+@@ -221,31 +228,35 @@ int fib_validate_source(__be32 src, __be
+               goto e_inval_res;
+       *spec_dst = FIB_RES_PREFSRC(res);
+       fib_combine_itag(itag, &res);
+-#ifdef CONFIG_IP_ROUTE_MULTIPATH
+-      if (FIB_RES_DEV(res) == dev || res.fi->fib_nhs > 1)
+-#else
+       if (FIB_RES_DEV(res) == dev)
+-#endif
+       {
+               ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
+               fib_res_put(&res);
+               return ret;
+       }
++      table = FIB_RES_TABLE(&res);
++      prefixlen = res.prefixlen;
++      scope = res.scope;
+       fib_res_put(&res);
+       if (no_addr)
+               goto last_resort;
+-      if (rpf)
+-              goto e_inval;
+       fl.oif = dev->ifindex;
+ 
+       ret = 0;
+       if (fib_lookup(&fl, &res) == 0) {
+-              if (res.type == RTN_UNICAST) {
++              if (res.type == RTN_UNICAST &&
++                  ((table == FIB_RES_TABLE(&res) &&
++                    res.prefixlen >= prefixlen && res.scope >= scope) ||
++                   !rpf)) {
+                       *spec_dst = FIB_RES_PREFSRC(res);
+                       ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
++                      fib_res_put(&res);
++                      return ret;
+               }
+               fib_res_put(&res);
+       }
++      if (rpf)
++              goto e_inval;
+       return ret;
+ 
+ last_resort:
+@@ -844,9 +855,7 @@ static int fib_inetaddr_event(struct not
+       switch (event) {
+       case NETDEV_UP:
+               fib_add_ifaddr(ifa);
+-#ifdef CONFIG_IP_ROUTE_MULTIPATH
+               fib_sync_up(ifa->ifa_dev->dev);
+-#endif
+               rt_cache_flush(-1);
+               break;
+       case NETDEV_DOWN:
+@@ -885,9 +894,7 @@ static int fib_netdev_event(struct notif
+               for_ifa(in_dev) {
+                       fib_add_ifaddr(ifa);
+               } endfor_ifa(in_dev);
+-#ifdef CONFIG_IP_ROUTE_MULTIPATH
+               fib_sync_up(dev);
+-#endif
+               rt_cache_flush(-1);
+               break;
+       case NETDEV_DOWN:
+diff -urp v2.6.24/linux/net/ipv4/fib_hash.c linux/net/ipv4/fib_hash.c
+--- v2.6.24/linux/net/ipv4/fib_hash.c  2008-01-25 10:45:06.000000000 +0200
++++ linux/net/ipv4/fib_hash.c  2008-01-27 16:03:55.000000000 +0200
+@@ -275,30 +275,38 @@ out:
+       return err;
+ }
+ 
+-static int fn_hash_last_dflt=-1;
+-
+ static void
+ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct 
fib_result *res)
+ {
+-      int order, last_idx;
++      int order, last_idx, last_dflt, last_nhsel;
++      struct fib_alias *first_fa = NULL;
++      struct hlist_head *head;
+       struct hlist_node *node;
+       struct fib_node *f;
+       struct fib_info *fi = NULL;
+       struct fib_info *last_resort;
+       struct fn_hash *t = (struct fn_hash*)tb->tb_data;
+-      struct fn_zone *fz = t->fn_zones[0];
++      struct fn_zone *fz = t->fn_zones[res->prefixlen];
++      __be32 k;
+ 
+       if (fz == NULL)
+               return;
+ 
++      k = fz_key(flp->fl4_dst, fz);
++      last_dflt = -2;
++      last_nhsel = 0;
+       last_idx = -1;
+       last_resort = NULL;
+       order = -1;
+ 
+       read_lock(&fib_hash_lock);
+-      hlist_for_each_entry(f, node, &fz->fz_hash[0], fn_hash) {
++      head = &fz->fz_hash[fn_hash(k, fz)];
++      hlist_for_each_entry(f, node, head, fn_hash) {
+               struct fib_alias *fa;
+ 
++              if (f->fn_key != k)
++                      continue;
++
+               list_for_each_entry(fa, &f->fn_alias, fa_list) {
+                       struct fib_info *next_fi = fa->fa_info;
+ 
+@@ -306,41 +314,52 @@ fn_hash_select_default(struct fib_table 
+                           fa->fa_type != RTN_UNICAST)
+                               continue;
+ 
++                      if (fa->fa_tos &&
++                          fa->fa_tos != flp->fl4_tos)
++                              continue;
+                       if (next_fi->fib_priority > res->fi->fib_priority)
+                               break;
+-                      if (!next_fi->fib_nh[0].nh_gw ||
+-                          next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK)
+-                              continue;
+                       fa->fa_state |= FA_S_ACCESSED;
+ 
+-                      if (fi == NULL) {
+-                              if (next_fi != res->fi)
+-                                      break;
+-                      } else if (!fib_detect_death(fi, order, &last_resort,
+-                                                   &last_idx, 
&fn_hash_last_dflt)) {
++                      if (!first_fa) {
++                              last_dflt = fa->fa_last_dflt;
++                              first_fa = fa;
++                      }
++                      if (fi && !fib_detect_death(fi, order, &last_resort,
++                              &last_idx, &last_dflt, &last_nhsel, flp)) {
+                               if (res->fi)
+                                       fib_info_put(res->fi);
+                               res->fi = fi;
+                               atomic_inc(&fi->fib_clntref);
+-                              fn_hash_last_dflt = order;
++                              first_fa->fa_last_dflt = order;
+                               goto out;
+                       }
+                       fi = next_fi;
+                       order++;
+               }
++              break;
+       }
+ 
+       if (order <= 0 || fi == NULL) {
+-              fn_hash_last_dflt = -1;
++              if (fi && fi->fib_nhs > 1 &&
++                  fib_detect_death(fi, order, &last_resort, &last_idx,
++                      &last_dflt, &last_nhsel, flp) &&
++                  last_resort == fi) {
++                      read_lock_bh(&fib_nhflags_lock);
++                      fi->fib_nh[last_nhsel].nh_flags &= ~RTNH_F_SUSPECT;
++                      read_unlock_bh(&fib_nhflags_lock);
++              }
++              if (first_fa) first_fa->fa_last_dflt = -1;
+               goto out;
+       }
+ 
+-      if (!fib_detect_death(fi, order, &last_resort, &last_idx, 
&fn_hash_last_dflt)) {
++      if (!fib_detect_death(fi, order, &last_resort, &last_idx,
++                            &last_dflt, &last_nhsel, flp)) {
+               if (res->fi)
+                       fib_info_put(res->fi);
+               res->fi = fi;
+               atomic_inc(&fi->fib_clntref);
+-              fn_hash_last_dflt = order;
++              first_fa->fa_last_dflt = order;
+               goto out;
+       }
+ 
+@@ -350,8 +369,11 @@ fn_hash_select_default(struct fib_table 
+               res->fi = last_resort;
+               if (last_resort)
+                       atomic_inc(&last_resort->fib_clntref);
++              read_lock_bh(&fib_nhflags_lock);
++              last_resort->fib_nh[last_nhsel].nh_flags &= ~RTNH_F_SUSPECT;
++              read_unlock_bh(&fib_nhflags_lock);
++              first_fa->fa_last_dflt = last_idx;
+       }
+-      fn_hash_last_dflt = last_idx;
+ out:
+       read_unlock(&fib_hash_lock);
+ }
+@@ -450,6 +472,7 @@ static int fn_hash_insert(struct fib_tab
+                       write_lock_bh(&fib_hash_lock);
+                       fi_drop = fa->fa_info;
+                       fa->fa_info = fi;
++                      fa->fa_last_dflt = -1;
+                       fa->fa_type = cfg->fc_type;
+                       fa->fa_scope = cfg->fc_scope;
+                       state = fa->fa_state;
+@@ -511,6 +534,7 @@ static int fn_hash_insert(struct fib_tab
+       new_fa->fa_type = cfg->fc_type;
+       new_fa->fa_scope = cfg->fc_scope;
+       new_fa->fa_state = 0;
++      new_fa->fa_last_dflt = -1;
+ 
+       /*
+        * Insert new entry to the list.
+diff -urp v2.6.24/linux/net/ipv4/fib_lookup.h linux/net/ipv4/fib_lookup.h
+--- v2.6.24/linux/net/ipv4/fib_lookup.h        2007-07-10 09:18:43.000000000 
+0300
++++ linux/net/ipv4/fib_lookup.h        2008-01-27 16:03:55.000000000 +0200
+@@ -9,6 +9,7 @@ struct fib_alias {
+       struct list_head        fa_list;
+       struct rcu_head rcu;
+       struct fib_info         *fa_info;
++      int                     fa_last_dflt;
+       u8                      fa_tos;
+       u8                      fa_type;
+       u8                      fa_scope;
+@@ -36,6 +37,7 @@ extern struct fib_alias *fib_find_alias(
+                                       u8 tos, u32 prio);
+ extern int fib_detect_death(struct fib_info *fi, int order,
+                           struct fib_info **last_resort,
+-                          int *last_idx, int *dflt);
++                          int *last_idx, int *dflt, int *last_nhsel,
++                          const struct flowi *flp);
+ 
+ #endif /* _FIB_LOOKUP_H */
+diff -urp v2.6.24/linux/net/ipv4/fib_rules.c linux/net/ipv4/fib_rules.c
+--- v2.6.24/linux/net/ipv4/fib_rules.c 2008-01-25 10:45:06.000000000 +0200
++++ linux/net/ipv4/fib_rules.c 2008-01-27 16:03:55.000000000 +0200
+@@ -56,6 +56,11 @@ u32 fib_rules_tclass(struct fib_result *
+ }
+ #endif
+ 
++int fib_result_table(struct fib_result *res)
++{
++      return res->r->table;
++}
++
+ int fib_lookup(struct flowi *flp, struct fib_result *res)
+ {
+       struct fib_lookup_arg arg = {
+@@ -107,7 +112,8 @@ errout:
+ void fib_select_default(const struct flowi *flp, struct fib_result *res)
+ {
+       if (res->r && res->r->action == FR_ACT_TO_TBL &&
+-          FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) {
++          ((FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) ||
++           FIB_RES_NH(*res).nh_scope == RT_SCOPE_HOST)) {
+               struct fib_table *tb;
+               if ((tb = fib_get_table(res->r->table)) != NULL)
+                       tb->tb_select_default(tb, flp, res);
+diff -urp v2.6.24/linux/net/ipv4/fib_semantics.c linux/net/ipv4/fib_semantics.c
+--- v2.6.24/linux/net/ipv4/fib_semantics.c     2008-01-25 10:45:06.000000000 
+0200
++++ linux/net/ipv4/fib_semantics.c     2008-01-27 16:04:16.000000000 +0200
+@@ -54,6 +54,7 @@ static struct hlist_head *fib_info_hash;
+ static struct hlist_head *fib_info_laddrhash;
+ static unsigned int fib_hash_size;
+ static unsigned int fib_info_cnt;
++rwlock_t fib_nhflags_lock = RW_LOCK_UNLOCKED;
+ 
+ #define DEVINDEX_HASHBITS 8
+ #define DEVINDEX_HASHSIZE (1U << DEVINDEX_HASHBITS)
+@@ -189,7 +190,7 @@ static __inline__ int nh_comp(const stru
+ #ifdef CONFIG_NET_CLS_ROUTE
+                   nh->nh_tclassid != onh->nh_tclassid ||
+ #endif
+-                  ((nh->nh_flags^onh->nh_flags)&~RTNH_F_DEAD))
++                  ((nh->nh_flags^onh->nh_flags)&~RTNH_F_BADSTATE))
+                       return -1;
+               onh++;
+       } endfor_nexthops(fi);
+@@ -226,7 +227,7 @@ static struct fib_info *fib_find_info(co
+                   nfi->fib_priority == fi->fib_priority &&
+                   memcmp(nfi->fib_metrics, fi->fib_metrics,
+                          sizeof(fi->fib_metrics)) == 0 &&
+-                  ((nfi->fib_flags^fi->fib_flags)&~RTNH_F_DEAD) == 0 &&
++                  ((nfi->fib_flags^fi->fib_flags)&~RTNH_F_BADSTATE) == 0 &&
+                   (nfi->fib_nhs == 0 || nh_comp(fi, nfi) == 0))
+                       return fi;
+       }
+@@ -346,26 +347,70 @@ struct fib_alias *fib_find_alias(struct 
+ }
+ 
+ int fib_detect_death(struct fib_info *fi, int order,
+-                   struct fib_info **last_resort, int *last_idx, int *dflt)
++                   struct fib_info **last_resort, int *last_idx, int *dflt,
++                   int *last_nhsel, const struct flowi *flp)
+ {
+       struct neighbour *n;
+-      int state = NUD_NONE;
++      int nhsel;
++      int state;
++      struct fib_nh * nh;
++      __be32 dst;
++      int flag, dead = 1;
++
++      /* change_nexthops(fi) { */
++      for (nhsel = 0, nh = fi->fib_nh; nhsel < fi->fib_nhs; nh++, nhsel++) {
++              if (flp->oif && flp->oif != nh->nh_oif)
++                      continue;
++              if (flp->fl4_gw && flp->fl4_gw != nh->nh_gw && nh->nh_gw &&
++                  nh->nh_scope == RT_SCOPE_LINK)
++                      continue;
++              if (nh->nh_flags & RTNH_F_DEAD)
++                      continue;
+ 
+-      n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev);
+-      if (n) {
+-              state = n->nud_state;
+-              neigh_release(n);
+-      }
+-      if (state==NUD_REACHABLE)
+-              return 0;
+-      if ((state&NUD_VALID) && order != *dflt)
+-              return 0;
+-      if ((state&NUD_VALID) ||
+-          (*last_idx<0 && order > *dflt)) {
+-              *last_resort = fi;
+-              *last_idx = order;
++              flag = 0;
++              if (nh->nh_dev->flags & IFF_NOARP) {
++                      dead = 0;
++                      goto setfl;
++              }
++
++              dst = nh->nh_gw;
++              if (!nh->nh_gw || nh->nh_scope != RT_SCOPE_LINK)
++                      dst = flp->fl4_dst;
++
++              state = NUD_NONE;
++              n = neigh_lookup(&arp_tbl, &dst, nh->nh_dev);
++              if (n) {
++                      state = n->nud_state;
++                      neigh_release(n);
++              }
++              if (state==NUD_REACHABLE ||
++                      ((state&NUD_VALID) && order != *dflt)) {
++                      dead = 0;
++                      goto setfl;
++              }
++              if (!(state&NUD_VALID))
++                      flag = 1;
++              if (!dead)
++                      goto setfl;
++              if ((state&NUD_VALID) ||
++                  (*last_idx<0 && order >= *dflt)) {
++                      *last_resort = fi;
++                      *last_idx = order;
++                      *last_nhsel = nhsel;
++              }
++
++              setfl:
++
++              read_lock_bh(&fib_nhflags_lock);
++              if (flag)
++                      nh->nh_flags |= RTNH_F_SUSPECT;
++              else
++                      nh->nh_flags &= ~RTNH_F_SUSPECT;
++              read_unlock_bh(&fib_nhflags_lock);
+       }
+-      return 1;
++      /* } endfor_nexthops(fi) */
++
++      return dead;
+ }
+ 
+ #ifdef CONFIG_IP_ROUTE_MULTIPATH
+@@ -535,8 +580,11 @@ static int fib_check_nh(struct fib_confi
+                               return -EINVAL;
+                       if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) 
== NULL)
+                               return -ENODEV;
+-                      if (!(dev->flags&IFF_UP))
+-                              return -ENETDOWN;
++                      if (!(dev->flags&IFF_UP)) {
++                              if (fi->fib_protocol != RTPROT_STATIC)
++                                      return -ENETDOWN;
++                              nh->nh_flags |= RTNH_F_DEAD;
++                      }
+                       nh->nh_dev = dev;
+                       dev_hold(dev);
+                       nh->nh_scope = RT_SCOPE_LINK;
+@@ -556,24 +604,48 @@ static int fib_check_nh(struct fib_confi
+                       /* It is not necessary, but requires a bit of thinking 
*/
+                       if (fl.fl4_scope < RT_SCOPE_LINK)
+                               fl.fl4_scope = RT_SCOPE_LINK;
+-                      if ((err = fib_lookup(&fl, &res)) != 0)
+-                              return err;
++                      err = fib_lookup(&fl, &res);
+               }
+-              err = -EINVAL;
+-              if (res.type != RTN_UNICAST && res.type != RTN_LOCAL)
+-                      goto out;
+-              nh->nh_scope = res.scope;
+-              nh->nh_oif = FIB_RES_OIF(res);
+-              if ((nh->nh_dev = FIB_RES_DEV(res)) == NULL)
+-                      goto out;
+-              dev_hold(nh->nh_dev);
+-              err = -ENETDOWN;
+-              if (!(nh->nh_dev->flags & IFF_UP))
+-                      goto out;
+-              err = 0;
++              if (err) {
++                      struct in_device *in_dev;
++
++                      if (err != -ENETUNREACH ||
++                          fi->fib_protocol != RTPROT_STATIC)
++                              return err;
++
++                      in_dev = inetdev_by_index(nh->nh_oif);
++                      if (in_dev == NULL ||
++                          in_dev->dev->flags & IFF_UP) {
++                              if (in_dev)
++                                      in_dev_put(in_dev);
++                              return err;
++                      }
++                      nh->nh_flags |= RTNH_F_DEAD;
++                      nh->nh_scope = RT_SCOPE_LINK;
++                      nh->nh_dev = in_dev->dev;
++                      dev_hold(nh->nh_dev);
++                      in_dev_put(in_dev);
++              } else {
++                      err = -EINVAL;
++                      if (res.type != RTN_UNICAST && res.type != RTN_LOCAL)
++                              goto out;
++                      nh->nh_scope = res.scope;
++                      nh->nh_oif = FIB_RES_OIF(res);
++                      if ((nh->nh_dev = FIB_RES_DEV(res)) == NULL)
++                              goto out;
++                      dev_hold(nh->nh_dev);
++                      if (!(nh->nh_dev->flags & IFF_UP)) {
++                              if (fi->fib_protocol != RTPROT_STATIC) {
++                                      err = -ENETDOWN;
++                                      goto out;
++                              }
++                              nh->nh_flags |= RTNH_F_DEAD;
++                      }
++                      err = 0;
+ out:
+-              fib_res_put(&res);
+-              return err;
++                      fib_res_put(&res);
++                      return err;
++              }
+       } else {
+               struct in_device *in_dev;
+ 
+@@ -584,8 +656,11 @@ out:
+               if (in_dev == NULL)
+                       return -ENODEV;
+               if (!(in_dev->dev->flags&IFF_UP)) {
+-                      in_dev_put(in_dev);
+-                      return -ENETDOWN;
++                      if (fi->fib_protocol != RTPROT_STATIC) {
++                              in_dev_put(in_dev);
++                              return -ENETDOWN;
++                      }
++                      nh->nh_flags |= RTNH_F_DEAD;
+               }
+               nh->nh_dev = in_dev->dev;
<<Diff was trimmed, longer than 597 lines>>
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to