[solved] Mactelnetd fix

Hi @jow

is there any chance to implement this patch in your mactelnetd package ?

problem:

It seems like the problem is because you are on both VLAN 1(untagged) and VLAN 20, and the Mikrotik is also that. So the first packet is sent to both interfaces, and then it continues on only the one.

discussion about problem:

thank you

Hi @jow

i tried to create patch

cat 000-timeout.patch 
--- a/mactelnetd.c      2015-09-02 14:37:36.000000000 +0200
+++ b/mactelnetd.c      2023-08-25 05:50:31.355408929 +0200
@@ -518,6 +518,11 @@
                        break;
 
                case MT_PTYPE_SESSIONSTART:
+                        curconn = list_find_connection(pkthdr.seskey, (unsigned char *)&(pkthdr.srcaddr));
+                        if (curconn != NULL) {
+                                /* Ignore multiple session starts from the same sender, this can be same mac but different interface */
+                                break;
+                        }
                        syslog(LOG_DEBUG, "(%d) New connection from %s.", pkt->seskey, ether_ntoa((struct ether_addr*)&(pkt->srcaddr)));
 
                        curconn = calloc(1, sizeof(*curconn));

and get this error

mactelnetd.c: In function 'handle_packet':
mactelnetd.c:521:56: error: 'pkthdr' undeclared (first use in this function)
  521 |                         curconn = list_find_connection(pkthdr.seskey, (unsigned char *)&(pkthdr.srcaddr));
      |                                                        ^~~~~~
mactelnetd.c:521:56: note: each undeclared identifier is reported only once for each function it appears in
mactelnetd.c:573:25: warning: 'uloop_timeout_remaining' is deprecated: use uloop_timeout_remaining64 [-Wdeprecated-declarations]
  573 |                         if (uloop_timeout_remaining(&curconn->timeout) > 9000) {
      |                         ^~
In file included from mactelnetd.c:51:
/mnt/storage1/openwrt/2203/staging_dir/target-mipsel_24kc_musl/usr/include/libubox/uloop.h:95:5: note: declared here
   95 | int uloop_timeout_remaining(struct uloop_timeout *timeout) __attribute__((deprecated("use uloop_timeout_remaining64")));
      |     ^~~~~~~~~~~~~~~~~~~~~~~
make[3]: *** [Makefile:65: mactelnetd] Error 1

could you please help ?

Hi @jow

sorry for ping

after all, i make this patch, but i am very unsure in my programming knowledge
it is working, no more timeouts
... any opinion ? is this correct this way ?

diff --git a/mactelnetd.c b/mactelnetd.c
index 38666f8..fb94f9c 100644
--- a/mactelnetd.c
+++ b/mactelnetd.c
@@ -518,6 +518,11 @@ static void handle_packet(struct mt_mactelnet_hdr *pkt, struct sockaddr_in *src,
                        break;
 
                case MT_PTYPE_SESSIONSTART:
+                       curconn = list_find_connection(pkt->seskey, (struct ether_addr*)&(pkt->srcaddr));
+                               if (curconn != NULL) {
+                               /* Ignore multiple session starts from the same sender, this can be same mac but different interface */
+                               break;
+                       }
                        syslog(LOG_DEBUG, "(%d) New connection from %s.", pkt->seskey, ether_ntoa((struct ether_addr*)&(pkt->srcaddr)));
 
                        curconn = calloc(1, sizeof(*curconn));

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.