Changeset a3d0b8a in rtems


Ignore:
Timestamp:
Dec 10, 1998, 7:42:29 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
b1bc63b
Parents:
2ffe30d
Message:

Patch from Ian Lance Taylor <ian@…>:

From: Eric Norum <eric@…>
Date: Sat, 5 Dec 98 13:20:51 -0600

What do you think of this patch? It implements your `tap'
suggestion in a way that adds support for all ethernet devices with
no driver modifications. I also added a return value from the tap
function. If the return value is zero, the packet will be passed up
the chain as usual. If the return value is non-zero the mbuf holding
the packet will be freed and the packet will be dropped.

If you like it, please submit it to Joel.

I guess there needs to be an addition to the network documentation
describing the additional ioctl's -- and a big warning that the tap
function is called from a context that holds the network semaphore.

Here is Eric's patch. I've tested it a bit, and made a couple of
trivial changes. This is certainly better than mine: it should work
for all Ethernet drivers.
==================================================

The only concern I have about this patch is that the tap function may
want to fiddle with the mbuf, calling functions like m_pullup and the
like. If those force the networking code to rearrange the mbuf
structure, then the caller's call to m_freem may crash. I don't know
if this is a realistic concern--I don't know enough about the mbuf
layer.

Files:
17 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/include/sys/sockio.h

    r2ffe30d ra3d0b8a  
    8484#define SIOCGIFMEDIA    _IOWR('i', 56, struct ifmediareq) /* get net media */
    8585
     86
     87/*
     88 * RTEMS additions for setting/getting `tap' function on incoming packets.
     89 */
     90#define SIOCSIFTAP       _IOW('i', 80, struct ifreq)    /* set tap function */
     91#define SIOCGIFTAP      _IOWR('i', 81, struct ifreq)    /* get tap function */
     92
    8693#endif /* !_SYS_SOCKIO_H_ */
  • c/src/exec/libnetworking/net/if.c

    r2ffe30d ra3d0b8a  
    665665            }
    666666#endif
     667
     668        /*
     669         * RTEMS additions for setting/getting `tap' function
     670         */
     671        case SIOCSIFTAP:
     672                ifp->if_tap = ifr->ifr_tap;
     673                return 0;
     674
     675        case SIOCGIFTAP:
     676                ifr->ifr_tap = ifp->if_tap;
     677                return 0;
    667678        }
    668679        return (0);
  • c/src/exec/libnetworking/net/if.h

    r2ffe30d ra3d0b8a  
    163163        void    (*if_init)              /* Init routine */
    164164                __P((void *));
     165        int     (*if_tap)               /* Packet filter routine */
     166                (struct ifnet *, struct ether_header *, struct mbuf *);
    165167        struct  ifqueue if_snd;         /* output queue */
    166168        struct  ifqueue *if_poll_slowq; /* input queue for slow devices */
     
    370372                int     ifru_media;
    371373                caddr_t ifru_data;
     374                int     (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
    372375        } ifr_ifru;
    373376#define ifr_addr        ifr_ifru.ifru_addr      /* address */
     
    380383#define ifr_media       ifr_ifru.ifru_media     /* physical media */
    381384#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
     385#define ifr_tap         ifr_ifru.ifru_tap       /* tap function */
    382386};
    383387
  • c/src/exec/libnetworking/net/if_ethersubr.c

    r2ffe30d ra3d0b8a  
    484484                ifp->if_imcasts++;
    485485
     486        /*
     487         * RTEMS addition -- allow application to `tap into'
     488         * the incoming packet stream.
     489         */
     490        if (ifp->if_tap && (*ifp->if_tap)(ifp, eh, m)) {
     491                m_freem(m);
     492                return;
     493        }
     494
    486495        ether_type = ntohs(eh->ether_type);
    487496
  • c/src/lib/include/sys/sockio.h

    r2ffe30d ra3d0b8a  
    8484#define SIOCGIFMEDIA    _IOWR('i', 56, struct ifmediareq) /* get net media */
    8585
     86
     87/*
     88 * RTEMS additions for setting/getting `tap' function on incoming packets.
     89 */
     90#define SIOCSIFTAP       _IOW('i', 80, struct ifreq)    /* set tap function */
     91#define SIOCGIFTAP      _IOWR('i', 81, struct ifreq)    /* get tap function */
     92
    8693#endif /* !_SYS_SOCKIO_H_ */
  • c/src/lib/libnetworking/net/if.c

    r2ffe30d ra3d0b8a  
    665665            }
    666666#endif
     667
     668        /*
     669         * RTEMS additions for setting/getting `tap' function
     670         */
     671        case SIOCSIFTAP:
     672                ifp->if_tap = ifr->ifr_tap;
     673                return 0;
     674
     675        case SIOCGIFTAP:
     676                ifr->ifr_tap = ifp->if_tap;
     677                return 0;
    667678        }
    668679        return (0);
  • c/src/lib/libnetworking/net/if.h

    r2ffe30d ra3d0b8a  
    163163        void    (*if_init)              /* Init routine */
    164164                __P((void *));
     165        int     (*if_tap)               /* Packet filter routine */
     166                (struct ifnet *, struct ether_header *, struct mbuf *);
    165167        struct  ifqueue if_snd;         /* output queue */
    166168        struct  ifqueue *if_poll_slowq; /* input queue for slow devices */
     
    370372                int     ifru_media;
    371373                caddr_t ifru_data;
     374                int     (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
    372375        } ifr_ifru;
    373376#define ifr_addr        ifr_ifru.ifru_addr      /* address */
     
    380383#define ifr_media       ifr_ifru.ifru_media     /* physical media */
    381384#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
     385#define ifr_tap         ifr_ifru.ifru_tap       /* tap function */
    382386};
    383387
  • c/src/lib/libnetworking/net/if_ethersubr.c

    r2ffe30d ra3d0b8a  
    484484                ifp->if_imcasts++;
    485485
     486        /*
     487         * RTEMS addition -- allow application to `tap into'
     488         * the incoming packet stream.
     489         */
     490        if (ifp->if_tap && (*ifp->if_tap)(ifp, eh, m)) {
     491                m_freem(m);
     492                return;
     493        }
     494
    486495        ether_type = ntohs(eh->ether_type);
    487496
  • c/src/lib/libnetworking/sys/sockio.h

    r2ffe30d ra3d0b8a  
    8484#define SIOCGIFMEDIA    _IOWR('i', 56, struct ifmediareq) /* get net media */
    8585
     86
     87/*
     88 * RTEMS additions for setting/getting `tap' function on incoming packets.
     89 */
     90#define SIOCSIFTAP       _IOW('i', 80, struct ifreq)    /* set tap function */
     91#define SIOCGIFTAP      _IOWR('i', 81, struct ifreq)    /* get tap function */
     92
    8693#endif /* !_SYS_SOCKIO_H_ */
  • c/src/libnetworking/net/if.c

    r2ffe30d ra3d0b8a  
    665665            }
    666666#endif
     667
     668        /*
     669         * RTEMS additions for setting/getting `tap' function
     670         */
     671        case SIOCSIFTAP:
     672                ifp->if_tap = ifr->ifr_tap;
     673                return 0;
     674
     675        case SIOCGIFTAP:
     676                ifr->ifr_tap = ifp->if_tap;
     677                return 0;
    667678        }
    668679        return (0);
  • c/src/libnetworking/net/if.h

    r2ffe30d ra3d0b8a  
    163163        void    (*if_init)              /* Init routine */
    164164                __P((void *));
     165        int     (*if_tap)               /* Packet filter routine */
     166                (struct ifnet *, struct ether_header *, struct mbuf *);
    165167        struct  ifqueue if_snd;         /* output queue */
    166168        struct  ifqueue *if_poll_slowq; /* input queue for slow devices */
     
    370372                int     ifru_media;
    371373                caddr_t ifru_data;
     374                int     (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
    372375        } ifr_ifru;
    373376#define ifr_addr        ifr_ifru.ifru_addr      /* address */
     
    380383#define ifr_media       ifr_ifru.ifru_media     /* physical media */
    381384#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
     385#define ifr_tap         ifr_ifru.ifru_tap       /* tap function */
    382386};
    383387
  • c/src/libnetworking/net/if_ethersubr.c

    r2ffe30d ra3d0b8a  
    484484                ifp->if_imcasts++;
    485485
     486        /*
     487         * RTEMS addition -- allow application to `tap into'
     488         * the incoming packet stream.
     489         */
     490        if (ifp->if_tap && (*ifp->if_tap)(ifp, eh, m)) {
     491                m_freem(m);
     492                return;
     493        }
     494
    486495        ether_type = ntohs(eh->ether_type);
    487496
  • c/src/libnetworking/sys/sockio.h

    r2ffe30d ra3d0b8a  
    8484#define SIOCGIFMEDIA    _IOWR('i', 56, struct ifmediareq) /* get net media */
    8585
     86
     87/*
     88 * RTEMS additions for setting/getting `tap' function on incoming packets.
     89 */
     90#define SIOCSIFTAP       _IOW('i', 80, struct ifreq)    /* set tap function */
     91#define SIOCGIFTAP      _IOWR('i', 81, struct ifreq)    /* get tap function */
     92
    8693#endif /* !_SYS_SOCKIO_H_ */
  • cpukit/libcsupport/include/sys/sockio.h

    r2ffe30d ra3d0b8a  
    8484#define SIOCGIFMEDIA    _IOWR('i', 56, struct ifmediareq) /* get net media */
    8585
     86
     87/*
     88 * RTEMS additions for setting/getting `tap' function on incoming packets.
     89 */
     90#define SIOCSIFTAP       _IOW('i', 80, struct ifreq)    /* set tap function */
     91#define SIOCGIFTAP      _IOWR('i', 81, struct ifreq)    /* get tap function */
     92
    8693#endif /* !_SYS_SOCKIO_H_ */
  • cpukit/libnetworking/net/if.c

    r2ffe30d ra3d0b8a  
    665665            }
    666666#endif
     667
     668        /*
     669         * RTEMS additions for setting/getting `tap' function
     670         */
     671        case SIOCSIFTAP:
     672                ifp->if_tap = ifr->ifr_tap;
     673                return 0;
     674
     675        case SIOCGIFTAP:
     676                ifr->ifr_tap = ifp->if_tap;
     677                return 0;
    667678        }
    668679        return (0);
  • cpukit/libnetworking/net/if.h

    r2ffe30d ra3d0b8a  
    163163        void    (*if_init)              /* Init routine */
    164164                __P((void *));
     165        int     (*if_tap)               /* Packet filter routine */
     166                (struct ifnet *, struct ether_header *, struct mbuf *);
    165167        struct  ifqueue if_snd;         /* output queue */
    166168        struct  ifqueue *if_poll_slowq; /* input queue for slow devices */
     
    370372                int     ifru_media;
    371373                caddr_t ifru_data;
     374                int     (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
    372375        } ifr_ifru;
    373376#define ifr_addr        ifr_ifru.ifru_addr      /* address */
     
    380383#define ifr_media       ifr_ifru.ifru_media     /* physical media */
    381384#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
     385#define ifr_tap         ifr_ifru.ifru_tap       /* tap function */
    382386};
    383387
  • cpukit/libnetworking/net/if_ethersubr.c

    r2ffe30d ra3d0b8a  
    484484                ifp->if_imcasts++;
    485485
     486        /*
     487         * RTEMS addition -- allow application to `tap into'
     488         * the incoming packet stream.
     489         */
     490        if (ifp->if_tap && (*ifp->if_tap)(ifp, eh, m)) {
     491                m_freem(m);
     492                return;
     493        }
     494
    486495        ether_type = ntohs(eh->ether_type);
    487496
Note: See TracChangeset for help on using the changeset viewer.