@@ -546,20 +546,21 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu)
return -1;
}
- if (entry->s.pkt_sock_mmap.sockfd)
- sockfd = entry->s.pkt_sock_mmap.sockfd;
- else
- sockfd = entry->s.pkt_sock.sockfd;
+ lock_entry(entry);
- strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ);
+ sockfd = sockfd_from_pktio_entry(entry);
+ strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1);
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
ifr.ifr_mtu = mtu;
ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)&ifr);
if (ret < 0) {
ODP_DBG("ioctl SIOCSIFMTU error\n");
+ unlock_entry(entry);
return -1;
}
+ unlock_entry(entry);
return 0;
}
@@ -576,19 +577,20 @@ int odp_pktio_mtu(odp_pktio_t id)
return -1;
}
- if (entry->s.pkt_sock_mmap.sockfd)
- sockfd = entry->s.pkt_sock_mmap.sockfd;
- else
- sockfd = entry->s.pkt_sock.sockfd;
+ lock_entry(entry);
- strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ);
+ sockfd = sockfd_from_pktio_entry(entry);
+ strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1);
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
ret = ioctl(sockfd, SIOCGIFMTU, &ifr);
if (ret < 0) {
ODP_DBG("ioctl SIOCGIFMTU error\n");
+ unlock_entry(entry);
return -1;
}
+ unlock_entry(entry);
return ifr.ifr_mtu;
}
Use helper function to get socket fd and add locks. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- platform/linux-generic/odp_packet_io.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)