X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=datapath%2Fvport-capwap.c;h=f0bb3270fc45c9f692f014cd3da83535a2b84d23;hb=fc999dda6a9e3f42add70b371889a7419ff569c2;hp=bf1465fc0b5d0dbc1a4c9893645afddb3886afa9;hpb=842cf6f472b236b6e61be04b41970116245b1759;p=sliver-openvswitch.git diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c index bf1465fc0..f0bb3270f 100644 --- a/datapath/vport-capwap.c +++ b/datapath/vport-capwap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Nicira Networks. + * Copyright (c) 2010, 2011 Nicira Networks. * Distributed under the terms of the GNU GPL version 2. * * Significant portions of this file may be copied from parts of the Linux @@ -115,14 +115,17 @@ static struct netns_frags frag_netns_state = { static struct socket *capwap_rcv_socket; -static int capwap_hdr_len(const struct tnl_port_config *port_config) +static int capwap_hdr_len(const struct tnl_mutable_config *mutable) { - /* CAPWAP has neither checksums nor keys, so reject ports with those. */ - if (port_config->flags & (TNL_F_CSUM | TNL_F_IN_KEY_MATCH | - TNL_F_OUT_KEY_ACTION)) + /* CAPWAP has no checksums. */ + if (mutable->flags & TNL_F_CSUM) return -EINVAL; - if (port_config->in_key != 0 || port_config->out_key != 0) + /* CAPWAP has no keys, so check that the configuration for keys is the + * default if no key-specific attributes are used. + */ + if ((mutable->flags & (TNL_F_IN_KEY_MATCH | TNL_F_OUT_KEY_ACTION)) != + (TNL_F_IN_KEY_MATCH | TNL_F_OUT_KEY_ACTION)) return -EINVAL; return CAPWAP_HLEN; @@ -203,7 +206,7 @@ static int capwap_rcv(struct sock *sk, struct sk_buff *skb) goto error; } - tnl_rcv(vport, skb); + tnl_rcv(vport, skb, iph->tos); goto out; error: @@ -212,7 +215,7 @@ out: return 0; } -struct tnl_ops capwap_tnl_ops = { +static const struct tnl_ops capwap_tnl_ops = { .tunnel_type = TNL_T_PROTO_CAPWAP, .ipproto = IPPROTO_UDP, .hdr_len = capwap_hdr_len, @@ -220,9 +223,9 @@ struct tnl_ops capwap_tnl_ops = { .update_header = capwap_update_header, }; -static struct vport *capwap_create(const char *name, const void __user *config) +static struct vport *capwap_create(const struct vport_parms *parms) { - return tnl_create(name, config, &capwap_vport_ops, &capwap_tnl_ops); + return tnl_create(parms, &capwap_vport_ops, &capwap_tnl_ops); } /* Random value. Irrelevant as long as it's not 0 since we set the handler. */ @@ -237,7 +240,7 @@ static int capwap_init(void) goto error; sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; + sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_port = htons(CAPWAP_DST_PORT); err = kernel_bind(capwap_rcv_socket, (struct sockaddr *)&sin, @@ -644,23 +647,23 @@ static void capwap_frag_expire(unsigned long ifq) inet_frag_put(&fq->ifq, &frag_state); } -struct vport_ops capwap_vport_ops = { - .type = "capwap", +const struct vport_ops capwap_vport_ops = { + .type = ODP_VPORT_TYPE_CAPWAP, .flags = VPORT_F_GEN_STATS, .init = capwap_init, .exit = capwap_exit, .create = capwap_create, - .modify = tnl_modify, .destroy = tnl_destroy, - .set_mtu = tnl_set_mtu, .set_addr = tnl_set_addr, .get_name = tnl_get_name, .get_addr = tnl_get_addr, + .get_options = tnl_get_options, + .set_options = tnl_set_options, .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, }; - -#endif /* Linux kernel >= 2.6.26 */ +#else +#warning CAPWAP tunneling will not be available on kernels before 2.6.26 +#endif /* Linux kernel < 2.6.26 */