#32 ioctl, tty line discipline, and NGM_TTY_COOKIE

open
Archie Cobbs
None
8
2014-08-16
2010-03-16
Gabriel B
No

Hello,
I have a USB 3G modem. I'm trying to use mpd5 (v 5.5) on FreeBSD 8.0 to connect to my ISP. This is the response.

[root@pfsense.local]/conf(68): mpd5 -d /conf/
Multi-link PPP daemon for FreeBSD

process 39822 started, version 5.5 (root@FreeBSD_8.0_pfSense_2.0-snaps.pfsense.org 14:43 28-Feb-2010)
[L1] [L1] Link: OPEN event
[L1] LCP: Open event
[L1] LCP: state change Initial --> Starting
[L1] LCP: LayerStart
[L1] can't create tee node at ".:"->"l0": No such file or directory
[L1] chat: Detected Hayes compatible modem.
[L1] chat: Dialing server at *99#...
[L1] chat: Connected at 7200000.
[L1] MODEM: chat script succeeded
[L1] ioctl(TIOCSETD, 6): Inappropriate ioctl for device
[L1] Link: DOWN event
[L1] LCP: Close event
[L1] LCP: state change Starting --> Initial
[L1] LCP: LayerFinish
[L1] LCP: Down event
caught fatal signal int
[B1] Bundle: Shutdown
[L1] Link: Shutdown
process 39822 terminated
[2.0-BETA1] [root@pfsense.local]/conf(69):

I've looked at the mpd source code (modem.c) and found the source of the error starting here at line 544.
http://mpd.cvs.sourceforge.net/viewvc/mpd/mpd/src/modem.c?annotate=1.70#l544

#if NGM_TTY_COOKIE < 1226109660
/* Install ng_tty line discipline */
if (ioctl(m->fd, TIOCSETD, &ldisc) < 0) {

/* Installation of the tty node type should be automatic, but isn't yet.
The 'mkpeer' below will fail, because you can only create a ng_tty
node via TIOCSETD; however, this will force a load of the node type. */
if (errno == ENODEV) {
(void)NgSendAsciiMsg(m->csock, ".:",
"mkpeer { type=\"%s\" ourhook=\"dummy\" peerhook=\"%s\" }",
NG_TTY_NODE_TYPE, NG_TTY_HOOK);
}
if (ioctl(m->fd, TIOCSETD, &ldisc) < 0) {
Log(LG_ERR, ("[%s] ioctl(TIOCSETD, %d): %s",
l->name, ldisc, strerror(errno)));
close(m->csock);
return(-1);
}

Then I looked at the NGM_TTY_COOKIE value in ng_tty.h in svn /stable/8/sys/netgraph/ng_tty.h
http://svn.freebsd.org/viewvc/base/head/sys/netgraph/ng_tty.h?annotate=184760#l50

50 mav 184760 #define NGM_TTY_COOKIE 1226109660
51 julian 52419
52 /* Default hot char */
53 #define NG_TTY_DFL_HOTCHAR 0x7e /* PPP flag byte */

And now I'm totally confused. The NGM_TTY_COOKIE is set at 1226109660.

The code in modem.c that is generating the error is only supposed to execute if the NGM_TTY_COOKIE is LESS than 1226109660. Why is the error being generated? I don't understand what is happening.

Perhaps the condition check for the error is incorrect? It seems odd to have the 'if' clause conditions repeated within the initial check.

Please help.

Gabriel

Discussion

  • Gabriel B
    Gabriel B
    2010-03-16

    • priority: 5 --> 8
    • assigned_to: nobody --> amotin
     
  • Gabriel B
    Gabriel B
    2010-03-18

    I've tested changing the two
    #if NGM_TTY_COOKIE < 1226109660

    statements in modem.c so that the code jumps the the #else portion and recompiled mpd v5.5, and then I run into this -> (MODEM: can't connect async node) as seen below.
    I'm not sure why this is happening. I looked at the source but don't know netgraph well enough to know what's going on ??

    [2.0-BETA1][root@pfsense.local]/root(1): mpd5 -d /conf/
    Multi-link PPP daemon for FreeBSD

    process 25977 started, version 5.5 (root@ 13:07 17-Mar-2010)
    [L1] [L1] Link: OPEN event
    [L1] LCP: Open event
    [L1] LCP: state change Initial --> Starting
    [L1] LCP: LayerStart
    [L1] can't create tee node at ".:"->"l0": No such file or directory
    [L1] chat: Detected Hayes compatible modem.
    [L1] chat: Dialing server at *99#...
    [L1] chat: Connected at 7200000.
    [L1] MODEM: chat script succeeded
    [L1] MODEM: can't connect async node
    [L1] can't shutdown "[a]:hook": Bad file descriptor
    [L1] can't shutdown "[a]:": Bad file descriptor
    [L1] Link: DOWN event
    [L1] LCP: Close event
    [L1] LCP: state change Starting --> Initial
    [L1] LCP: LayerFinish
    [L1] LCP: Down event
    caught fatal signal int
    [B1] Bundle: Shutdown
    [L1] Link: Shutdown
    process 25977 terminated

     
  • Gabriel B
    Gabriel B
    2010-03-18

    • assigned_to: amotin --> archiecobbs