Changeset 58e8646 in mainline for uspace/srv/net/udp


Ignore:
Timestamp:
2017-08-23T18:37:21Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
258d77e
Parents:
853802e
Message:

Fix DNS resolution not working due to missing local address.

Location:
uspace/srv/net/udp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/assoc.c

    r853802e r58e8646  
    4040#include <fibril_synch.h>
    4141#include <inet/endpoint.h>
     42#include <inet/inet.h>
    4243#include <io/log.h>
    4344#include <nettl/amap.h>
     
    261262                return EINVAL;
    262263
     264        /* This association has no local address set. Need to determine one. */
     265        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - check no local addr");
     266        if (inet_addr_is_any(&epp.local.addr) && !assoc->nolocal) {
     267                log_msg(LOG_DEFAULT, LVL_DEBUG, "Determine local address.");
     268                rc = inet_get_srcaddr(&epp.remote.addr, 0, &epp.local.addr);
     269                if (rc != EOK) {
     270                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Cannot determine "
     271                            "local address.");
     272                        return EINVAL;
     273                }
     274        }
     275
    263276        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - check version");
    264277
    265         if (epp.remote.addr.version != epp.local.addr.version)
     278        if (!inet_addr_is_any(&epp.local.addr) &&
     279            epp.remote.addr.version != epp.local.addr.version)
    266280                return EINVAL;
    267281
  • uspace/srv/net/udp/service.c

    r853802e r58e8646  
    270270}
    271271
     272/** Set association sending messages with no local address.
     273 *
     274 * Handle client request to set nolocal flag (with parameters unmarshalled).
     275 *
     276 * @param client   UDP client
     277 * @param assoc_id Association ID
     278 * @return EOK on success, ENOENT if no such association is found
     279 */
     280static int udp_assoc_set_nolocal_impl(udp_client_t *client, sysarg_t assoc_id)
     281{
     282        udp_cassoc_t *cassoc;
     283        int rc;
     284
     285        rc = udp_cassoc_get(client, assoc_id, &cassoc);
     286        if (rc != EOK) {
     287                assert(rc == ENOENT);
     288                return ENOENT;
     289        }
     290
     291        log_msg(LOG_DEFAULT, LVL_NOTE, "Setting nolocal to true");
     292        cassoc->assoc->nolocal = true;
     293        return EOK;
     294}
     295
    272296/** Send message via association.
    273297 *
     
    391415        assoc_id = IPC_GET_ARG1(*icall);
    392416        rc = udp_assoc_destroy_impl(client, assoc_id);
     417        async_answer_0(iid, rc);
     418}
     419
     420/** Set association with no local address.
     421 *
     422 * Handle client request to set no local address flag.
     423 *
     424 * @param client   UDP client
     425 * @param iid      Async request ID
     426 * @param icall    Async request data
     427 */
     428static void udp_assoc_set_nolocal_srv(udp_client_t *client, ipc_callid_t iid,
     429    ipc_call_t *icall)
     430{
     431        sysarg_t assoc_id;
     432        int rc;
     433
     434        log_msg(LOG_DEFAULT, LVL_NOTE, "udp_assoc_set_nolocal_srv()");
     435
     436        assoc_id = IPC_GET_ARG1(*icall);
     437        rc = udp_assoc_set_nolocal_impl(client, assoc_id);
    393438        async_answer_0(iid, rc);
    394439}
     
    662707                        udp_assoc_destroy_srv(&client, callid, &call);
    663708                        break;
     709                case UDP_ASSOC_SET_NOLOCAL:
     710                        udp_assoc_set_nolocal_srv(&client, callid, &call);
     711                        break;
    664712                case UDP_ASSOC_SEND_MSG:
    665713                        udp_assoc_send_msg_srv(&client, callid, &call);
  • uspace/srv/net/udp/udp_type.h

    r853802e r58e8646  
    4141#include <inet/endpoint.h>
    4242#include <ipc/loc.h>
     43#include <stdbool.h>
    4344#include <stddef.h>
    4445#include <inet/addr.h>
     
    119120        /** Receive queue CV. Broadcast when new datagram is inserted */
    120121        fibril_condvar_t rcv_queue_cv;
     122        /** Allow sending messages with no local address */
     123        bool nolocal;
    121124
    122125        udp_assoc_cb_t *cb;
Note: See TracChangeset for help on using the changeset viewer.