]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - include/net/dst.h
net: Abstract default ADVMSS behind an accessor.
[mv-sheeva.git] / include / net / dst.h
index 02386505033d975e666cd924a3bafe3ca02bb100..03a1c3d52d808c06f9349405c30f85663bcaf313 100644 (file)
@@ -43,10 +43,11 @@ struct dst_entry {
        short                   error;
        short                   obsolete;
        int                     flags;
-#define DST_HOST               1
-#define DST_NOXFRM             2
-#define DST_NOPOLICY           4
-#define DST_NOHASH             8
+#define DST_HOST               0x0001
+#define DST_NOXFRM             0x0002
+#define DST_NOPOLICY           0x0004
+#define DST_NOHASH             0x0008
+#define DST_NOCACHE            0x0010
        unsigned long           expires;
 
        unsigned short          header_len;     /* more space at head required */
@@ -69,7 +70,7 @@ struct dst_entry {
 
        struct  dst_ops         *ops;
 
-       u32                     metrics[RTAX_MAX];
+       u32                     _metrics[RTAX_MAX];
 
 #ifdef CONFIG_NET_CLS_ROUTE
        __u32                   tclassid;
@@ -93,19 +94,58 @@ struct dst_entry {
        int                     __use;
        unsigned long           lastuse;
        union {
-               struct dst_entry *next;
-               struct rtable    *rt_next;
-               struct rt6_info   *rt6_next;
-               struct dn_route  *dn_next;
+               struct dst_entry        *next;
+               struct rtable __rcu     *rt_next;
+               struct rt6_info         *rt6_next;
+               struct dn_route __rcu   *dn_next;
        };
 };
 
 #ifdef __KERNEL__
 
 static inline u32
-dst_metric(const struct dst_entry *dst, int metric)
+dst_metric_raw(const struct dst_entry *dst, const int metric)
 {
-       return dst->metrics[metric-1];
+       return dst->_metrics[metric-1];
+}
+
+static inline u32
+dst_metric(const struct dst_entry *dst, const int metric)
+{
+       WARN_ON_ONCE(metric == RTAX_HOPLIMIT ||
+                    metric == RTAX_ADVMSS);
+       return dst_metric_raw(dst, metric);
+}
+
+static inline u32
+dst_metric_advmss(const struct dst_entry *dst)
+{
+       u32 advmss = dst_metric_raw(dst, RTAX_ADVMSS);
+
+       if (!advmss)
+               advmss = dst->ops->default_advmss(dst);
+
+       return advmss;
+}
+
+static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
+{
+       dst->_metrics[metric-1] = val;
+}
+
+static inline void dst_import_metrics(struct dst_entry *dst, const u32 *src_metrics)
+{
+       memcpy(dst->_metrics, src_metrics, RTAX_MAX * sizeof(u32));
+}
+
+static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
+{
+       dst_import_metrics(dest, src->_metrics);
+}
+
+static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
+{
+       return dst->_metrics;
 }
 
 static inline u32
@@ -133,7 +173,7 @@ static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metr
 static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
                                      unsigned long rtt)
 {
-       dst->metrics[metric-1] = jiffies_to_msecs(rtt);
+       dst_metric_set(dst, metric, jiffies_to_msecs(rtt));
 }
 
 static inline u32
@@ -227,6 +267,23 @@ static inline void skb_dst_force(struct sk_buff *skb)
 }
 
 
+/**
+ *     __skb_tunnel_rx - prepare skb for rx reinsert
+ *     @skb: buffer
+ *     @dev: tunnel device
+ *
+ *     After decapsulation, packet is going to re-enter (netif_rx()) our stack,
+ *     so make some cleanups. (no accounting done)
+ */
+static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
+{
+       skb->dev = dev;
+       skb->rxhash = 0;
+       skb_set_queue_mapping(skb, 0);
+       skb_dst_drop(skb);
+       nf_reset(skb);
+}
+
 /**
  *     skb_tunnel_rx - prepare skb for rx reinsert
  *     @skb: buffer
@@ -234,17 +291,14 @@ static inline void skb_dst_force(struct sk_buff *skb)
  *
  *     After decapsulation, packet is going to re-enter (netif_rx()) our stack,
  *     so make some cleanups, and perform accounting.
+ *     Note: this accounting is not SMP safe.
  */
 static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
 {
-       skb->dev = dev;
        /* TODO : stats should be SMP safe */
        dev->stats.rx_packets++;
        dev->stats.rx_bytes += skb->len;
-       skb->rxhash = 0;
-       skb_set_queue_mapping(skb, 0);
-       skb_dst_drop(skb);
-       nf_reset(skb);
+       __skb_tunnel_rx(skb, dev);
 }
 
 /* Children define the path of the packet through the