diff options
author | 2016-10-07 13:46:11 +0100 | |
---|---|---|
committer | 2016-10-07 13:58:07 +0100 | |
commit | 2fea8d3d522d31cb279a90b3e49a6f217878b35b (patch) | |
tree | 0be9d6e0ee7907b199d45317d5285c2bb0e77fe9 /lib | |
parent | 1c436f7f29a3ba668590c5ddcfb8842f2f1e6e0c (diff) |
libtle_udp: don't allow to open stream for unsupported family
Change-Id: Ice9cc37ff538af185c8fcb18bedd007c175299e7
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libtle_udp/udp_ctl.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libtle_udp/udp_ctl.c b/lib/libtle_udp/udp_ctl.c index c8580ac..e6da8f2 100644 --- a/lib/libtle_udp/udp_ctl.c +++ b/lib/libtle_udp/udp_ctl.c @@ -625,17 +625,25 @@ fill_ipv6_am(const struct sockaddr_in6 *in, rte_xmm_t *addr, rte_xmm_t *mask) } static int -check_stream_prm(const struct tle_udp_stream_param *prm) +check_stream_prm(const struct tle_udp_ctx *ctx, + const struct tle_udp_stream_param *prm) { if ((prm->local_addr.ss_family != AF_INET && prm->local_addr.ss_family != AF_INET6) || prm->local_addr.ss_family != prm->remote_addr.ss_family) - return EINVAL; + return -EINVAL; /* callback and event notifications mechanisms are mutually exclusive */ if ((prm->recv_ev != NULL && prm->recv_cb.func != NULL) || (prm->send_ev != NULL && prm->send_cb.func != NULL)) - return EINVAL; + return -EINVAL; + + /* check does context support desired address family. */ + if ((prm->local_addr.ss_family == AF_INET && + ctx->prm.lookup4 == NULL) || + (prm->local_addr.ss_family == AF_INET6 && + ctx->prm.lookup6 == NULL)) + return -EINVAL; return 0; } @@ -648,7 +656,7 @@ tle_udp_stream_open(struct tle_udp_ctx *ctx, const struct sockaddr_in *rin; int32_t rc; - if (ctx == NULL || prm == NULL || check_stream_prm(prm) != 0) { + if (ctx == NULL || prm == NULL || check_stream_prm(ctx, prm) != 0) { rte_errno = EINVAL; return NULL; } |