On 12/18/12 10:40, Isaku Yamahata wrote:
> Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
> ---
>  datapath/datapath.c                           |   54 
> ++++++++++++-------------
>  datapath/linux/Modules.mk                     |    1 +
>  datapath/linux/compat/include/net/genetlink.h |   15 ++++++-
>  datapath/linux/compat/include/net/inet_frag.h |   16 ++++++++
>  datapath/vport-capwap.c                       |   11 ++++-
>  5 files changed, 66 insertions(+), 31 deletions(-)
>  create mode 100644 datapath/linux/compat/include/net/inet_frag.h
> 
> diff --git a/datapath/datapath.c b/datapath/datapath.c
> index f990b73..0de4043 100644
> --- a/datapath/datapath.c
> +++ b/datapath/datapath.c
> @@ -61,7 +61,7 @@
>  #include "vport-internal_dev.h"
>  
>  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
> -    LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
> +    LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
>  #error Kernels before 2.6.18 or after 3.6 are not supported by this version 
> of Open vSwitch.

Minor issue: the #error message should read 3.7 instead of 3.6.

-Lori

>  #endif
>  
> @@ -1108,7 +1108,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, 
> struct genl_info *info)
>               /* Put flow in bucket. */
>               ovs_flow_tbl_insert(table, flow, &key, key_len);
>  
> -             reply = ovs_flow_cmd_build_info(flow, dp, info->snd_pid,
> +             reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid,
>                                               info->snd_seq,
>                                               OVS_FLOW_CMD_NEW);
>       } else {
> @@ -1146,7 +1146,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, 
> struct genl_info *info)
>                       ovs_flow_deferred_free_acts(old_acts);
>               }
>  
> -             reply = ovs_flow_cmd_build_info(flow, dp, info->snd_pid,
> +             reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid,
>                                              info->snd_seq, OVS_FLOW_CMD_NEW);
>  
>               /* Clear stats. */
> @@ -1158,7 +1158,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, 
> struct genl_info *info)
>       }
>  
>       if (!IS_ERR(reply))
> -             genl_notify(reply, genl_info_net(info), info->snd_pid,
> +             genl_notify(reply, genl_info_net(info), info->snd_portid,
>                          ovs_dp_flow_multicast_group.id, info->nlhdr,
>                          GFP_KERNEL);
>       else
> @@ -1199,7 +1199,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct 
> genl_info *info)
>       if (!flow)
>               return -ENOENT;
>  
> -     reply = ovs_flow_cmd_build_info(flow, dp, info->snd_pid,
> +     reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid,
>                                       info->snd_seq, OVS_FLOW_CMD_NEW);
>       if (IS_ERR(reply))
>               return PTR_ERR(reply);
> @@ -1241,13 +1241,13 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, 
> struct genl_info *info)
>  
>       ovs_flow_tbl_remove(table, flow);
>  
> -     err = ovs_flow_cmd_fill_info(flow, dp, reply, info->snd_pid,
> +     err = ovs_flow_cmd_fill_info(flow, dp, reply, info->snd_portid,
>                                    info->snd_seq, 0, OVS_FLOW_CMD_DEL);
>       BUG_ON(err < 0);
>  
>       ovs_flow_deferred_free(flow);
>  
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_flow_multicast_group.id, info->nlhdr, GFP_KERNEL);
>       return 0;
>  }
> @@ -1275,7 +1275,7 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, 
> struct netlink_callback *cb)
>                       break;
>  
>               if (ovs_flow_cmd_fill_info(flow, dp, skb,
> -                                        NETLINK_CB(cb->skb).pid,
> +                                        NETLINK_CB(cb->skb).portid,
>                                          cb->nlh->nlmsg_seq, NLM_F_MULTI,
>                                          OVS_FLOW_CMD_NEW) < 0)
>                       break;
> @@ -1476,7 +1476,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct 
> genl_info *info)
>               goto err_destroy_ports_array;
>       }
>  
> -     reply = ovs_dp_cmd_build_info(dp, info->snd_pid,
> +     reply = ovs_dp_cmd_build_info(dp, info->snd_portid,
>                                     info->snd_seq, OVS_DP_CMD_NEW);
>       err = PTR_ERR(reply);
>       if (IS_ERR(reply))
> @@ -1488,7 +1488,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct 
> genl_info *info)
>  
>       rtnl_unlock();
>  
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_datapath_multicast_group.id, info->nlhdr,
>                   GFP_KERNEL);
>       return 0;
> @@ -1555,7 +1555,7 @@ static int ovs_dp_cmd_del(struct sk_buff *skb, struct 
> genl_info *info)
>       if (IS_ERR(dp))
>               return err;
>  
> -     reply = ovs_dp_cmd_build_info(dp, info->snd_pid,
> +     reply = ovs_dp_cmd_build_info(dp, info->snd_portid,
>                                     info->snd_seq, OVS_DP_CMD_DEL);
>       err = PTR_ERR(reply);
>       if (IS_ERR(reply))
> @@ -1563,7 +1563,7 @@ static int ovs_dp_cmd_del(struct sk_buff *skb, struct 
> genl_info *info)
>  
>       __dp_destroy(dp);
>  
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_datapath_multicast_group.id, info->nlhdr,
>                   GFP_KERNEL);
>  
> @@ -1584,7 +1584,7 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct 
> genl_info *info)
>       if (IS_ERR(dp))
>               return PTR_ERR(dp);
>  
> -     reply = ovs_dp_cmd_build_info(dp, info->snd_pid,
> +     reply = ovs_dp_cmd_build_info(dp, info->snd_portid,
>                                     info->snd_seq, OVS_DP_CMD_NEW);
>       if (IS_ERR(reply)) {
>               err = PTR_ERR(reply);
> @@ -1593,7 +1593,7 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct 
> genl_info *info)
>               return 0;
>       }
>  
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_datapath_multicast_group.id, info->nlhdr,
>                   GFP_KERNEL);
>  
> @@ -1614,7 +1614,7 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct 
> genl_info *info)
>       if (IS_ERR(dp))
>               return PTR_ERR(dp);
>  
> -     reply = ovs_dp_cmd_build_info(dp, info->snd_pid,
> +     reply = ovs_dp_cmd_build_info(dp, info->snd_portid,
>                                     info->snd_seq, OVS_DP_CMD_NEW);
>       if (IS_ERR(reply))
>               return PTR_ERR(reply);
> @@ -1631,7 +1631,7 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct 
> netlink_callback *cb)
>  
>       list_for_each_entry(dp, &ovs_net->dps, list_node) {
>               if (i >= skip &&
> -                 ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).pid,
> +                 ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
>                                        cb->nlh->nlmsg_seq, NLM_F_MULTI,
>                                        OVS_DP_CMD_NEW) < 0)
>                       break;
> @@ -1876,7 +1876,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, 
> struct genl_info *info)
>  
>       err = change_vport(vport, a);
>       if (!err) {
> -             reply = ovs_vport_cmd_build_info(vport, info->snd_pid,
> +             reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
>                                                info->snd_seq,
>                                                OVS_VPORT_CMD_NEW);
>               if (IS_ERR(reply))
> @@ -1886,7 +1886,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, 
> struct genl_info *info)
>               ovs_dp_detach_port(vport);
>               goto exit_unlock;
>       }
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL);
>  
>  exit_unlock:
> @@ -1926,15 +1926,15 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, 
> struct genl_info *info)
>       if (!err && a[OVS_VPORT_ATTR_UPCALL_PID])
>               vport->upcall_pid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);
>  
> -     reply = ovs_vport_cmd_build_info(vport, info->snd_pid, info->snd_seq,
> -                                      OVS_VPORT_CMD_NEW);
> +     reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
> +                                      info->snd_seq, OVS_VPORT_CMD_NEW);
>       if (IS_ERR(reply)) {
>               netlink_set_err(GENL_SOCK(sock_net(skb->sk)), 0,
>                               ovs_dp_vport_multicast_group.id, 
> PTR_ERR(reply));
>               goto exit_unlock;
>       }
>  
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL);
>  
>  exit_unlock:
> @@ -1965,15 +1965,15 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, 
> struct genl_info *info)
>               goto exit_unlock;
>       }
>  
> -     reply = ovs_vport_cmd_build_info(vport, info->snd_pid, info->snd_seq,
> -                                      OVS_VPORT_CMD_DEL);
> +     reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
> +                                      info->snd_seq, OVS_VPORT_CMD_DEL);
>       err = PTR_ERR(reply);
>       if (IS_ERR(reply))
>               goto exit_unlock;
>  
>       ovs_dp_detach_port(vport);
>  
> -     genl_notify(reply, genl_info_net(info), info->snd_pid,
> +     genl_notify(reply, genl_info_net(info), info->snd_portid,
>                   ovs_dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL);
>  
>  exit_unlock:
> @@ -2000,8 +2000,8 @@ static int ovs_vport_cmd_get(struct sk_buff *skb, 
> struct genl_info *info)
>       if (IS_ERR(vport))
>               goto exit_unlock;
>  
> -     reply = ovs_vport_cmd_build_info(vport, info->snd_pid, info->snd_seq,
> -                                      OVS_VPORT_CMD_NEW);
> +     reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
> +                                      info->snd_seq, OVS_VPORT_CMD_NEW);
>       err = PTR_ERR(reply);
>       if (IS_ERR(reply))
>               goto exit_unlock;
> @@ -2036,7 +2036,7 @@ static int ovs_vport_cmd_dump(struct sk_buff *skb, 
> struct netlink_callback *cb)
>               hlist_for_each_entry_rcu(vport, n, &dp->ports[i], dp_hash_node) 
> {
>                       if (j >= skip &&
>                           ovs_vport_cmd_fill_info(vport, skb,
> -                                                 NETLINK_CB(cb->skb).pid,
> +                                                 NETLINK_CB(cb->skb).portid,
>                                                   cb->nlh->nlmsg_seq,
>                                                   NLM_F_MULTI,
>                                                   OVS_VPORT_CMD_NEW) < 0)
> diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
> index 81556d5..eae98e7 100644
> --- a/datapath/linux/Modules.mk
> +++ b/datapath/linux/Modules.mk
> @@ -61,6 +61,7 @@ openvswitch_headers += \
>       linux/compat/include/net/checksum.h \
>       linux/compat/include/net/dst.h \
>       linux/compat/include/net/genetlink.h \
> +     linux/compat/include/net/inet_frag.h \
>       linux/compat/include/net/ip.h \
>       linux/compat/include/net/ipv6.h \
>       linux/compat/include/net/net_namespace.h \
> diff --git a/datapath/linux/compat/include/net/genetlink.h 
> b/datapath/linux/compat/include/net/genetlink.h
> index af7d5fd..31ff282 100644
> --- a/datapath/linux/compat/include/net/genetlink.h
> +++ b/datapath/linux/compat/include/net/genetlink.h
> @@ -5,6 +5,17 @@
>  #include <linux/netlink.h>
>  #include <net/net_namespace.h>
>  
> +/*
> + * 15e473046cb6e5d18a4d0057e61d76315230382b renames pid to portid
> + * the affected structures are
> + * netlink_skb_parms::pid -> portid
> + * genl_info::snd_pid -> snd_portid
> + */
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
> +#define snd_portid snd_pid
> +#define portid pid
> +#endif
> +
>  /* Very special super-nasty workaround here:
>   *
>   * Before 2.6.19, nlmsg_multicast() lacked a 'flags' parameter.  We work
> @@ -126,7 +137,7 @@ static inline void *genlmsg_put_reply(struct sk_buff *skb,
>                       struct genl_info *info, struct genl_family *family,
>                       int flags, u8 cmd)
>  {
> -     return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
> +     return genlmsg_put(skb, info->snd_portid, info->snd_seq, family,
>                               flags, cmd);
>  }
>  
> @@ -137,7 +148,7 @@ static inline void *genlmsg_put_reply(struct sk_buff *skb,
>   */
>  static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
>  {
> -     return genlmsg_unicast(skb, info->snd_pid);
> +     return genlmsg_unicast(skb, info->snd_portid);
>  }
>  
>  /**
> diff --git a/datapath/linux/compat/include/net/inet_frag.h 
> b/datapath/linux/compat/include/net/inet_frag.h
> new file mode 100644
> index 0000000..6767c31
> --- /dev/null
> +++ b/datapath/linux/compat/include/net/inet_frag.h
> @@ -0,0 +1,16 @@
> +#ifndef __NET_INET_FRAG_WRAPPER_H
> +#define __NET_INET_FRAG_WRAPPER_H 1
> +
> +#include <linux/version.h>
> +#include_next <net/inet_frag.h>
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
> +#define inet_frag_evictor(nf, f, force)                                      
> \
> +     do {                                                            \
> +             if (force || atomic_read(&nf->mem) > nf->high_thresh) { \
> +                     inet_frag_evictor(nf, f);                       \
> +             }                                                       \
> +     } while (0)
> +#endif
> +
> +#endif /* inet_frag.h */
> diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c
> index 5f31732..cea6bfd 100644
> --- a/datapath/vport-capwap.c
> +++ b/datapath/vport-capwap.c
> @@ -143,7 +143,11 @@ static struct sk_buff *defrag(struct sk_buff *, bool 
> frag_last);
>  
>  static void capwap_frag_init(struct inet_frag_queue *, void *match);
>  static unsigned int capwap_frag_hash(struct inet_frag_queue *);
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
>  static int capwap_frag_match(struct inet_frag_queue *, void *match);
> +#else
> +static bool capwap_frag_match(struct inet_frag_queue *, void *match);
> +#endif
>  static void capwap_frag_expire(unsigned long ifq);
>  
>  static struct inet_frags frag_state = {
> @@ -769,8 +773,7 @@ static struct sk_buff *defrag(struct sk_buff *skb, bool 
> frag_last)
>       u16 frag_off;
>       struct frag_queue *fq;
>  
> -     if (atomic_read(&ns_frag_state->mem) > ns_frag_state->high_thresh)
> -             inet_frag_evictor(ns_frag_state, &frag_state);
> +     inet_frag_evictor(ns_frag_state, &frag_state, false);
>  
>       match.daddr = iph->daddr;
>       match.saddr = iph->saddr;
> @@ -804,7 +807,11 @@ static unsigned int capwap_frag_hash(struct 
> inet_frag_queue *ifq)
>       return frag_hash(&ifq_cast(ifq)->match);
>  }
>  
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
>  static int capwap_frag_match(struct inet_frag_queue *ifq, void *a_)
> +#else
> +static bool capwap_frag_match(struct inet_frag_queue *ifq, void *a_)
> +#endif
>  {
>       struct frag_match *a = a_;
>       struct frag_match *b = &ifq_cast(ifq)->match;
> 
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to