diff options
Diffstat (limited to 'dom/media/webrtc/transport')
18 files changed, 224 insertions, 318 deletions
diff --git a/dom/media/webrtc/transport/test/moz.build b/dom/media/webrtc/transport/test/moz.build index a2b0bc2bc2..3213525abd 100644 --- a/dom/media/webrtc/transport/test/moz.build +++ b/dom/media/webrtc/transport/test/moz.build @@ -7,35 +7,39 @@ include("/ipc/chromium/chromium-config.mozbuild") if CONFIG["OS_TARGET"] != "WINNT": - if CONFIG["OS_TARGET"] != "Android": - SOURCES += [ - "ice_unittest.cpp", - ] - SOURCES += [ "buffered_stun_socket_unittest.cpp", "multi_tcp_socket_unittest.cpp", - "nrappkit_unittest.cpp", "proxy_tunnel_socket_unittest.cpp", - "rlogconnector_unittest.cpp", "runnable_utils_unittest.cpp", "simpletokenbucket_unittest.cpp", - "sockettransportservice_unittest.cpp", "stunserver.cpp", "test_nr_socket_ice_unittest.cpp", "test_nr_socket_unittest.cpp", "TestSyncRunnable.cpp", - "transport_unittests.cpp", "turn_unittest.cpp", - "webrtcproxychannel_unittest.cpp", ] - if CONFIG["MOZ_SCTP"]: + # Bug 1894419 - Various failures under TSAN + if not CONFIG["MOZ_TSAN"]: + if CONFIG["OS_TARGET"] != "Android": + SOURCES += [ + "ice_unittest.cpp", + ] + + if CONFIG["MOZ_SCTP"]: + SOURCES += [ + "sctp_unittest.cpp", + ] + SOURCES += [ - "sctp_unittest.cpp", + "nrappkit_unittest.cpp", + "rlogconnector_unittest.cpp", + "sockettransportservice_unittest.cpp", + "transport_unittests.cpp", + "webrtcproxychannel_unittest.cpp", ] - for var in ("HAVE_STRDUP", "NR_SOCKET_IS_VOID_PTR", "SCTP_DEBUG"): DEFINES[var] = True diff --git a/dom/media/webrtc/transport/test_nr_socket.cpp b/dom/media/webrtc/transport/test_nr_socket.cpp index 1a6f226c42..1bf95adc88 100644 --- a/dom/media/webrtc/transport/test_nr_socket.cpp +++ b/dom/media/webrtc/transport/test_nr_socket.cpp @@ -141,8 +141,7 @@ TestNat::NatBehavior TestNat::ToNatBehavior(const std::string& type) { return TestNat::PORT_DEPENDENT; } - MOZ_ASSERT(false, "Invalid NAT behavior"); - return TestNat::ENDPOINT_INDEPENDENT; + MOZ_CRASH("Invalid NAT behavior"); } bool TestNat::has_port_mappings() const { @@ -202,8 +201,8 @@ TestNrSocket::~TestNrSocket() { nat_->erase_socket(this); } RefPtr<NrSocketBase> TestNrSocket::create_external_socket( const nr_transport_addr& dest_addr) const { - MOZ_ASSERT(nat_->enabled_); - MOZ_ASSERT(!nat_->is_an_internal_tuple(dest_addr)); + MOZ_RELEASE_ASSERT(nat_->enabled_); + MOZ_RELEASE_ASSERT(!nat_->is_an_internal_tuple(dest_addr)); int r; nr_transport_addr nat_external_addr; @@ -261,7 +260,7 @@ void TestNrSocket::close() { } int TestNrSocket::listen(int backlog) { - MOZ_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP); + MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP); r_log(LOG_GENERIC, LOG_DEBUG, "TestNrSocket %p %s listening", this, internal_socket_->my_addr().as_string); @@ -269,7 +268,7 @@ int TestNrSocket::listen(int backlog) { } int TestNrSocket::accept(nr_transport_addr* addrp, nr_socket** sockp) { - MOZ_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP); + MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP); int r = internal_socket_->accept(addrp, sockp); if (r) { return r; @@ -296,7 +295,7 @@ void TestNrSocket::process_delayed_cb(NR_SOCKET s, int how, void* cb_arg) { int TestNrSocket::sendto(const void* msg, size_t len, int flags, const nr_transport_addr* to) { - MOZ_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP); + MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP); r_log(LOG_GENERIC, LOG_DEBUG, "TestNrSocket %p %s %s", this, __FUNCTION__, to->as_string); @@ -347,10 +346,7 @@ int TestNrSocket::sendto(const void* msg, size_t len, int flags, external_socket = similar_port_mapping->external_socket_; } else { external_socket = create_external_socket(*to); - if (!external_socket) { - MOZ_ASSERT(false); - return R_INTERNAL; - } + MOZ_RELEASE_ASSERT(external_socket); } port_mapping = create_port_mapping(*to, external_socket); @@ -371,7 +367,7 @@ int TestNrSocket::sendto(const void* msg, size_t len, int flags, int TestNrSocket::recvfrom(void* buf, size_t maxlen, size_t* len, int flags, nr_transport_addr* from) { - MOZ_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP); + MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP); if (!read_buffer_.empty()) { UdpPacket& packet = read_buffer_.front(); @@ -441,8 +437,8 @@ bool TestNrSocket::allow_ingress(const nr_transport_addr& to, const nr_transport_addr& from, PortMapping** port_mapping_used) const { // This is only called for traffic arriving at a port mapping - MOZ_ASSERT(nat_->enabled_); - MOZ_ASSERT(!nat_->is_an_internal_tuple(from)); + MOZ_RELEASE_ASSERT(nat_->enabled_); + MOZ_RELEASE_ASSERT(!nat_->is_an_internal_tuple(from)); // Find the port mapping (if any) that this packet landed on *port_mapping_used = nullptr; @@ -603,7 +599,7 @@ int TestNrSocket::write(const void* msg, size_t len, size_t* written) { return R_INTERNAL; } // This is TCP only - MOZ_ASSERT(port_mappings_.size() == 1); + MOZ_RELEASE_ASSERT(port_mappings_.size() == 1); r_log(LOG_GENERIC, LOG_DEBUG, "PortMapping %s -> %s writing", port_mappings_.front()->external_socket_->my_addr().as_string, port_mappings_.front()->remote_address_.as_string); @@ -641,7 +637,7 @@ int TestNrSocket::read(void* buf, size_t maxlen, size_t* len) { if (port_mappings_.empty()) { r = internal_socket_->read(buf, maxlen, len); } else { - MOZ_ASSERT(port_mappings_.size() == 1); + MOZ_RELEASE_ASSERT(port_mappings_.size() == 1); r = port_mappings_.front()->external_socket_->read(buf, maxlen, len); if (!r && nat_->refresh_on_ingress_) { port_mappings_.front()->last_used_ = PR_IntervalNow(); @@ -722,7 +718,7 @@ int TestNrSocket::async_wait(int how, NR_async_cb cb, void* cb_arg, if (internal_socket_->my_addr().protocol == IPPROTO_TCP) { // For a TCP connection through a simulated NAT, these signals are // just passed through. - MOZ_ASSERT(port_mappings_.size() == 1); + MOZ_RELEASE_ASSERT(port_mappings_.size() == 1); return port_mappings_.front()->async_wait( how, port_mapping_tcp_passthrough_callback, this, function, line); @@ -834,7 +830,7 @@ void TestNrSocket::on_socket_readable(NrSocketBase* real_socket) { } void TestNrSocket::fire_readable_callback() { - MOZ_ASSERT(poll_flags() & PR_POLL_READ); + MOZ_RELEASE_ASSERT(poll_flags() & PR_POLL_READ); r_log(LOG_GENERIC, LOG_DEBUG, "TestNrSocket %p %s ready for read", this, internal_socket_->my_addr().as_string); fire_callback(NR_ASYNC_WAIT_READ); @@ -849,7 +845,7 @@ void TestNrSocket::port_mapping_writeable_callback(void* ext_sock_v, int how, } void TestNrSocket::write_to_port_mapping(NrSocketBase* external_socket) { - MOZ_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP); + MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP); int r = 0; for (PortMapping* port_mapping : port_mappings_) { @@ -935,7 +931,7 @@ TestNrSocket::PortMapping::PortMapping( } int TestNrSocket::PortMapping::send_from_queue() { - MOZ_ASSERT(remote_address_.protocol != IPPROTO_TCP); + MOZ_RELEASE_ASSERT(remote_address_.protocol != IPPROTO_TCP); int r = 0; while (!send_queue_.empty()) { @@ -967,7 +963,7 @@ int TestNrSocket::PortMapping::send_from_queue() { int TestNrSocket::PortMapping::sendto(const void* msg, size_t len, const nr_transport_addr& to) { - MOZ_ASSERT(remote_address_.protocol != IPPROTO_TCP); + MOZ_RELEASE_ASSERT(remote_address_.protocol != IPPROTO_TCP); r_log(LOG_GENERIC, LOG_DEBUG, "PortMapping %s -> %s sending to %s", external_socket_->my_addr().as_string, remote_address_.as_string, to.as_string); diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c index 362b7d828e..51f72f4179 100644 --- a/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c +++ b/dom/media/webrtc/transport/third_party/nICEr/src/stun/addrs.c @@ -62,82 +62,125 @@ nr_stun_is_duplicate_addr(nr_local_addr addrs[], int count, nr_local_addr *addr) return 0; } +static int +nr_stun_filter_find_first_addr_with_ifname(nr_local_addr addrs[], int count, const char *ifname) { + for (int i = 0; i < count; ++i) { + if (!strncmp(addrs[i].addr.ifname, ifname, sizeof(addrs[i].addr.ifname))) { + return i; + } + } + return count; +} + +static int +nr_stun_filter_addrs_for_ifname(nr_local_addr src[], const int src_begin, const int src_end, nr_local_addr dest[], int *dest_index, int remove_loopback, int remove_link_local) { + int r, _status; + /* We prefer temp ipv6 for their privacy properties. If we cannot get + * that, we prefer ipv6 that are not based on mac address. */ + int filter_mac_ipv6 = 0; + int filter_teredo_ipv6 = 0; + int filter_non_temp_ipv6 = 0; + + const char* ifname = src[src_begin].addr.ifname; + + /* Figure out what we want to filter */ + for (int i = src_begin; i < src_end; ++i) { + if (strncmp(ifname, src[i].addr.ifname, sizeof(src[i].addr.ifname))) { + /* Ignore addrs from other interfaces */ + continue; + } + + if (src[i].addr.ip_version == NR_IPV6) { + if (nr_transport_addr_is_teredo(&src[i].addr)) { + src[i].interface.type |= NR_INTERFACE_TYPE_TEREDO; + /* Prefer teredo over mac-based address. Probably will never see + * both. */ + filter_mac_ipv6 = 1; + } else { + filter_teredo_ipv6 = 1; + } + + if (!nr_transport_addr_is_mac_based(&src[i].addr)) { + filter_mac_ipv6 = 1; + } + + if (src[i].flags & NR_ADDR_FLAG_TEMPORARY) { + filter_non_temp_ipv6 = 1; + } + } + } + + /* Perform the filtering */ + for (int i = src_begin; i < src_end; ++i) { + if (strncmp(ifname, src[i].addr.ifname, sizeof(src[i].addr.ifname))) { + /* Ignore addrs from other interfaces */ + continue; + } + + if (nr_stun_is_duplicate_addr(dest, *dest_index, &src[i])) { + /* skip src[i], it's a duplicate */ + } + else if (remove_loopback && nr_transport_addr_is_loopback(&src[i].addr)) { + /* skip src[i], it's a loopback */ + } + else if (remove_link_local && + nr_transport_addr_is_link_local(&src[i].addr)) { + /* skip src[i], it's a link-local address */ + } + else if (filter_mac_ipv6 && + nr_transport_addr_is_mac_based(&src[i].addr)) { + /* skip src[i], it's MAC based */ + } + else if (filter_teredo_ipv6 && + nr_transport_addr_is_teredo(&src[i].addr)) { + /* skip src[i], it's a Teredo address */ + } + else if (filter_non_temp_ipv6 && + (src[i].addr.ip_version == NR_IPV6) && + !(src[i].flags & NR_ADDR_FLAG_TEMPORARY)) { + /* skip src[i], it's a non-temporary ipv6, and we have a temporary */ + } + else { + /* otherwise, copy it to the destination array */ + if ((r=nr_local_addr_copy(&dest[*dest_index], &src[i]))) + ABORT(r); + ++(*dest_index); + } + } + + _status = 0; +abort: + return _status; +} + int nr_stun_filter_addrs(nr_local_addr addrs[], int remove_loopback, int remove_link_local, int *count) { int r, _status; nr_local_addr *tmp = 0; - int i; - int n; - /* We prefer temp ipv6 for their privacy properties. If we cannot get - * that, we prefer ipv6 that are not based on mac address. */ - int filter_mac_ipv6 = 0; - int filter_teredo_ipv6 = 0; - int filter_non_temp_ipv6 = 0; + int dest_index = 0; tmp = RMALLOC(*count * sizeof(*tmp)); if (!tmp) ABORT(R_NO_MEMORY); - for (i = 0; i < *count; ++i) { - if (addrs[i].addr.ip_version == NR_IPV6) { - if (nr_transport_addr_is_teredo(&addrs[i].addr)) { - addrs[i].interface.type |= NR_INTERFACE_TYPE_TEREDO; - /* Prefer teredo over mac-based address. Probably will never see - * both. */ - filter_mac_ipv6 = 1; - } else { - filter_teredo_ipv6 = 1; - } - - if (!nr_transport_addr_is_mac_based(&addrs[i].addr)) { - filter_mac_ipv6 = 1; - } - - if (addrs[i].flags & NR_ADDR_FLAG_TEMPORARY) { - filter_non_temp_ipv6 = 1; + for (int i = 0; i < *count; ++i) { + if (i == nr_stun_filter_find_first_addr_with_ifname(addrs, *count, addrs[i].addr.ifname)) { + /* This is the first address associated with this interface. + * Filter for this interface once, now. */ + if (r = nr_stun_filter_addrs_for_ifname(addrs, i, *count, tmp, &dest_index, remove_loopback, remove_link_local)) { + ABORT(r); } } } - n = 0; - for (i = 0; i < *count; ++i) { - if (nr_stun_is_duplicate_addr(tmp, n, &addrs[i])) { - /* skip addrs[i], it's a duplicate */ - } - else if (remove_loopback && nr_transport_addr_is_loopback(&addrs[i].addr)) { - /* skip addrs[i], it's a loopback */ - } - else if (remove_link_local && - nr_transport_addr_is_link_local(&addrs[i].addr)) { - /* skip addrs[i], it's a link-local address */ - } - else if (filter_mac_ipv6 && - nr_transport_addr_is_mac_based(&addrs[i].addr)) { - /* skip addrs[i], it's MAC based */ - } - else if (filter_teredo_ipv6 && - nr_transport_addr_is_teredo(&addrs[i].addr)) { - /* skip addrs[i], it's a Teredo address */ - } - else if (filter_non_temp_ipv6 && - (addrs[i].addr.ip_version == NR_IPV6) && - !(addrs[i].flags & NR_ADDR_FLAG_TEMPORARY)) { - /* skip addrs[i], it's a non-temporary ipv6, and we have a temporary */ - } - else { - /* otherwise, copy it to the temporary array */ - if ((r=nr_local_addr_copy(&tmp[n], &addrs[i]))) - ABORT(r); - ++n; - } - } + /* Clear the entire array out before copying back */ + memset(addrs, 0, *count * sizeof(*addrs)); - *count = n; + *count = dest_index; - memset(addrs, 0, *count * sizeof(*addrs)); /* copy temporary array into passed in/out array */ - for (i = 0; i < *count; ++i) { + for (int i = 0; i < *count; ++i) { if ((r=nr_local_addr_copy(&addrs[i], &tmp[i]))) ABORT(r); } diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c b/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c index 09bb24749f..bb47cda879 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/log/r_log.c @@ -375,22 +375,10 @@ int r_vlog(int facility,int level,const char *format,va_list ap) int stderr_vlog(int facility,int level,const char *format,va_list ap) { -#if 0 /* remove time stamping, for now */ - char cbuf[30]; - time_t tt; - - tt=time(0); - - ctime_r(&tt,cbuf); - cbuf[strlen(cbuf)-1]=0; - - fprintf(stderr,"%s: ",cbuf); -#endif - vfprintf(stderr,format,ap); fprintf(stderr,"\n"); return(0); - } + } int syslog_vlog(int facility,int level,const char *format,va_list ap) { @@ -525,7 +513,7 @@ int r_logging(int facility, int level) static int r_log_get_default_level(void) { - char *log; + char *log = 0; int _status; log=getenv("R_LOG_LEVEL"); @@ -546,7 +534,7 @@ static int r_log_get_default_level(void) static int r_log_get_destinations(int usereg) { - char *log; + char *log = 0; int i; int r,_status; @@ -627,7 +615,7 @@ int r_log_init() int _r_log_init(int use_reg) { #ifndef WIN32 - char *log; + char *log = 0; #endif if(r_log_initted==0) { diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c index 709b1c3fb7..3134ad1536 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry.c @@ -563,7 +563,7 @@ NR_reg_make_registry(NR_registry parent, char *child, NR_registry out) int r, _status; size_t plen; size_t clen; - char *c; + char *c = 0; size_t i; if ((r=nr_reg_is_valid(parent))) diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry_local.c b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry_local.c index ed6e19aaa0..e577b7d4e5 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry_local.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registry_local.c @@ -134,19 +134,9 @@ static int nr_reg_get_array(char *name, unsigned char type, UCHAR *out, size_t s static int nr_reg_set(char *name, int type, void *data); static int nr_reg_set_array(char *name, unsigned char type, UCHAR *data, size_t length); static int nr_reg_set_parent_registries(char *name); - -/* make these static OLD_REGISTRY */ -#if 0 -static int nr_reg_fetch_node(char *name, unsigned char type, nr_registry_node **node, int *free_node); -static char *nr_reg_alloc_node_data(char *name, nr_registry_node *node, int *freeit); -#else int nr_reg_fetch_node(char *name, unsigned char type, nr_registry_node **node, int *free_node); char *nr_reg_alloc_node_data(char *name, nr_registry_node *node, int *freeit); -#endif static int nr_reg_rfree(void *ptr); -#if 0 /* Unused currently */ -static int nr_reg_noop(void *ptr); -#endif static int nr_reg_compute_length(char *name, nr_registry_node *node, size_t *length); char *nr_reg_action_name(int action); @@ -155,10 +145,6 @@ char *nr_reg_action_name(int action); * nr_array_registry_node */ static r_assoc *nr_registry = 0; -#if 0 /* Unused currently */ -static nr_array_registry_node nr_top_level_node; -#endif - typedef struct nr_reg_find_children_arg_ { size_t size; NR_registry *children; @@ -178,7 +164,7 @@ nr_reg_local_iter(NR_registry prefix, int (*action)(void *ptr, r_assoc_iterator { int r, _status; r_assoc_iterator iter; - char *name; + char *name = 0; int namel; nr_registry_node *node; int prefixl; @@ -246,7 +232,7 @@ nr_reg_local_find_children(void *ptr, r_assoc_iterator *iter, char *prefix, char { int _status; int prefixl = strlen(prefix); - char *dot; + char *dot = 0; nr_reg_find_children_arg *arg = (void*)ptr; assert(sizeof(*(arg->children)) == sizeof(NR_registry)); @@ -275,7 +261,7 @@ int nr_reg_local_count_children(void *ptr, r_assoc_iterator *iter, char *prefix, char *name, nr_registry_node *node) { int prefixl = strlen(prefix); - char *dot; + char *dot = 0; /* only count children */ if (name[prefixl] == '.') { @@ -296,7 +282,7 @@ nr_reg_local_dump_print(void *ptr, r_assoc_iterator *iter, char *prefix, char *n { int _status; int freeit = 0; - char *data; + char *data = 0; /* only print leaf nodes */ if (node->type != NR_REG_TYPE_REGISTRY) { @@ -315,14 +301,6 @@ nr_reg_local_dump_print(void *ptr, r_assoc_iterator *iter, char *prefix, char *n } -#if 0 /* Unused currently */ -int -nr_reg_noop(void *ptr) -{ - return 0; -} -#endif - int nr_reg_rfree(void *ptr) { @@ -750,7 +728,7 @@ nr_reg_set_parent_registries(char *name) { int r, _status; char *parent = 0; - char *dot; + char *dot = 0; if ((parent = r_strdup(name)) == 0) ABORT(R_NO_MEMORY); @@ -955,7 +933,7 @@ nr_reg_local_get_type(NR_registry name, NR_registry_type type) { int r, _status; nr_registry_node *node = 0; - char *str; + char *str = 0; if ((r=nr_reg_is_valid(name))) ABORT(r); @@ -1044,7 +1022,7 @@ int nr_reg_local_get_child_count(NR_registry parent, size_t *count) { int r, _status; - nr_registry_node *ignore1; + nr_registry_node *ignore1 = 0; int ignore2; diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registrycb.c b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registrycb.c index 4b326a1ee2..bd3570cefc 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registrycb.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/registry/registrycb.c @@ -118,9 +118,9 @@ int nr_reg_register_callback(NR_registry name, char action, void (*cb)(void *cb_arg, char action, NR_registry name), void *cb_arg) { int r, _status; - r_assoc *assoc; + r_assoc *assoc = 0; int create_assoc = 0; - nr_reg_cb_info *info; + nr_reg_cb_info *info = 0; int create_info = 0; unsigned char cb_id[SIZEOF_CB_ID]; @@ -191,7 +191,7 @@ int nr_reg_unregister_callback(char *name, char action, void (*cb)(void *cb_arg, char action, NR_registry name)) { int r, _status; - r_assoc *assoc; + r_assoc *assoc = 0; int size; unsigned char cb_id[SIZEOF_CB_ID]; @@ -283,12 +283,12 @@ int nr_reg_raise_event_recurse(char *name, char *tmp, int action) { int r, _status; - r_assoc *assoc; + r_assoc *assoc = 0; nr_reg_cb_info *info; r_assoc_iterator iter; - char *key; + char *key = 0; int keyl; - char *c; + char *c = 0; int free_tmp = 0; int count; diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_assoc.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_assoc.c index 25b3827d50..eb8cb0b061 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_assoc.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_assoc.c @@ -150,7 +150,7 @@ int r_assoc_create(assocp,hash_func,bits) int r_assoc_destroy(assocp) r_assoc **assocp; { - r_assoc *assoc; + r_assoc *assoc = 0; int i; if(!assocp || !*assocp) @@ -169,7 +169,7 @@ int r_assoc_destroy(assocp) static int destroy_assoc_chain(chain) r_assoc_el *chain; { - r_assoc_el *nxt; + r_assoc_el *nxt = 0; while(chain){ nxt=chain->next; @@ -190,7 +190,7 @@ static int copy_assoc_chain(knewp,old) r_assoc_el **knewp; r_assoc_el *old; { - r_assoc_el *knew=0,*ptr,*tmp; + r_assoc_el *knew = 0, *ptr = 0, *tmp = 0; int r,_status; ptr=0; /* Pacify GCC's uninitialized warning. @@ -245,7 +245,7 @@ static int r_assoc_fetch_bucket(assoc,key,len,bucketp) r_assoc_el **bucketp; { UINT4 hash_value; - r_assoc_el *bucket; + r_assoc_el *bucket = 0; hash_value=assoc->hash_func(key,len,assoc->bits); @@ -265,7 +265,7 @@ int r_assoc_fetch(assoc,key,len,datap) int len; void **datap; { - r_assoc_el *bucket; + r_assoc_el *bucket = 0; int r; if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){ @@ -287,7 +287,7 @@ int r_assoc_insert(assoc,key,len,data,copy,destroy,how) int (*destroy)(void *ptr); int how; { - r_assoc_el *bucket,*new_bucket=0; + r_assoc_el *bucket = 0, *new_bucket = 0; int r,_status; if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){ @@ -340,7 +340,7 @@ int r_assoc_delete(assoc,key,len) int len; { int r; - r_assoc_el *bucket; + r_assoc_el *bucket = 0; UINT4 hash_value; if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){ @@ -377,7 +377,7 @@ int r_assoc_copy(knewp,old) r_assoc *old; { int r,_status,i; - r_assoc *knew; + r_assoc *knew = 0; if(!(knew=(r_assoc *)RCALLOC(sizeof(r_assoc)))) ABORT(R_NO_MEMORY); @@ -441,7 +441,7 @@ int r_assoc_iter(iter,key,keyl,val) void **val; { int i; - r_assoc_el *ret; + r_assoc_el *ret = 0; if(!iter->next) return(R_EOD); diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_crc32.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_crc32.c index 38d3e4da38..6def127dfd 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_crc32.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_crc32.c @@ -157,7 +157,7 @@ r_crc32(buf, dlen, cval) u_int32_t *cval; { u_int32_t crc = ~0; - char *p ; + char *p = 0; int i; u_int32_t crc32_total = 0 ; diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_data.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_data.c index dfb7af2d5c..23df74fb8b 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_data.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_data.c @@ -183,7 +183,7 @@ int r_data_destroy(dp) int r_data_destroy_v(v) void *v; { - Data *d; + Data *d = 0; if(!v) return(0); @@ -199,7 +199,7 @@ int r_data_destroy_v(v) int r_data_destroy_vp(v) void **v; { - Data *d; + Data *d = 0; if(!v || !*v) return(0); diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_list.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_list.c index 4e71d67030..527d39b43a 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_list.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_list.c @@ -117,8 +117,8 @@ int r_list_create(listp) int r_list_destroy(listp) r_list **listp; { - r_list *list; - r_list_el *el; + r_list *list = 0; + r_list_el *el = 0; if(!listp || !*listp) return(0); @@ -147,7 +147,7 @@ int r_list_copy(outp,in) r_list *in; { r_list *out=0; - r_list_el *el,*el2,*last=0; + r_list_el *el = 0, *el2 = 0, *last = 0; int r, _status; if(!in){ diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_memory.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_memory.c index 53846fc019..3cfcc916d4 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_memory.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_memory.c @@ -66,7 +66,7 @@ void *r_malloc(type,size) size_t size; { size_t total; - r_malloc_chunk *chunk; + r_malloc_chunk *chunk = 0; total=size+sizeof(r_malloc_chunk); @@ -90,7 +90,7 @@ void *r_calloc(type,number,size) size_t number; size_t size; { - void *ret; + void *ret = 0; size_t total; total=number*size; @@ -106,7 +106,7 @@ void *r_calloc(type,number,size) void r_free(ptr) void *ptr; { - r_malloc_chunk *chunk; + r_malloc_chunk *chunk = 0; if(!ptr) return; @@ -125,7 +125,7 @@ void *r_realloc(ptr,size) void *ptr; size_t size; { - r_malloc_chunk *chunk,*nchunk; + r_malloc_chunk *chunk = 0, *nchunk = 0; size_t total; if(!ptr) return(r_malloc(255,size)); @@ -154,7 +154,7 @@ char *r_strdup(str) const char *str; { int len; - char *nstr; + char *nstr = 0; if(!str) return(0); diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_replace.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_replace.c index 8916b884cc..4dc8feb878 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_replace.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr/r_replace.c @@ -88,7 +88,7 @@ char *strdup(str) char *str; { int len=strlen(str); - char *n; + char *n = 0; if(!(n=(char *)malloc(len+1))) return(0); diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/p_buf.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/p_buf.c index 459baecdda..6ada8420ed 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/p_buf.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/p_buf.c @@ -72,7 +72,7 @@ int nr_p_buf_ctx_create(size,ctxp) int nr_p_buf_ctx_destroy(ctxp) nr_p_buf_ctx **ctxp; { - nr_p_buf_ctx *ctx; + nr_p_buf_ctx *ctx = 0; if(!ctxp || !*ctxp) return(0); @@ -133,7 +133,7 @@ int nr_p_buf_free_chain(ctx,head) nr_p_buf_ctx *ctx; nr_p_buf_head *head; { - nr_p_buf *n1,*n2; + nr_p_buf *n1 = 0, *n2 = 0; n1=STAILQ_FIRST(head); while(n1){ @@ -155,7 +155,7 @@ int nr_p_buf_write_to_chain(ctx,chain,data,len) UINT4 len; { int r,_status; - nr_p_buf *buf; + nr_p_buf *buf = 0; buf=STAILQ_LAST(chain,nr_p_buf_,entry); while(len){ @@ -186,7 +186,7 @@ int nr_p_buf_write_to_chain(ctx,chain,data,len) static int nr_p_buf_destroy_chain(head) nr_p_buf_head *head; { - nr_p_buf *n1,*n2; + nr_p_buf *n1 = 0, *n2 = 0; n1=STAILQ_FIRST(head); while(n1){ diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.c b/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.c index 79b14a8967..51f75832b1 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.c +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.c @@ -79,38 +79,6 @@ int nr_get_filename(base,name,namep) return(_status); } -#if 0 -int read_RSA_private_key(base,name,keyp) - char *base; - char *name; - RSA **keyp; - { - char *keyfile=0; - BIO *bio=0; - FILE *fp=0; - RSA *rsa=0; - int r,_status; - - /* Load the keyfile */ - if(r=get_filename(base,name,&keyfile)) - ABORT(r); - if(!(fp=fopen(keyfile,"r"))) - ABORT(R_NOT_FOUND); - if(!(bio=BIO_new(BIO_s_file()))) - ABORT(R_NO_MEMORY); - BIO_set_fp(bio,fp,BIO_NOCLOSE); - - if(!(rsa=PEM_read_bio_RSAPrivateKey(bio,0,0,0))) - ABORT(R_NOT_FOUND); - - *keyp=rsa; - _status=0; - abort: - return(_status); - } -#endif - - void nr_errprintf_log(const char *format,...) { va_list ap; @@ -296,55 +264,6 @@ int nr_sha1_file(char *filename,UCHAR *out) // TODO #else -#if 0 - -#include <fts.h> - -int nr_rm_tree(char *path) - { - FTS *fts=0; - FTSENT *p; - int failed=0; - int _status; - char *argv[2]; - - argv[0]=path; - argv[1]=0; - - if(!(fts=fts_open(argv,0,NULL))){ - r_log_e(LOG_COMMON,LOG_ERR,"Couldn't open directory %s",path); - ABORT(R_FAILED); - } - - while(p=fts_read(fts)){ - switch(p->fts_info){ - case FTS_D: - break; - case FTS_DOT: - break; - case FTS_ERR: - r_log_e(LOG_COMMON,LOG_ERR,"Problem reading %s",p->fts_path); - break; - default: - r_log(LOG_COMMON,LOG_DEBUG,"Removing %s",p->fts_path); - errno=0; - if(remove(p->fts_path)){ - r_log_e(LOG_COMMON,LOG_ERR,"Problem removing %s",p->fts_path); - failed=1; - } - } - } - - if(failed) - ABORT(R_FAILED); - - _status=0; - abort: - if(fts) fts_close(fts); - return(_status); - } -#endif - int nr_write_pid_file(char *pid_filename) { FILE *fp; @@ -625,7 +544,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size) * to use pointer overlays. All the world's not a VAX. */ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; - char *tp, *ep; + char *tp = 0, *ep = 0; struct { int base, len; } best, cur; unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; int i; diff --git a/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.h b/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.h index d7861659cd..26c692fbbe 100644 --- a/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.h +++ b/dom/media/webrtc/transport/third_party/nrappkit/src/util/util.h @@ -43,11 +43,6 @@ #include "registry.h" int nr_get_filename(char *base,char *name, char **namep); -#if 0 -#include <openssl/ssl.h> - -int read_RSA_private_key(char *base, char *name,RSA **keyp); -#endif void nr_errprintf_log(const char *fmt,...); void nr_errprintf_log2(void *ignore, const char *fmt,...); extern int nr_util_default_log_facility; diff --git a/dom/media/webrtc/transport/transportlayerdtls.cpp b/dom/media/webrtc/transport/transportlayerdtls.cpp index 4ab8aaa029..1279726bce 100644 --- a/dom/media/webrtc/transport/transportlayerdtls.cpp +++ b/dom/media/webrtc/transport/transportlayerdtls.cpp @@ -9,12 +9,14 @@ #include "transportlayerdtls.h" #include <algorithm> +#include <iomanip> #include <queue> #include <sstream> #include "dtlsidentity.h" #include "keyhi.h" #include "logging.h" +#include "mozilla/glean/GleanMetrics.h" #include "mozilla/Telemetry.h" #include "mozilla/UniquePtr.h" #include "mozilla/Unused.h" @@ -889,6 +891,7 @@ void TransportLayerDtls::Handshake() { if (!cert_ok_) { MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Certificate check never occurred"); TL_SET_STATE(TS_ERROR); + RecordHandshakeCompletionTelemetry("CERT_FAILURE"); return; } if (!CheckAlpn()) { @@ -897,11 +900,13 @@ void TransportLayerDtls::Handshake() { // (assuming the close_notify isn't dropped). ssl_fd_ = nullptr; TL_SET_STATE(TS_ERROR); + RecordHandshakeCompletionTelemetry("ALPN_FAILURE"); return; } TL_SET_STATE(TS_OPEN); + RecordHandshakeCompletionTelemetry("SUCCESS"); RecordTlsTelemetry(); timer_ = nullptr; } else { @@ -932,6 +937,7 @@ void TransportLayerDtls::Handshake() { MOZ_MTLOG(ML_ERROR, LAYER_INFO << "DTLS handshake error " << err << " (" << err_msg << ")"); TL_SET_STATE(TS_ERROR); + RecordHandshakeCompletionTelemetry(err_msg); break; } } @@ -1468,6 +1474,17 @@ void TransportLayerDtls::TimerCallback(nsITimer* timer, void* arg) { dtls->Handshake(); } +void TransportLayerDtls::RecordHandshakeCompletionTelemetry( + const char* aResult) { + if (role_ == CLIENT) { + mozilla::glean::webrtcdtls::client_handshake_result.Get(nsCString(aResult)) + .Add(1); + } else { + mozilla::glean::webrtcdtls::server_handshake_result.Get(nsCString(aResult)) + .Add(1); + } +} + void TransportLayerDtls::RecordTlsTelemetry() { MOZ_ASSERT(state_ == TS_OPEN); SSLChannelInfo info; @@ -1478,54 +1495,29 @@ void TransportLayerDtls::RecordTlsTelemetry() { return; } - uint16_t telemetry_cipher = 0; - - switch (info.cipherSuite) { - /* Old DHE ciphers: candidates for removal, see bug 1227519 */ - case TLS_DHE_RSA_WITH_AES_128_CBC_SHA: - telemetry_cipher = 1; - break; - case TLS_DHE_RSA_WITH_AES_256_CBC_SHA: - telemetry_cipher = 2; - break; - /* Current ciphers */ - case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: - telemetry_cipher = 3; - break; - case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: - telemetry_cipher = 4; - break; - case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: - telemetry_cipher = 5; - break; - case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: - telemetry_cipher = 6; - break; - case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: - telemetry_cipher = 7; + switch (info.protocolVersion) { + case SSL_LIBRARY_VERSION_TLS_1_1: + mozilla::glean::webrtcdtls::protocol_version.Get("1.0"_ns).Add(1); break; - case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: - telemetry_cipher = 8; + case SSL_LIBRARY_VERSION_TLS_1_2: + mozilla::glean::webrtcdtls::protocol_version.Get("1.2"_ns).Add(1); break; - case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: - telemetry_cipher = 9; - break; - case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: - telemetry_cipher = 10; - break; - /* TLS 1.3 ciphers */ - case TLS_AES_128_GCM_SHA256: - telemetry_cipher = 11; - break; - case TLS_CHACHA20_POLY1305_SHA256: - telemetry_cipher = 12; - break; - case TLS_AES_256_GCM_SHA384: - telemetry_cipher = 13; + case SSL_LIBRARY_VERSION_TLS_1_3: + mozilla::glean::webrtcdtls::protocol_version.Get("1.3"_ns).Add(1); break; + default: + MOZ_CRASH("Unknown SSL version"); } - Telemetry::Accumulate(Telemetry::WEBRTC_DTLS_CIPHER, telemetry_cipher); + { + std::ostringstream oss; + // Record TLS cipher-suite ID as a string (eg; + // TLS_DHE_RSA_WITH_AES_128_CBC_SHA is 0x0033) + oss << "0x" << std::setfill('0') << std::setw(4) << std::hex + << info.cipherSuite; + mozilla::glean::webrtcdtls::cipher.Get(nsCString(oss.str().c_str())).Add(1); + MOZ_MTLOG(ML_DEBUG, "cipher: " << oss.str()); + } uint16_t cipher; nsresult rv = GetSrtpCipher(&cipher); @@ -1535,24 +1527,15 @@ void TransportLayerDtls::RecordTlsTelemetry() { return; } - auto cipher_label = mozilla::Telemetry::LABELS_WEBRTC_SRTP_CIPHER::Unknown; - - switch (cipher) { - case kDtlsSrtpAes128CmHmacSha1_80: - cipher_label = Telemetry::LABELS_WEBRTC_SRTP_CIPHER::Aes128CmHmacSha1_80; - break; - case kDtlsSrtpAes128CmHmacSha1_32: - cipher_label = Telemetry::LABELS_WEBRTC_SRTP_CIPHER::Aes128CmHmacSha1_32; - break; - case kDtlsSrtpAeadAes128Gcm: - cipher_label = Telemetry::LABELS_WEBRTC_SRTP_CIPHER::AeadAes128Gcm; - break; - case kDtlsSrtpAeadAes256Gcm: - cipher_label = Telemetry::LABELS_WEBRTC_SRTP_CIPHER::AeadAes256Gcm; - break; + { + std::ostringstream oss; + // Record SRTP cipher-suite ID as a string (eg; + // SRTP_AES128_CM_HMAC_SHA1_80 is 0x0001) + oss << "0x" << std::setfill('0') << std::setw(4) << std::hex << cipher; + mozilla::glean::webrtcdtls::srtp_cipher.Get(nsCString(oss.str().c_str())) + .Add(1); + MOZ_MTLOG(ML_DEBUG, "srtp cipher: " << oss.str()); } - - Telemetry::AccumulateCategorical(cipher_label); } } // namespace mozilla diff --git a/dom/media/webrtc/transport/transportlayerdtls.h b/dom/media/webrtc/transport/transportlayerdtls.h index d68a6e77d5..e0370a04b2 100644 --- a/dom/media/webrtc/transport/transportlayerdtls.h +++ b/dom/media/webrtc/transport/transportlayerdtls.h @@ -144,7 +144,7 @@ class TransportLayerDtls final : public TransportLayer { SECStatus CheckDigest(const DtlsDigest& digest, UniqueCERTCertificate& cert) const; - void RecordHandshakeCompletionTelemetry(TransportLayer::State endState); + void RecordHandshakeCompletionTelemetry(const char* aResult); void RecordTlsTelemetry(); static PRBool WriteSrtpXtn(PRFileDesc* fd, SSLHandshakeType message, |