datapath: Add multicast tunnel support.
[sliver-openvswitch.git] / datapath / vport-gre.c
index fc489e9..95ac4bb 100644 (file)
@@ -103,9 +103,12 @@ static struct sk_buff *gre_update_header(const struct vport *vport,
                                                0));
        /*
         * Allow our local IP stack to fragment the outer packet even if the
-        * DF bit is set as a last resort.
+        * DF bit is set as a last resort.  We also need to force selection of
+        * an IP ID here because Linux will otherwise leave it at 0 if the
+        * packet originally had DF set.
         */
        skb->local_df = 1;
+       __ip_select_ident(ip_hdr(skb), dst, 0);
 
        return skb;
 }
@@ -185,13 +188,15 @@ static void gre_err(struct sk_buff *skb, u32 info)
                return;
 
        iph = (struct iphdr *)skb->data;
+       if (ipv4_is_multicast(iph->daddr))
+               return;
 
        tunnel_hdr_len = parse_header(iph, &flags, &key);
        if (tunnel_hdr_len < 0)
                return;
 
-       vport = tnl_find_port(iph->saddr, iph->daddr, key,
-                             TNL_T_PROTO_GRE | TNL_T_KEY_EITHER, &mutable);
+       vport = tnl_find_port(iph->saddr, iph->daddr, key, TNL_T_PROTO_GRE,
+                             &mutable);
        if (!vport)
                return;
 
@@ -204,7 +209,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
         * out key as if it were the in key and then check to see if the input
         * and output keys are the same.
         */
-       if (mutable->in_key != mutable->out_key)
+       if (mutable->key.in_key != mutable->out_key)
                return;
 
        if (!!(mutable->flags & TNL_F_IN_KEY_MATCH) !=
@@ -327,8 +332,8 @@ static int gre_rcv(struct sk_buff *skb)
                goto error;
 
        iph = ip_hdr(skb);
-       vport = tnl_find_port(iph->daddr, iph->saddr, key,
-                             TNL_T_PROTO_GRE | TNL_T_KEY_EITHER, &mutable);
+       vport = tnl_find_port(iph->daddr, iph->saddr, key, TNL_T_PROTO_GRE,
+                             &mutable);
        if (unlikely(!vport)) {
                icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
                goto error;
@@ -342,7 +347,7 @@ static int gre_rcv(struct sk_buff *skb)
        __skb_pull(skb, hdr_len);
        skb_postpull_rcsum(skb, skb_transport_header(skb), hdr_len + ETH_HLEN);
 
-       tnl_rcv(vport, skb);
+       tnl_rcv(vport, skb, iph->tos);
        return 0;
 
 error:
@@ -385,13 +390,12 @@ static void gre_exit(void)
 }
 
 const struct vport_ops gre_vport_ops = {
-       .type           = ODP_VPORT_TYPE_GRE,
-       .flags          = VPORT_F_GEN_STATS | VPORT_F_TUN_ID,
+       .type           = OVS_VPORT_TYPE_GRE,
+       .flags          = VPORT_F_TUN_ID,
        .init           = gre_init,
        .exit           = gre_exit,
        .create         = gre_create,
        .destroy        = tnl_destroy,
-       .set_mtu        = tnl_set_mtu,
        .set_addr       = tnl_set_addr,
        .get_name       = tnl_get_name,
        .get_addr       = tnl_get_addr,
@@ -400,6 +404,5 @@ const struct vport_ops gre_vport_ops = {
        .get_dev_flags  = vport_gen_get_dev_flags,
        .is_running     = vport_gen_is_running,
        .get_operstate  = vport_gen_get_operstate,
-       .get_mtu        = tnl_get_mtu,
        .send           = tnl_send,
 };