~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to lib/stream-ssl.c

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
 
2
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
3
3
 *
4
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
5
 * you may not use this file except in compliance with the License.
35
35
#include "coverage.h"
36
36
#include "dynamic-string.h"
37
37
#include "entropy.h"
38
 
#include "leak-checker.h"
39
38
#include "ofpbuf.h"
40
39
#include "openflow/openflow.h"
41
40
#include "packets.h"
247
246
    /* Disable Nagle. */
248
247
    retval = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on);
249
248
    if (retval) {
250
 
        VLOG_ERR("%s: setsockopt(TCP_NODELAY): %s", name, strerror(errno));
 
249
        VLOG_ERR("%s: setsockopt(TCP_NODELAY): %s", name, ovs_strerror(errno));
251
250
        retval = errno;
252
251
        goto error;
253
252
    }
324
323
        int state = error ? STATE_TCP_CONNECTING : STATE_SSL_CONNECTING;
325
324
        return new_ssl_stream(name, fd, CLIENT, state, &sin, streamp);
326
325
    } else {
327
 
        VLOG_ERR("%s: connect: %s", name, strerror(error));
 
326
        VLOG_ERR("%s: connect: %s", name, ovs_strerror(error));
328
327
        return error;
329
328
    }
330
329
}
370
369
            return EPROTO;
371
370
        } else {
372
371
            VLOG_ERR("could not bootstrap CA cert: creating %s failed: %s",
373
 
                     ca_cert.file_name, strerror(errno));
 
372
                     ca_cert.file_name, ovs_strerror(errno));
374
373
            return errno;
375
374
        }
376
375
    }
379
378
    if (!file) {
380
379
        error = errno;
381
380
        VLOG_ERR("could not bootstrap CA cert: fdopen failed: %s",
382
 
                 strerror(error));
 
381
                 ovs_strerror(error));
383
382
        unlink(ca_cert.file_name);
384
383
        return error;
385
384
    }
396
395
    if (fclose(file)) {
397
396
        error = errno;
398
397
        VLOG_ERR("could not bootstrap CA cert: writing %s failed: %s",
399
 
                 ca_cert.file_name, strerror(error));
 
398
                 ca_cert.file_name, ovs_strerror(error));
400
399
        unlink(ca_cert.file_name);
401
400
        return error;
402
401
    }
442
441
 
443
442
    case STATE_SSL_CONNECTING:
444
443
        /* Capture the first few bytes of received data so that we can guess
445
 
         * what kind of funny data we've been sent if SSL negotation fails. */
 
444
         * what kind of funny data we've been sent if SSL negotiation fails. */
446
445
        if (sslv->n_head <= 0) {
447
446
            sslv->n_head = recv(sslv->fd, sslv->head, sizeof sslv->head,
448
447
                                MSG_PEEK);
565
564
            if (ret < 0) {
566
565
                int status = errno;
567
566
                VLOG_WARN_RL(&rl, "%s: system error (%s)",
568
 
                             function, strerror(status));
 
567
                             function, ovs_strerror(status));
569
568
                return status;
570
569
            } else {
571
570
                VLOG_WARN_RL(&rl, "%s: unexpected SSL connection close",
674
673
            ssl_clear_txbuf(sslv);
675
674
            return n;
676
675
        case EAGAIN:
677
 
            leak_checker_claim(buffer);
678
676
            return n;
679
677
        default:
680
678
            sslv->txbuf = NULL;
808
806
 
809
807
    pssl = xmalloc(sizeof *pssl);
810
808
    pstream_init(&pssl->pstream, &pssl_pstream_class, bound_name);
 
809
    pstream_set_bound_port(&pssl->pstream, sin.sin_port);
811
810
    pssl->fd = fd;
812
811
    *pstreamp = &pssl->pstream;
813
812
    return 0;
835
834
    if (new_fd < 0) {
836
835
        error = errno;
837
836
        if (error != EAGAIN) {
838
 
            VLOG_DBG_RL(&rl, "accept: %s", strerror(error));
 
837
            VLOG_DBG_RL(&rl, "accept: %s", ovs_strerror(error));
839
838
        }
840
839
        return error;
841
840
    }
1016
1015
     * here. */
1017
1016
    error = get_mtime(file_name, &mtime);
1018
1017
    if (error && error != ENOENT) {
1019
 
        VLOG_ERR_RL(&rl, "%s: stat failed (%s)", file_name, strerror(error));
 
1018
        VLOG_ERR_RL(&rl, "%s: stat failed (%s)",
 
1019
                    file_name, ovs_strerror(error));
1020
1020
    }
1021
1021
    if (config->file_name
1022
1022
        && !strcmp(config->file_name, file_name)
1124
1124
    file = fopen(file_name, "r");
1125
1125
    if (!file) {
1126
1126
        VLOG_ERR("failed to open %s for reading: %s",
1127
 
                 file_name, strerror(errno));
 
1127
                 file_name, ovs_strerror(errno));
1128
1128
        return errno;
1129
1129
    }
1130
1130