Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_unfold])
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [parallel_ops])
OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_unfold])
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [parallel_ops])
- OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [NLA_NUL_STRING])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be16])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be32])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be16])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be32])
#include <net/route.h>
#include <net/xfrm.h>
#include <net/route.h>
#include <net/xfrm.h>
-
-#ifndef HAVE_NLA_NUL_STRING
-static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen)
-{
- char *s;
- int len;
- if (!attr)
- return 0;
-
- len = nla_len(attr);
- if (len >= maxlen)
- return -EINVAL;
-
- s = nla_data(attr);
- if (s[len - 1] != '\0')
- return -EINVAL;
-
- return 0;
-}
-#else
-static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen)
-{
- return 0;
-}
-#endif /* !HAVE_NLA_NUL_STRING */
-
static inline void skb_clear_rxhash(struct sk_buff *skb)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
static inline void skb_clear_rxhash(struct sk_buff *skb)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
}
static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
}
static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
[OVS_PACKET_ATTR_PACKET] = { .len = ETH_HLEN },
[OVS_PACKET_ATTR_PACKET] = { .len = ETH_HLEN },
-#else
- [OVS_PACKET_ATTR_PACKET] = { .minlen = ETH_HLEN },
-#endif
[OVS_PACKET_ATTR_KEY] = { .type = NLA_NESTED },
[OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
};
[OVS_PACKET_ATTR_KEY] = { .type = NLA_NESTED },
[OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
};
};
static const struct nla_policy datapath_policy[OVS_DP_ATTR_MAX + 1] = {
};
static const struct nla_policy datapath_policy[OVS_DP_ATTR_MAX + 1] = {
-#ifdef HAVE_NLA_NUL_STRING
[OVS_DP_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
[OVS_DP_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
[OVS_DP_ATTR_UPCALL_PID] = { .type = NLA_U32 },
};
[OVS_DP_ATTR_UPCALL_PID] = { .type = NLA_U32 },
};
-static int ovs_dp_cmd_validate(struct nlattr *a[OVS_DP_ATTR_MAX + 1])
-{
- return CHECK_NUL_STRING(a[OVS_DP_ATTR_NAME], IFNAMSIZ - 1);
-}
-
/* Called with ovs_mutex. */
static struct datapath *lookup_datapath(struct net *net,
struct ovs_header *ovs_header,
/* Called with ovs_mutex. */
static struct datapath *lookup_datapath(struct net *net,
struct ovs_header *ovs_header,
if (!a[OVS_DP_ATTR_NAME] || !a[OVS_DP_ATTR_UPCALL_PID])
goto err;
if (!a[OVS_DP_ATTR_NAME] || !a[OVS_DP_ATTR_UPCALL_PID])
goto err;
- err = ovs_dp_cmd_validate(a);
- if (err)
- goto err;
-
ovs_lock();
err = -ENOMEM;
ovs_lock();
err = -ENOMEM;
struct datapath *dp;
int err;
struct datapath *dp;
int err;
- err = ovs_dp_cmd_validate(info->attrs);
- if (err)
- return err;
-
ovs_lock();
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
err = PTR_ERR(dp);
ovs_lock();
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
err = PTR_ERR(dp);
struct datapath *dp;
int err;
struct datapath *dp;
int err;
- err = ovs_dp_cmd_validate(info->attrs);
- if (err)
- return err;
-
ovs_lock();
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
err = PTR_ERR(dp);
ovs_lock();
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
err = PTR_ERR(dp);
struct datapath *dp;
int err;
struct datapath *dp;
int err;
- err = ovs_dp_cmd_validate(info->attrs);
- if (err)
- return err;
-
ovs_lock();
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
if (IS_ERR(dp)) {
ovs_lock();
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
if (IS_ERR(dp)) {
};
static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
};
static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
-#ifdef HAVE_NLA_NUL_STRING
[OVS_VPORT_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
[OVS_VPORT_ATTR_STATS] = { .len = sizeof(struct ovs_vport_stats) },
[OVS_VPORT_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
[OVS_VPORT_ATTR_STATS] = { .len = sizeof(struct ovs_vport_stats) },
-#else
- [OVS_VPORT_ATTR_STATS] = { .minlen = sizeof(struct ovs_vport_stats) },
-#endif
[OVS_VPORT_ATTR_PORT_NO] = { .type = NLA_U32 },
[OVS_VPORT_ATTR_TYPE] = { .type = NLA_U32 },
[OVS_VPORT_ATTR_UPCALL_PID] = { .type = NLA_U32 },
[OVS_VPORT_ATTR_PORT_NO] = { .type = NLA_U32 },
[OVS_VPORT_ATTR_TYPE] = { .type = NLA_U32 },
[OVS_VPORT_ATTR_UPCALL_PID] = { .type = NLA_U32 },
-static int ovs_vport_cmd_validate(struct nlattr *a[OVS_VPORT_ATTR_MAX + 1])
-{
- return CHECK_NUL_STRING(a[OVS_VPORT_ATTR_NAME], IFNAMSIZ - 1);
-}
-
/* Called with ovs_mutex or RCU read lock. */
static struct vport *lookup_vport(struct net *net,
struct ovs_header *ovs_header,
/* Called with ovs_mutex or RCU read lock. */
static struct vport *lookup_vport(struct net *net,
struct ovs_header *ovs_header,
!a[OVS_VPORT_ATTR_UPCALL_PID])
goto exit;
!a[OVS_VPORT_ATTR_UPCALL_PID])
goto exit;
- err = ovs_vport_cmd_validate(a);
- if (err)
- goto exit;
-
ovs_lock();
dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
err = -ENODEV;
ovs_lock();
dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
err = -ENODEV;
struct vport *vport;
int err;
struct vport *vport;
int err;
- err = ovs_vport_cmd_validate(a);
- if (err)
- goto exit;
-
ovs_lock();
vport = lookup_vport(sock_net(skb->sk), info->userhdr, a);
err = PTR_ERR(vport);
ovs_lock();
vport = lookup_vport(sock_net(skb->sk), info->userhdr, a);
err = PTR_ERR(vport);
kfree_skb(reply);
exit_unlock:
ovs_unlock();
kfree_skb(reply);
exit_unlock:
ovs_unlock();
struct vport *vport;
int err;
struct vport *vport;
int err;
- err = ovs_vport_cmd_validate(a);
- if (err)
- goto exit;
-
ovs_lock();
vport = lookup_vport(sock_net(skb->sk), info->userhdr, a);
err = PTR_ERR(vport);
ovs_lock();
vport = lookup_vport(sock_net(skb->sk), info->userhdr, a);
err = PTR_ERR(vport);
exit_unlock:
ovs_unlock();
exit_unlock:
ovs_unlock();
struct vport *vport;
int err;
struct vport *vport;
int err;
- err = ovs_vport_cmd_validate(a);
- if (err)
- goto exit;
-
rcu_read_lock();
vport = lookup_vport(sock_net(skb->sk), ovs_header, a);
err = PTR_ERR(vport);
rcu_read_lock();
vport = lookup_vport(sock_net(skb->sk), ovs_header, a);
err = PTR_ERR(vport);
exit_unlock:
rcu_read_unlock();
exit_unlock:
rcu_read_unlock();