Subject SHA-1 Author Date
Added support for FORCE_NET_V*_CONN_ERROR to return an error for connect syscall c221dc3ff63bcd28c2053694177a9a09ef9a6570 Catalin(ux) M. BOIE 2019-03-20 18:26:19
rpm changelog e7127f5191015b0b93c7108b6fa02fde7f0fe909 Catalin(ux) M. BOIE 2019-02-05 21:10:57
duilder update 71425ef75fbc076d6601ceadd52e81e678aabe57 Catalin(ux) M. BOIE 2019-02-05 21:09:29
Switch to v0.13 7a5ed99fa6629ff9dbe16f6b015712a78854b621 Catalin(ux) M. BOIE 2019-02-05 21:08:06
Lots of changes e11f13f4d11723f0c2c833ffbaca89e55d74e139 Catalin(ux) M. BOIE 2019-01-16 20:18:06
Restart accept interrupted by signal d84134f3193fd2d4c5298eaded8ffade5d74d220 Catalin(ux) M. BOIE 2014-11-11 06:57:12
Bump version to 0.12 ea1c70a262b706cd45f1eb98b6aa9805de300647 Catalin(ux) M. BOIE 2014-10-14 03:14:29
Added support to change poll timeout d0e5782e1fb0da5db1291b3c518486d3ac8dec97 Catalin(ux) M. BOIE 2014-10-14 03:13:58
Fixed strcmp on a NULL variable 59df6d596e3c842227f4f374b4b6635de3ce1c3e Catalin(ux) M. BOIE 2014-10-14 03:12:29
Added support for deny and fake for Kevin d9598fd2ca7886484b78512d71dbd29059720832 Catalin(ux) M. BOIE 2012-07-18 21:13:20
Commit d0e5782e1fb0da5db1291b3c518486d3ac8dec97 - Added support to change poll timeout
Author: Catalin(ux) M. BOIE
Author date (UTC): 2014-10-14 03:13
Committer: Catalin(ux) M. BOIE
Commit date (UTC): 2014-10-14 03:13
Tree: 3fb0041aa6cae763cc5a0b69f6746120521147d0
Parents: 59df6d596e3c842227f4f374b4b6635de3ce1c3e
File Lines added Lines deleted
Makefile.in 3 0
README 1 1
TODO 11 5
force_bind.c 32 2
force_bind.spec.in 1 1
test_poll.c 27 0

File Makefile.in changed (mode: 100644) (index e87d60c..b881de1)
... ... test_client: test_client.c
22 22 test_client6: test_client6.c test_client6: test_client6.c
23 23 $(CC) $(CFLAGS) $< -o $@ $(CC) $(CFLAGS) $< -o $@
24 24
25 test_poll: test_poll.c
26 $(CC) $(CFLAGS) $< -o $@
27
25 28 .PHONY: clean .PHONY: clean
26 29 clean: clean:
27 30 @rm -f force_bind.so.* test_bind send_udp test_client test_client6 \ @rm -f force_bind.so.* test_bind send_udp test_client test_client6 \

File README changed (mode: 100644) (index 95feff7..a2eefad)
... ... Examples:
105 105 export FORCE_NET_VERBOSE=1 export FORCE_NET_VERBOSE=1
106 106 export LD_PRELOAD=${LD_PRELOAD}:/usr/lib/force_bind.so export LD_PRELOAD=${LD_PRELOAD}:/usr/lib/force_bind.so
107 107 # 1. Make sure you have a 'prio' qdisc attached to eth0, for example: # 1. Make sure you have a 'prio' qdisc attached to eth0, for example:
108 tc qdisc add ev eth0 root handle 1: prio
108 tc qdisc add dev eth0 root handle 1: prio
109 109 # 2. Assign applications to classed (bands): # 2. Assign applications to classed (bands):
110 110 export FORCE_NET_PRIO=6 # interactive, band 0 export FORCE_NET_PRIO=6 # interactive, band 0
111 111 your_voip_program_here your_voip_program_here

File TODO changed (mode: 100644) (index 5c2fda3..ffddfcc)
1 [ ] Document force_poll_timeout
2 [ ] Split binding on connect from the one used for listen.
1 3 [ ] If we have more bind calls, we have a problem. Probably we have to use a table like this: [ ] If we have more bind calls, we have a problem. Probably we have to use a table like this:
2 ipv4 0.0.0.0/80 127.0.0.2/8080
3 ipv6 ::/80 ::1/8080
4 unix /tmp/sock /tmp/sock1
4 #oper family type address/port address/port
5 bind ipv4 dgram 0.0.0.0/80 127.0.0.2/8080
6 bind ipv6 stream ::/80 ::1/8080
7 bind unix stream /tmp/sock /tmp/sock1
8 alter * stream...
5 9 [ ] Test UDP sendto and sendmsg! [ ] Test UDP sendto and sendmsg!
6 10 [ ] Probably we have to hijack also dup/dup2/etc. [ ] Probably we have to hijack also dup/dup2/etc.
7 11 [ ] Bandwidth per total or per socket. Better, per ip/protocol [ ] Bandwidth per total or per socket. Better, per ip/protocol
 
15 19 [ ] Dump statistics (bytes, syscalls etc.) in a file specified by a env var. [ ] Dump statistics (bytes, syscalls etc.) in a file specified by a env var.
16 20 [ ] Need to study how to set only the class for IPv6. Also check Linux kernel [ ] Need to study how to set only the class for IPv6. Also check Linux kernel
17 21 to see how prio is set for IPv6 class. to see how prio is set for IPv6 class.
18 [ ] Nice: Force a protocol on a connection! So, uer tries TCP but get UDP!
22 [ ] Nice: Force a protocol on a connection! So, user tries TCP but get UDP!
19 23 [ ] Controlling timeout (SO_RCVTIMEO, SO_SNDTIMEO) [ ] Controlling timeout (SO_RCVTIMEO, SO_SNDTIMEO)
20 24 [ ] Enforce connect timeout [ ] Enforce connect timeout
21 25 [ ] Change data on the fly... [ ] Change data on the fly...
22 26 [ ] Allow saving stream data in a file. [ ] Allow saving stream data in a file.
23 27 [ ] sendmmsg/recvmmsg support [ ] sendmmsg/recvmmsg support
24 28 [ ] There are stupid applications (skype) that run poll with timeout 0! Fix it! [ ] There are stupid applications (skype) that run poll with timeout 0! Fix it!
25 [ ]
29 [ ] Remote network: transport all sockets operations over another socket to a
30 remote host.
31 [ ]

File force_bind.c changed (mode: 100644) (index 02b98b8..6e89448)
32 32 #include <arpa/inet.h> #include <arpa/inet.h>
33 33 #include <netinet/in.h> #include <netinet/in.h>
34 34 #include <netinet/tcp.h> #include <netinet/tcp.h>
35 #include <poll.h>
35 36
36 37 #include "force_bind_config.h" #include "force_bind_config.h"
37 38
 
... ... static ssize_t (*old_sendto)(int sockfd, const void *buf, size_t len, int flag
110 111 static ssize_t (*old_sendmsg)(int sockfd, const struct msghdr *msg, int flags); static ssize_t (*old_sendmsg)(int sockfd, const struct msghdr *msg, int flags);
111 112 static int (*old_accept)(int sockfd, struct sockaddr *addr, socklen_t *addrlen); static int (*old_accept)(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
112 113 static int (*old_connect)(int sockfd, const struct sockaddr *addr, socklen_t addrlen); static int (*old_connect)(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
114 static int (*old_poll)(struct pollfd *fds, nfds_t nfds, int timeout);
113 115
114 116 static char *force_address_v4 = NULL; static char *force_address_v4 = NULL;
115 117 static char *force_address_v6 = NULL; static char *force_address_v6 = NULL;
 
... ... static struct info fdinfo;
130 132 static unsigned int verbose = 0; static unsigned int verbose = 0;
131 133 static char *log_file = NULL; static char *log_file = NULL;
132 134 static FILE *Log = NULL; static FILE *Log = NULL;
135 static int force_poll_timeout = -1000;
133 136
134 137
135 138 /* Helper functions */ /* Helper functions */
 
... ... static void xlog(const unsigned int level, const char *format, ...)
215 218 va_end(ap); va_end(ap);
216 219 } }
217 220
218 static void dump(const int level, const char *title, const void *buf,
221 void dump(const int level, const char *title, const void *buf,
219 222 const unsigned int len) const unsigned int len)
220 223 { {
221 224 unsigned int i; unsigned int i;
 
... ... static void init(void)
357 360 fdinfo.tail = NULL; fdinfo.tail = NULL;
358 361
359 362 log_file = getenv("FORCE_NET_LOG"); log_file = getenv("FORCE_NET_LOG");
360 if (log_file != NULL)
363 if (log_file != NULL) {
361 364 Log = fopen(log_file, "w"); Log = fopen(log_file, "w");
365 setlinebuf(Log);
366 }
362 367
363 368 x = getenv("FORCE_NET_VERBOSE"); x = getenv("FORCE_NET_VERBOSE");
364 369 if (x != NULL) if (x != NULL)
 
... ... static void init(void)
521 526 prio); prio);
522 527 } }
523 528
529 /* poll timeout */
530 x = getenv("FORCE_NET_POLL_TIMEOUT");
531 if (x != NULL) {
532 force_poll_timeout = strtoul(x, NULL, 0);
533 xlog(1, "Force poll timeout to %d.\n",
534 force_poll_timeout);
535 }
536
537 /******** Now, hijack system calls ********/
524 538
525 539 old_bind = dlsym(RTLD_NEXT, "bind"); old_bind = dlsym(RTLD_NEXT, "bind");
526 540 if (old_bind == NULL) { if (old_bind == NULL) {
 
... ... static void init(void)
582 596 exit(1); exit(1);
583 597 } }
584 598
599 old_poll = dlsym(RTLD_NEXT, "poll");
600 if (old_poll == NULL) {
601 xlog(0, "Cannot resolve 'poll'!\n");
602 exit(1);
603 }
604
585 605 xlog(1, "Init ended.\n"); xlog(1, "Init ended.\n");
586 606 } }
587 607
 
... ... int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
1231 1251 return old_connect(sockfd, (struct sockaddr *) &new_dest, addrlen); return old_connect(sockfd, (struct sockaddr *) &new_dest, addrlen);
1232 1252 } }
1233 1253
1254 int poll(struct pollfd *fds, nfds_t nfds, int timeout)
1255 {
1256 xlog(2, "poll(fds, %d, %d) old_poll=%p\n", nfds, timeout, old_poll);
1257
1258 if (force_poll_timeout != -1000)
1259 timeout = force_poll_timeout;
1260
1261 return old_poll(fds, nfds, timeout);
1262 }
1263

File force_bind.spec.in changed (mode: 100644) (index b7b631f..d3e9125)
... ... Version: @VER@
4 4 Release: @REV@ Release: @REV@
5 5 License: GPLv3+ License: GPLv3+
6 6 Group: Applications/Communications Group: Applications/Communications
7 Source: http://kernel.embedromix.ro/us/Conn/%{name}-%{version}.tar.gz
7 Source: http://kernel.embedromix.ro/us/%{name}/%{name}-%{version}.tar.gz
8 8 URL: http://kernel.embedromix.ro/us/ URL: http://kernel.embedromix.ro/us/
9 9 BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
10 10

File test_poll.c added (mode: 100644) (index 0000000..0e31b61)
1 /*
2 * This program test poll syscall with a timeout of 0. Skype is acting stupid.
3 * Copyright: Catalin(ux) M. BOIE
4 * Part of force_bind package
5 */
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <sys/un.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <unistd.h>
13 #include <arpa/inet.h>
14 #include <poll.h>
15
16 int main(void)
17 {
18 struct pollfd fds;
19 int ret;
20
21 fds.fd = 0;
22 fds.events = POLLIN;
23 ret = poll(&fds, 1, 0);
24 printf("ret = %d\n", ret);
25
26 return 0;
27 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/force_bind

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/force_bind

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/force_bind

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master