sk: Convey transmit path errors to the caller.

The transport layer's functional interface foresees having error codes
percolate back up to the caller.  However, up until now, the sk module
simply returned -1 for any error.  This patch lets the code return the
specific error instead.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2020-04-30 06:13:33 -07:00
parent d95fbcb566
commit a6e0b83bd5
1 changed files with 7 additions and 7 deletions

14
sk.c
View File

@ -354,7 +354,7 @@ int sk_receive(int fd, void *buf, int buflen,
"timed out while polling for tx timestamp");
pr_err("increasing tx_timestamp_timeout may correct "
"this issue, but it is likely caused by a driver bug");
return res;
return -errno;
} else if (!(pfd.revents & sk_revents)) {
pr_err("poll for tx timestamp woke up on non ERR event");
return -1;
@ -362,24 +362,24 @@ int sk_receive(int fd, void *buf, int buflen,
}
cnt = recvmsg(fd, &msg, flags);
if (cnt < 0)
if (cnt < 0) {
pr_err("recvmsg%sfailed: %m",
flags == MSG_ERRQUEUE ? " tx timestamp " : " ");
}
for (cm = CMSG_FIRSTHDR(&msg); cm != NULL; cm = CMSG_NXTHDR(&msg, cm)) {
level = cm->cmsg_level;
type = cm->cmsg_type;
if (SOL_SOCKET == level && SO_TIMESTAMPING == type) {
if (cm->cmsg_len < sizeof(*ts) * 3) {
pr_warning("short SO_TIMESTAMPING message");
return -1;
return -EMSGSIZE;
}
ts = (struct timespec *) CMSG_DATA(cm);
}
if (SOL_SOCKET == level && SO_TIMESTAMPNS == type) {
if (cm->cmsg_len < sizeof(*sw)) {
pr_warning("short SO_TIMESTAMPNS message");
return -1;
return -EMSGSIZE;
}
sw = (struct timespec *) CMSG_DATA(cm);
hwts->sw = timespec_to_tmv(*sw);
@ -391,7 +391,7 @@ int sk_receive(int fd, void *buf, int buflen,
if (!ts) {
memset(&hwts->ts, 0, sizeof(hwts->ts));
return cnt;
return cnt < 1 ? -errno : cnt;
}
switch (hwts->type) {
@ -407,7 +407,7 @@ int sk_receive(int fd, void *buf, int buflen,
hwts->ts = timespec_to_tmv(ts[1]);
break;
}
return cnt;
return cnt < 1 ? -errno : cnt;
}
int sk_set_priority(int fd, int family, uint8_t dscp)