diff options
author | Lee Duncan <leeman.duncan@gmail.com> | 2017-05-25 16:33:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 16:33:43 -0700 |
commit | 9ab03b44b754bf9d72cb95e0b86361fbda6232c2 (patch) | |
tree | 1c5ad0b3753f1e4f8a17a4f6f85f03acfcc59d85 | |
parent | 54f914c66bbfc436bc4cd426d664d6b4864492d6 (diff) | |
parent | a1be9c4ec348f87923f63ce2dbc23893a3b9e45c (diff) | |
download | open-iscsi-9ab03b44b754bf9d72cb95e0b86361fbda6232c2.tar.gz |
Merge pull request #54 from njavali/iscsiuio-bug-fixes
iscsiuio bug fixes
-rw-r--r-- | iscsiuio/src/apps/dhcpc/dhcpv6.c | 9 | ||||
-rw-r--r-- | iscsiuio/src/unix/libs/bnx2x.c | 24 | ||||
-rw-r--r-- | iscsiuio/src/unix/libs/cnic.c | 9 | ||||
-rw-r--r-- | iscsiuio/src/unix/libs/qedi.c | 19 |
4 files changed, 32 insertions, 29 deletions
diff --git a/iscsiuio/src/apps/dhcpc/dhcpv6.c b/iscsiuio/src/apps/dhcpc/dhcpv6.c index a4e25f0..461af0e 100644 --- a/iscsiuio/src/apps/dhcpc/dhcpv6.c +++ b/iscsiuio/src/apps/dhcpc/dhcpv6.c @@ -153,7 +153,7 @@ static u16_t dhcpv6_init_packet(struct dhcpv6_context *context, u8_t type) if (dhcpv6->dhcpv6_type != type) context->dhcpv6_transaction_id++; - dhcpv6->dhcpv6_trans_id = context->dhcpv6_transaction_id; + dhcpv6->dhcpv6_trans_id = HOST_TO_NET16(context->dhcpv6_transaction_id); dhcpv6->dhcpv6_type = type; /* Keep track of length of all DHCP options. */ @@ -265,8 +265,13 @@ void ipv6_udp_handle_dhcp(struct dhcpv6_context *context) dhcpv6 = (union dhcpv6_hdr *)((u8_t *)context->udp + sizeof(struct udp_hdr)); - if (dhcpv6->dhcpv6_trans_id != context->dhcpv6_transaction_id) + if (dhcpv6->dhcpv6_trans_id != + HOST_TO_NET16(context->dhcpv6_transaction_id)) { + LOG_ERR("DHCPv6 transaction-id error, sent %x, received %x", + HOST_TO_NET16(context->dhcpv6_transaction_id), + dhcpv6->dhcpv6_trans_id); return; + } dhcpv6_len = NET_TO_HOST16(context->udp->length) - sizeof(struct udp_hdr); diff --git a/iscsiuio/src/unix/libs/bnx2x.c b/iscsiuio/src/unix/libs/bnx2x.c index 19cbcec..1e8f532 100644 --- a/iscsiuio/src/unix/libs/bnx2x.c +++ b/iscsiuio/src/unix/libs/bnx2x.c @@ -1316,7 +1316,6 @@ void bnx2x_start_xmit(nic_t *nic, size_t len, u16_t vlan_id) if ((rx_bd->addr_hi == 0) && (rx_bd->addr_lo == 0)) { LOG_PACKET(PFX "%s: trying to transmit when device is closed", nic->log_name); - pthread_mutex_unlock(&nic->xmit_mutex); return; } @@ -1343,12 +1342,9 @@ void bnx2x_start_xmit(nic_t *nic, size_t len, u16_t vlan_id) (bp->tx_bd_prod << 16)); bnx2x_flush_doorbell(bp, bp->tx_doorbell); } else { - /* If the doorbell is not rung, the packet will not - get sent. Hence, the xmit_mutex lock will not - get freed. - */ - pthread_mutex_unlock(&nic->xmit_mutex); + LOG_ERR(PFX "Pkt transmission failed."); } + LOG_PACKET(PFX "%s: sent %d bytes using bp->tx_prod: %d", nic->log_name, len, bp->tx_prod); } @@ -1412,6 +1408,8 @@ int bnx2x_write(nic_t *nic, nic_interface_t *nic_iface, packet_t *pkt) nic->log_name, pkt->buf_size, bp->tx_cons, bp->tx_prod, bp->tx_bd_prod); + pthread_mutex_unlock(&nic->xmit_mutex); + return 0; } @@ -1560,17 +1558,16 @@ static int bnx2x_clear_tx_intr(nic_t *nic) hw_cons = bp->get_tx_cons(bp); if (bp->tx_cons == hw_cons) { - if (bp->tx_cons == bp->tx_prod) { - /* Make sure the xmit_mutex lock is unlock */ - if (pthread_mutex_trylock(&nic->xmit_mutex)) - LOG_ERR(PFX "bnx2x tx lock with prod == cons"); - - pthread_mutex_unlock(&nic->xmit_mutex); + if (bp->tx_cons == bp->tx_prod) return 0; - } return -EAGAIN; } + if (pthread_mutex_trylock(&nic->xmit_mutex)) { + LOG_ERR(PFX "%s: unable to get xmit_mutex.", nic->log_name); + return -EINVAL; + } + LOG_PACKET(PFX "%s: clearing tx interrupt [%d %d]", nic->log_name, bp->tx_cons, hw_cons); bp->tx_cons = hw_cons; @@ -1600,6 +1597,7 @@ static int bnx2x_clear_tx_intr(nic_t *nic) nic->log_name, pkt->buf_size, bp->tx_cons, bp->tx_prod, bp->tx_bd_prod); + pthread_mutex_unlock(&nic->xmit_mutex); return 0; } diff --git a/iscsiuio/src/unix/libs/cnic.c b/iscsiuio/src/unix/libs/cnic.c index 5d60f89..a009f25 100644 --- a/iscsiuio/src/unix/libs/cnic.c +++ b/iscsiuio/src/unix/libs/cnic.c @@ -141,6 +141,7 @@ static int cnic_arp_send(nic_t *nic, nic_interface_t *nic_iface, int fd, memcpy(&addr.s_addr, &dst_ip, sizeof(addr.s_addr)); LOG_DEBUG(PFX "%s: Sent cnic arp request for IP: %s", nic->log_name, addr_str); + pthread_mutex_unlock(&nic->xmit_mutex); return 0; } @@ -204,6 +205,8 @@ static int cnic_neigh_soliciation_send(nic_t *nic, LOG_DEBUG(PFX "%s: Sent cnic ICMPv6 neighbor request %s", nic->log_name, addr_str); + pthread_mutex_unlock(&nic->xmit_mutex); + return 0; } @@ -433,9 +436,6 @@ done: rc = -EIO; } - if (status != 0 || rc != 0) - pthread_mutex_unlock(&nic->xmit_mutex); - if (ev) { cnic_nl_neigh_rsp(nic, fd, ev, path, mac_addr, nic_iface, status, AF_INET); @@ -632,9 +632,6 @@ done: rc = -EIO; } - if (status != 0 || rc != 0) - pthread_mutex_unlock(&nic->xmit_mutex); - if (ev) { cnic_nl_neigh_rsp(nic, fd, ev, path, mac_addr, nic_iface, status, AF_INET6); diff --git a/iscsiuio/src/unix/libs/qedi.c b/iscsiuio/src/unix/libs/qedi.c index c2096e5..c6ff6e7 100644 --- a/iscsiuio/src/unix/libs/qedi.c +++ b/iscsiuio/src/unix/libs/qedi.c @@ -887,7 +887,6 @@ void qedi_start_xmit(nic_t *nic, size_t len, u16_t vlan_id) nic->log_name, len, bp->tx_prod); } else { LOG_ERR(PFX "Pkt transmission failed: %d", rc); - pthread_mutex_unlock(&nic->xmit_mutex); } free(ubuf); @@ -950,6 +949,10 @@ int qedi_write(nic_t *nic, nic_interface_t *nic_iface, packet_t *pkt) nic->log_name, pkt->buf_size, bp->tx_cons, bp->tx_prod, bp->tx_bd_prod); + LOG_DEBUG(PFX "%s: host:%d - releasing xmit mutex", + nic->log_name, nic->host_no); + pthread_mutex_unlock(&nic->xmit_mutex); + return 0; } @@ -1059,17 +1062,16 @@ static int qedi_clear_tx_intr(nic_t *nic) hw_cons = uctrl->hw_tx_cons; if (bp->tx_cons == hw_cons) { - if (bp->tx_cons == bp->tx_prod) { - /* Make sure the xmit_mutex lock is unlock */ - if (pthread_mutex_trylock(&nic->xmit_mutex)) - LOG_ERR(PFX "qedi tx lock with prod == cons"); - - pthread_mutex_unlock(&nic->xmit_mutex); + if (bp->tx_cons == bp->tx_prod) return 0; - } return -EAGAIN; } + if (pthread_mutex_trylock(&nic->xmit_mutex)) { + LOG_ERR(PFX "%s: unable to get xmit_mutex.", nic->log_name); + return -EINVAL; + } + LOG_PACKET(PFX "%s: clearing tx interrupt [%d %d]", nic->log_name, bp->tx_cons, hw_cons); bp->tx_cons = hw_cons; @@ -1099,6 +1101,7 @@ static int qedi_clear_tx_intr(nic_t *nic) nic->log_name, pkt->buf_size, bp->tx_cons, bp->tx_prod, bp->tx_bd_prod); + pthread_mutex_unlock(&nic->xmit_mutex); return 0; } |