tcp: drop tcp_bound_rto, merge content of it tcp_set_rto
[safe/jmp/linux-2.6] / net / ipv4 / ip_gre.c
index c0755e9..0101521 100644 (file)
@@ -126,8 +126,6 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev);
 
 /* Fallback tunnel: no source, no destination, no key, no options */
 
-static int ipgre_fb_tunnel_init(struct net_device *dev);
-
 #define HASH_SIZE  16
 
 static int ipgre_net_id;
@@ -371,7 +369,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
    by themself???
  */
 
-       struct iphdr *iph = (struct iphdr*)skb->data;
+       struct iphdr *iph = (struct iphdr *)skb->data;
        __be16       *p = (__be16*)(skb->data+(iph->ihl<<2));
        int grehlen = (iph->ihl<<2) + 4;
        const int type = icmp_hdr(skb)->type;
@@ -632,7 +630,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (dev->header_ops && dev->type == ARPHRD_IPGRE) {
                gre_hlen = 0;
-               tiph = (struct iphdr*)skb->data;
+               tiph = (struct iphdr *)skb->data;
        } else {
                gre_hlen = tunnel->hlen;
                tiph = &tunnel->parms.iph;
@@ -660,7 +658,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                        if (neigh == NULL)
                                goto tx_error;
 
-                       addr6 = (struct in6_addr*)&neigh->primary_key;
+                       addr6 = (struct in6_addr *)&neigh->primary_key;
                        addr_type = ipv6_addr_type(addr6);
 
                        if (addr_type == IPV6_ADDR_ANY) {
@@ -726,7 +724,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 #ifdef CONFIG_IPV6
        else if (skb->protocol == htons(ETH_P_IPV6)) {
-               struct rt6_info *rt6 = (struct rt6_info*)skb->dst;
+               struct rt6_info *rt6 = (struct rt6_info *)skb->dst;
 
                if (rt6 && mtu < dst_mtu(skb->dst) && mtu >= IPV6_MIN_MTU) {
                        if ((tunnel->parms.iph.daddr &&
@@ -800,7 +798,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                        iph->ttl = old_iph->ttl;
 #ifdef CONFIG_IPV6
                else if (skb->protocol == htons(ETH_P_IPV6))
-                       iph->ttl = ((struct ipv6hdr*)old_iph)->hop_limit;
+                       iph->ttl = ((struct ipv6hdr *)old_iph)->hop_limit;
 #endif
                else
                        iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
@@ -962,7 +960,7 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
                                        break;
                                }
                        } else {
-                               unsigned nflags=0;
+                               unsigned nflags = 0;
 
                                t = netdev_priv(dev);
 
@@ -1104,7 +1102,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
 
 static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
-       struct iphdr *iph = (struct iphdr*) skb_mac_header(skb);
+       struct iphdr *iph = (struct iphdr *) skb_mac_header(skb);
        memcpy(haddr, &iph->saddr, 4);
        return 4;
 }
@@ -1142,6 +1140,7 @@ static int ipgre_open(struct net_device *dev)
 static int ipgre_close(struct net_device *dev)
 {
        struct ip_tunnel *t = netdev_priv(dev);
+
        if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
                struct in_device *in_dev;
                in_dev = inetdev_by_index(dev_net(dev), t->mlink);
@@ -1155,14 +1154,22 @@ static int ipgre_close(struct net_device *dev)
 
 #endif
 
+static const struct net_device_ops ipgre_netdev_ops = {
+       .ndo_init               = ipgre_tunnel_init,
+       .ndo_uninit             = ipgre_tunnel_uninit,
+#ifdef CONFIG_NET_IPGRE_BROADCAST
+       .ndo_open               = ipgre_open,
+       .ndo_stop               = ipgre_close,
+#endif
+       .ndo_start_xmit         = ipgre_tunnel_xmit,
+       .ndo_do_ioctl           = ipgre_tunnel_ioctl,
+       .ndo_change_mtu         = ipgre_tunnel_change_mtu,
+};
+
 static void ipgre_tunnel_setup(struct net_device *dev)
 {
-       dev->init               = ipgre_tunnel_init;
-       dev->uninit             = ipgre_tunnel_uninit;
+       dev->netdev_ops         = &ipgre_netdev_ops;
        dev->destructor         = free_netdev;
-       dev->hard_start_xmit    = ipgre_tunnel_xmit;
-       dev->do_ioctl           = ipgre_tunnel_ioctl;
-       dev->change_mtu         = ipgre_tunnel_change_mtu;
 
        dev->type               = ARPHRD_IPGRE;
        dev->needed_headroom    = LL_MAX_HEADER + sizeof(struct iphdr) + 4;
@@ -1194,8 +1201,6 @@ static int ipgre_tunnel_init(struct net_device *dev)
                                return -EINVAL;
                        dev->flags = IFF_BROADCAST;
                        dev->header_ops = &ipgre_header_ops;
-                       dev->open = ipgre_open;
-                       dev->stop = ipgre_close;
                }
 #endif
        } else
@@ -1204,7 +1209,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
        return 0;
 }
 
-static int ipgre_fb_tunnel_init(struct net_device *dev)
+static void ipgre_fb_tunnel_init(struct net_device *dev)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
        struct iphdr *iph = &tunnel->parms.iph;
@@ -1220,7 +1225,6 @@ static int ipgre_fb_tunnel_init(struct net_device *dev)
 
        dev_hold(dev);
        ign->tunnels_wc[0]      = tunnel;
-       return 0;
 }
 
 
@@ -1264,9 +1268,9 @@ static int ipgre_init_net(struct net *net)
                err = -ENOMEM;
                goto err_alloc_dev;
        }
-
-       ign->fb_tunnel_dev->init = ipgre_fb_tunnel_init;
        dev_net_set(ign->fb_tunnel_dev, net);
+
+       ipgre_fb_tunnel_init(ign->fb_tunnel_dev);
        ign->fb_tunnel_dev->rtnl_link_ops = &ipgre_link_ops;
 
        if ((err = register_netdev(ign->fb_tunnel_dev)))
@@ -1345,7 +1349,7 @@ out:
 static void ipgre_netlink_parms(struct nlattr *data[],
                                struct ip_tunnel_parm *parms)
 {
-       memset(parms, 0, sizeof(parms));
+       memset(parms, 0, sizeof(*parms));
 
        parms->iph.protocol = IPPROTO_GRE;
 
@@ -1368,10 +1372,10 @@ static void ipgre_netlink_parms(struct nlattr *data[],
                parms->o_key = nla_get_be32(data[IFLA_GRE_OKEY]);
 
        if (data[IFLA_GRE_LOCAL])
-               memcpy(&parms->iph.saddr, nla_data(data[IFLA_GRE_LOCAL]), 4);
+               parms->iph.saddr = nla_get_be32(data[IFLA_GRE_LOCAL]);
 
        if (data[IFLA_GRE_REMOTE])
-               memcpy(&parms->iph.daddr, nla_data(data[IFLA_GRE_REMOTE]), 4);
+               parms->iph.daddr = nla_get_be32(data[IFLA_GRE_REMOTE]);
 
        if (data[IFLA_GRE_TTL])
                parms->iph.ttl = nla_get_u8(data[IFLA_GRE_TTL]);
@@ -1397,16 +1401,22 @@ static int ipgre_tap_init(struct net_device *dev)
        return 0;
 }
 
+static const struct net_device_ops ipgre_tap_netdev_ops = {
+       .ndo_init               = ipgre_tap_init,
+       .ndo_uninit             = ipgre_tunnel_uninit,
+       .ndo_start_xmit         = ipgre_tunnel_xmit,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_change_mtu         = ipgre_tunnel_change_mtu,
+};
+
 static void ipgre_tap_setup(struct net_device *dev)
 {
 
        ether_setup(dev);
 
-       dev->init               = ipgre_tap_init;
-       dev->uninit             = ipgre_tunnel_uninit;
+       dev->netdev_ops         = &ipgre_netdev_ops;
        dev->destructor         = free_netdev;
-       dev->hard_start_xmit    = ipgre_tunnel_xmit;
-       dev->change_mtu         = ipgre_tunnel_change_mtu;
 
        dev->iflink             = 0;
        dev->features           |= NETIF_F_NETNS_LOCAL;
@@ -1541,8 +1551,8 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
        NLA_PUT_BE16(skb, IFLA_GRE_OFLAGS, p->o_flags);
        NLA_PUT_BE32(skb, IFLA_GRE_IKEY, p->i_key);
        NLA_PUT_BE32(skb, IFLA_GRE_OKEY, p->o_key);
-       NLA_PUT(skb, IFLA_GRE_LOCAL, 4, &p->iph.saddr);
-       NLA_PUT(skb, IFLA_GRE_REMOTE, 4, &p->iph.daddr);
+       NLA_PUT_BE32(skb, IFLA_GRE_LOCAL, p->iph.saddr);
+       NLA_PUT_BE32(skb, IFLA_GRE_REMOTE, p->iph.daddr);
        NLA_PUT_U8(skb, IFLA_GRE_TTL, p->iph.ttl);
        NLA_PUT_U8(skb, IFLA_GRE_TOS, p->iph.tos);
        NLA_PUT_U8(skb, IFLA_GRE_PMTUDISC, !!(p->iph.frag_off & htons(IP_DF)));
@@ -1559,8 +1569,8 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
        [IFLA_GRE_OFLAGS]       = { .type = NLA_U16 },
        [IFLA_GRE_IKEY]         = { .type = NLA_U32 },
        [IFLA_GRE_OKEY]         = { .type = NLA_U32 },
-       [IFLA_GRE_LOCAL]        = { .len = 4 },
-       [IFLA_GRE_REMOTE]       = { .len = 4 },
+       [IFLA_GRE_LOCAL]        = { .len = FIELD_SIZEOF(struct iphdr, saddr) },
+       [IFLA_GRE_REMOTE]       = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
        [IFLA_GRE_TTL]          = { .type = NLA_U8 },
        [IFLA_GRE_TOS]          = { .type = NLA_U8 },
        [IFLA_GRE_PMTUDISC]     = { .type = NLA_U8 },
@@ -1643,5 +1653,5 @@ static void __exit ipgre_fini(void)
 module_init(ipgre_init);
 module_exit(ipgre_fini);
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("rtnl-link-gre");
-MODULE_ALIAS("rtnl-link-gretap");
+MODULE_ALIAS_RTNL_LINK("gre");
+MODULE_ALIAS_RTNL_LINK("gretap");