If I use sendfile() to send to a accept()ed AF_ALG socket set up for "hash", I get the wrong answer, if I read() and then write() I get the right answer. None of the system calls return an error. test case attached. -- --- Shawn Landden +1 360 389 3001 (SMS preferred)
#include <sys/sendfile.h> #include <sys/socket.h> #include <linux/if_alg.h> #include <stdio.h> #include <sys/stat.h> #include <fcntl.h> int main(void) { int opfd; int tfmfd; struct sockaddr_alg sa = { .salg_family = AF_ALG, .salg_type = "hash", .salg_name = "sha1" }; char buf2[10000000]; char buf[20]; int i; struct stat st; tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0); bind(tfmfd, (struct sockaddr *)&sa, sizeof(sa)); opfd = accept(tfmfd, NULL, 0); int true = open("/bin/true", O_RDONLY); fstat(true, &st); sendfile(opfd, true, NULL, st.st_size); read(opfd, &buf, 20); for (i = 0; i < 20; i++) { printf("%02x", (unsigned char)buf[i]); } printf("\n"); lseek(true, 0, SEEK_SET); read(true, &buf2, st.st_size); write(opfd, &buf2, st.st_size); read(opfd, &buf, 20); for (i = 0; i < 20; i++) { printf("%02x", (unsigned char)buf[i]); } printf("\n"); close(opfd); close(tfmfd); return 0; }