head 1.172; access; symbols netbsd-10-0-RELEASE:1.172 netbsd-10-0-RC6:1.172 netbsd-10-0-RC5:1.172 netbsd-10-0-RC4:1.172 netbsd-10-0-RC3:1.172 netbsd-10-0-RC2:1.172 thorpej-ifq:1.172.0.8 thorpej-ifq-base:1.172 thorpej-altq-separation:1.172.0.6 thorpej-altq-separation-base:1.172 netbsd-10-0-RC1:1.172 netbsd-10:1.172.0.4 netbsd-10-base:1.172 bouyer-sunxi-drm:1.172.0.2 bouyer-sunxi-drm-base:1.172 netbsd-9-3-RELEASE:1.165 thorpej-i2c-spi-conf2:1.167.0.20 thorpej-i2c-spi-conf2-base:1.167 thorpej-futex2:1.167.0.18 thorpej-futex2-base:1.167 thorpej-cfargs2:1.167.0.16 thorpej-cfargs2-base:1.167 cjep_sun2x-base1:1.167 cjep_sun2x:1.167.0.14 cjep_sun2x-base:1.167 cjep_staticlib_x-base1:1.167 netbsd-9-2-RELEASE:1.165 cjep_staticlib_x:1.167.0.12 cjep_staticlib_x-base:1.167 thorpej-i2c-spi-conf:1.167.0.10 thorpej-i2c-spi-conf-base:1.167 thorpej-cfargs:1.167.0.8 thorpej-cfargs-base:1.167 thorpej-futex:1.167.0.6 thorpej-futex-base:1.167 netbsd-9-1-RELEASE:1.165 bouyer-xenpvh-base2:1.167 phil-wifi-20200421:1.167 bouyer-xenpvh-base1:1.167 phil-wifi-20200411:1.167 bouyer-xenpvh:1.167.0.4 bouyer-xenpvh-base:1.167 is-mlppp:1.167.0.2 is-mlppp-base:1.167 phil-wifi-20200406:1.167 netbsd-8-2-RELEASE:1.158.8.2 ad-namecache-base3:1.167 netbsd-9-0-RELEASE:1.165 netbsd-9-0-RC2:1.165 ad-namecache-base2:1.166 ad-namecache-base1:1.166 ad-namecache:1.166.0.2 ad-namecache-base:1.166 netbsd-9-0-RC1:1.165 phil-wifi-20191119:1.166 netbsd-9:1.165.0.2 netbsd-9-base:1.165 phil-wifi-20190609:1.164 netbsd-8-1-RELEASE:1.158.8.2 netbsd-8-1-RC1:1.158.8.2 isaki-audio2:1.164.0.2 isaki-audio2-base:1.164 pgoyette-compat-merge-20190127:1.159.2.4 pgoyette-compat-20190127:1.164 pgoyette-compat-20190118:1.163 pgoyette-compat-1226:1.161 pgoyette-compat-1126:1.161 pgoyette-compat-1020:1.161 pgoyette-compat-0930:1.161 pgoyette-compat-0906:1.161 netbsd-7-2-RELEASE:1.146 pgoyette-compat-0728:1.161 netbsd-8-0-RELEASE:1.158 phil-wifi:1.161.0.2 phil-wifi-base:1.161 pgoyette-compat-0625:1.160 netbsd-8-0-RC2:1.158 pgoyette-compat-0521:1.159 pgoyette-compat-0502:1.159 pgoyette-compat-0422:1.159 netbsd-8-0-RC1:1.158 pgoyette-compat-0415:1.159 pgoyette-compat-0407:1.159 pgoyette-compat-0330:1.159 pgoyette-compat-0322:1.159 pgoyette-compat-0315:1.159 netbsd-7-1-2-RELEASE:1.146 pgoyette-compat:1.159.0.2 pgoyette-compat-base:1.159 netbsd-7-1-1-RELEASE:1.146 tls-maxphys-base-20171202:1.159 matt-nb8-mediatek:1.158.0.12 matt-nb8-mediatek-base:1.158 nick-nhusb-base-20170825:1.158 perseant-stdc-iso10646:1.158.0.10 perseant-stdc-iso10646-base:1.158 netbsd-8:1.158.0.8 netbsd-8-base:1.158 prg-localcount2-base3:1.158 prg-localcount2-base2:1.158 prg-localcount2-base1:1.158 prg-localcount2:1.158.0.6 prg-localcount2-base:1.158 pgoyette-localcount-20170426:1.158 bouyer-socketcan-base1:1.158 jdolecek-ncq:1.158.0.4 jdolecek-ncq-base:1.158 pgoyette-localcount-20170320:1.158 netbsd-7-1:1.146.0.10 netbsd-7-1-RELEASE:1.146 netbsd-7-1-RC2:1.146 nick-nhusb-base-20170204:1.158 netbsd-7-nhusb-base-20170116:1.146 bouyer-socketcan:1.158.0.2 bouyer-socketcan-base:1.158 pgoyette-localcount-20170107:1.158 netbsd-7-1-RC1:1.146 nick-nhusb-base-20161204:1.158 pgoyette-localcount-20161104:1.158 netbsd-7-0-2-RELEASE:1.146 nick-nhusb-base-20161004:1.158 localcount-20160914:1.157 netbsd-7-nhusb:1.146.0.8 netbsd-7-nhusb-base:1.146 pgoyette-localcount-20160806:1.152 pgoyette-localcount-20160726:1.152 pgoyette-localcount:1.152.0.2 pgoyette-localcount-base:1.152 nick-nhusb-base-20160907:1.152 nick-nhusb-base-20160529:1.151 netbsd-7-0-1-RELEASE:1.146 nick-nhusb-base-20160422:1.150 nick-nhusb-base-20160319:1.149 nick-nhusb-base-20151226:1.149 netbsd-7-0:1.146.0.6 netbsd-7-0-RELEASE:1.146 nick-nhusb-base-20150921:1.149 netbsd-7-0-RC3:1.146 netbsd-7-0-RC2:1.146 netbsd-7-0-RC1:1.146 nick-nhusb-base-20150606:1.147 nick-nhusb-base-20150406:1.146 nick-nhusb:1.146.0.4 nick-nhusb-base:1.146 netbsd-5-2-3-RELEASE:1.123 netbsd-5-1-5-RELEASE:1.123 netbsd-6-0-6-RELEASE:1.136 netbsd-6-1-5-RELEASE:1.136.8.1 netbsd-7:1.146.0.2 netbsd-7-base:1.146 yamt-pagecache-base9:1.141 yamt-pagecache-tag8:1.136.2.2 netbsd-6-1-4-RELEASE:1.136.8.1 netbsd-6-0-5-RELEASE:1.136 tls-earlyentropy:1.141.0.2 tls-earlyentropy-base:1.146 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.141 riastradh-drm2-base3:1.141 netbsd-6-1-3-RELEASE:1.136.8.1 netbsd-6-0-4-RELEASE:1.136 netbsd-5-2-2-RELEASE:1.123 netbsd-5-1-4-RELEASE:1.123 netbsd-6-1-2-RELEASE:1.136.8.1 netbsd-6-0-3-RELEASE:1.136 netbsd-5-2-1-RELEASE:1.123 netbsd-5-1-3-RELEASE:1.123 rmind-smpnet-nbase:1.143 netbsd-6-1-1-RELEASE:1.136.8.1 riastradh-drm2-base2:1.138 riastradh-drm2-base1:1.138 riastradh-drm2:1.138.0.8 riastradh-drm2-base:1.138 rmind-smpnet:1.138.0.2 rmind-smpnet-base:1.143 netbsd-6-1:1.136.8.1.0.2 netbsd-6-0-2-RELEASE:1.136 netbsd-6-1-RELEASE:1.136.8.1 khorben-n900:1.138.0.6 netbsd-6-1-RC4:1.136.8.1 netbsd-6-1-RC3:1.136.8.1 agc-symver:1.138.0.4 agc-symver-base:1.138 netbsd-6-1-RC2:1.136.8.1 netbsd-6-1-RC1:1.136.8.1 yamt-pagecache-base8:1.138 netbsd-5-2:1.123.0.16 netbsd-6-0-1-RELEASE:1.136 yamt-pagecache-base7:1.138 netbsd-5-2-RELEASE:1.123 netbsd-5-2-RC1:1.123 matt-nb6-plus-nbase:1.136 yamt-pagecache-base6:1.137 netbsd-6-0:1.136.0.14 netbsd-6-0-RELEASE:1.136 netbsd-6-0-RC2:1.136 tls-maxphys:1.136.0.12 tls-maxphys-base:1.146 matt-nb6-plus:1.136.0.10 matt-nb6-plus-base:1.136 netbsd-6-0-RC1:1.136 jmcneill-usbmp-base10:1.136 yamt-pagecache-base5:1.136 jmcneill-usbmp-base9:1.136 yamt-pagecache-base4:1.136 jmcneill-usbmp-base8:1.136 jmcneill-usbmp-base7:1.136 jmcneill-usbmp-base6:1.136 jmcneill-usbmp-base5:1.136 jmcneill-usbmp-base4:1.136 jmcneill-usbmp-base3:1.136 jmcneill-usbmp-pre-base2:1.136 jmcneill-usbmp-base2:1.136 netbsd-6:1.136.0.8 netbsd-6-base:1.136 netbsd-5-1-2-RELEASE:1.123 netbsd-5-1-1-RELEASE:1.123 jmcneill-usbmp:1.136.0.6 jmcneill-usbmp-base:1.136 jmcneill-audiomp3:1.136.0.4 jmcneill-audiomp3-base:1.136 yamt-pagecache-base3:1.136 yamt-pagecache-base2:1.136 yamt-pagecache:1.136.0.2 yamt-pagecache-base:1.136 rmind-uvmplock-nbase:1.133 cherry-xenmp:1.133.0.2 cherry-xenmp-base:1.133 bouyer-quota2-nbase:1.132 bouyer-quota2:1.132.0.4 bouyer-quota2-base:1.132 jruoho-x86intr:1.132.0.2 jruoho-x86intr-base:1.132 matt-mips64-premerge-20101231:1.132 matt-nb5-mips64-premerge-20101231:1.123 matt-nb5-pq3:1.123.0.14 matt-nb5-pq3-base:1.123 netbsd-5-1:1.123.0.12 netbsd-5-1-RELEASE:1.123 uebayasi-xip-base4:1.132 uebayasi-xip-base3:1.132 yamt-nfs-mp-base11:1.132 netbsd-5-1-RC4:1.123 matt-nb5-mips64-k15:1.123 uebayasi-xip-base2:1.131 yamt-nfs-mp-base10:1.131 netbsd-5-1-RC3:1.123 netbsd-5-1-RC2:1.123 uebayasi-xip-base1:1.131 netbsd-5-1-RC1:1.123 rmind-uvmplock:1.130.0.4 rmind-uvmplock-base:1.133 yamt-nfs-mp-base9:1.130 uebayasi-xip:1.130.0.2 uebayasi-xip-base:1.130 netbsd-5-0-2-RELEASE:1.123 matt-nb5-mips64-premerge-20091211:1.123 matt-premerge-20091211:1.129 yamt-nfs-mp-base8:1.129 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.123 matt-nb4-mips64-k7-u2a-k9b:1.123 matt-nb5-mips64-u1-k1-k5:1.123 yamt-nfs-mp-base7:1.129 matt-nb5-mips64:1.123.0.10 netbsd-5-0-1-RELEASE:1.123 jymxensuspend-base:1.129 yamt-nfs-mp-base6:1.129 yamt-nfs-mp-base5:1.129 yamt-nfs-mp-base4:1.129 jym-xensuspend-nbase:1.129 yamt-nfs-mp-base3:1.129 nick-hppapmap-base4:1.129 nick-hppapmap-base3:1.129 netbsd-5-0:1.123.0.8 netbsd-5-0-RELEASE:1.123 netbsd-5-0-RC4:1.123 netbsd-5-0-RC3:1.123 nick-hppapmap-base2:1.128 netbsd-5-0-RC2:1.123 jym-xensuspend:1.128.0.2 jym-xensuspend-base:1.129 netbsd-5-0-RC1:1.123 haad-dm-base2:1.126 haad-nbase2:1.126 ad-audiomp2:1.126.0.2 ad-audiomp2-base:1.126 netbsd-5:1.123.0.6 netbsd-5-base:1.123 nick-hppapmap:1.123.0.4 nick-hppapmap-base:1.129 matt-mips64-base2:1.123 matt-mips64:1.116.0.10 haad-dm-base1:1.123 wrstuden-revivesa-base-4:1.123 netbsd-4-0-1-RELEASE:1.111 wrstuden-revivesa-base-3:1.123 wrstuden-revivesa-base-2:1.123 wrstuden-fixsa-newbase:1.111 nick-csl-alignment-base5:1.117 haad-dm:1.123.0.2 haad-dm-base:1.126 wrstuden-revivesa-base-1:1.123 simonb-wapbl-nbase:1.123 yamt-pf42-base4:1.123 simonb-wapbl:1.122.0.6 simonb-wapbl-base:1.123 yamt-pf42-base3:1.122 hpcarm-cleanup-nbase:1.122 yamt-pf42-baseX:1.121 yamt-pf42-base2:1.122 yamt-nfs-mp-base2:1.122 wrstuden-revivesa:1.122.0.4 wrstuden-revivesa-base:1.123 yamt-nfs-mp:1.122.0.2 yamt-nfs-mp-base:1.122 yamt-pf42:1.121.0.8 yamt-pf42-base:1.121 ad-socklock-base1:1.121 yamt-lazymbuf-base15:1.121 yamt-lazymbuf-base14:1.121 keiichi-mipv6-nbase:1.121 mjf-devfs2:1.121.0.6 mjf-devfs2-base:1.127 nick-net80211-sync:1.121.0.4 nick-net80211-sync-base:1.121 keiichi-mipv6:1.121.0.2 keiichi-mipv6-base:1.121 bouyer-xeni386-merge1:1.119.8.1 matt-armv6-prevmlocking:1.116.8.1 wrstuden-fixsa-base-1:1.111 vmlocking2-base3:1.119 netbsd-4-0:1.111.0.10 netbsd-4-0-RELEASE:1.111 bouyer-xeni386-nbase:1.120 yamt-kmem-base3:1.119 cube-autoconf:1.119.0.10 cube-autoconf-base:1.119 yamt-kmem-base2:1.119 bouyer-xeni386:1.119.0.8 bouyer-xeni386-base:1.120 yamt-kmem:1.119.0.6 yamt-kmem-base:1.119 vmlocking2-base2:1.119 reinoud-bufcleanup-nbase:1.119 vmlocking2:1.119.0.4 vmlocking2-base1:1.119 netbsd-4-0-RC5:1.111 matt-nb4-arm:1.111.0.8 matt-nb4-arm-base:1.111 matt-armv6-nbase:1.121 jmcneill-base:1.119 netbsd-4-0-RC4:1.111 mjf-devfs:1.119.0.2 mjf-devfs-base:1.121 bouyer-xenamd64-base2:1.119 vmlocking-nbase:1.119 yamt-x86pmap-base4:1.118 bouyer-xenamd64:1.118.0.2 bouyer-xenamd64-base:1.119 netbsd-4-0-RC3:1.111 yamt-x86pmap-base3:1.118 yamt-x86pmap-base2:1.117 netbsd-4-0-RC2:1.111 yamt-x86pmap:1.117.0.2 yamt-x86pmap-base:1.117 netbsd-4-0-RC1:1.111 matt-armv6:1.116.0.8 matt-armv6-base:1.120 matt-mips64-base:1.116 jmcneill-pm:1.116.0.6 jmcneill-pm-base:1.119 hpcarm-cleanup:1.116.0.4 hpcarm-cleanup-base:1.121 nick-csl-alignment:1.116.0.2 nick-csl-alignment-base:1.116 netbsd-3-1-1-RELEASE:1.96 netbsd-3-0-3-RELEASE:1.96 yamt-idlelwp-base8:1.114 wrstuden-fixsa:1.111.0.6 wrstuden-fixsa-base:1.111 thorpej-atomic:1.114.0.8 thorpej-atomic-base:1.114 reinoud-bufcleanup:1.114.0.6 reinoud-bufcleanup-base:1.119 mjf-ufs-trans:1.114.0.4 mjf-ufs-trans-base:1.115 vmlocking:1.114.0.2 vmlocking-base:1.118 ad-audiomp:1.112.0.2 ad-audiomp-base:1.112 yamt-idlelwp:1.111.0.4 post-newlock2-merge:1.111 newlock2-nbase:1.111 yamt-splraiseipl-base5:1.111 yamt-splraiseipl-base4:1.111 yamt-splraiseipl-base3:1.111 abandoned-netbsd-4-base:1.108 abandoned-netbsd-4:1.108.0.2 netbsd-3-1:1.96.0.6 netbsd-3-1-RELEASE:1.96 netbsd-3-0-2-RELEASE:1.96 yamt-splraiseipl-base2:1.109 netbsd-3-1-RC4:1.96 yamt-splraiseipl:1.108.0.6 yamt-splraiseipl-base:1.108 netbsd-3-1-RC3:1.96 yamt-pdpolicy-base9:1.108 newlock2:1.108.0.4 newlock2-base:1.111 yamt-pdpolicy-base8:1.108 netbsd-3-1-RC2:1.96 netbsd-3-1-RC1:1.96 yamt-pdpolicy-base7:1.108 netbsd-4:1.111.0.2 netbsd-4-base:1.111 yamt-pdpolicy-base6:1.107 chap-midi-nbase:1.107 netbsd-3-0-1-RELEASE:1.96 gdamore-uart:1.107.0.2 gdamore-uart-base:1.107 simonb-timcounters-final:1.105.4.2 yamt-pdpolicy-base5:1.106 chap-midi:1.106.0.2 chap-midi-base:1.107 yamt-pdpolicy-base4:1.105 yamt-pdpolicy-base3:1.105 peter-altq-base:1.105 peter-altq:1.105.0.10 yamt-pdpolicy-base2:1.105 elad-kernelauth-base:1.105 elad-kernelauth:1.105.0.8 yamt-pdpolicy:1.105.0.6 yamt-pdpolicy-base:1.105 yamt-uio_vmspace-base5:1.105 simonb-timecounters:1.105.0.4 simonb-timecounters-base:1.106 rpaulo-netinet-merge-pcb:1.105.0.2 rpaulo-netinet-merge-pcb-base:1.108 yamt-uio_vmspace:1.104.0.2 netbsd-3-0:1.96.0.4 netbsd-3-0-RELEASE:1.96 netbsd-3-0-RC6:1.96 yamt-readahead-base3:1.102 netbsd-3-0-RC5:1.96 netbsd-3-0-RC4:1.96 netbsd-3-0-RC3:1.96 yamt-readahead-base2:1.101 netbsd-3-0-RC2:1.96 yamt-readahead-pervnode:1.101 yamt-readahead-perfile:1.101 yamt-readahead:1.101.0.8 yamt-readahead-base:1.101 netbsd-3-0-RC1:1.96 yamt-vop-base3:1.101 netbsd-2-0-3-RELEASE:1.88 netbsd-2-1:1.88.0.6 yamt-vop-base2:1.101 thorpej-vnode-attr:1.101.0.6 thorpej-vnode-attr-base:1.101 netbsd-2-1-RELEASE:1.88 yamt-vop:1.101.0.4 yamt-vop-base:1.101 netbsd-2-1-RC6:1.88 netbsd-2-1-RC5:1.88 netbsd-2-1-RC4:1.88 netbsd-2-1-RC3:1.88 netbsd-2-1-RC2:1.88 netbsd-2-1-RC1:1.88 yamt-lazymbuf:1.101.0.2 yamt-km-base4:1.96 netbsd-2-0-2-RELEASE:1.88 yamt-km-base3:1.96 netbsd-3:1.96.0.2 netbsd-3-base:1.96 yamt-km-base2:1.95 yamt-km:1.95.0.6 yamt-km-base:1.95 kent-audio2:1.95.0.4 kent-audio2-base:1.99 netbsd-2-0-1-RELEASE:1.88 kent-audio1-beforemerge:1.95 netbsd-2:1.88.0.4 netbsd-2-base:1.88 kent-audio1:1.95.0.2 kent-audio1-base:1.95 netbsd-2-0-RELEASE:1.88 netbsd-2-0-RC5:1.88 netbsd-2-0-RC4:1.88 netbsd-2-0-RC3:1.88 netbsd-2-0-RC2:1.88 netbsd-2-0-RC1:1.88 netbsd-2-0:1.88.0.2 netbsd-2-0-base:1.88 netbsd-1-6-PATCH002-RELEASE:1.77 netbsd-1-6-PATCH002:1.77 netbsd-1-6-PATCH002-RC4:1.77 netbsd-1-6-PATCH002-RC3:1.77 netbsd-1-6-PATCH002-RC2:1.77 netbsd-1-6-PATCH002-RC1:1.77 ktrace-lwp:1.84.0.2 ktrace-lwp-base:1.102 netbsd-1-6-PATCH001:1.77 netbsd-1-6-PATCH001-RELEASE:1.77 netbsd-1-6-PATCH001-RC3:1.77 netbsd-1-6-PATCH001-RC2:1.77 netbsd-1-6-PATCH001-RC1:1.77 nathanw_sa_end:1.67.2.10 nathanw_sa_before_merge:1.81 fvdl_fs64_base:1.81 gmcgarry_ctxsw:1.81.0.4 gmcgarry_ctxsw_base:1.81 gmcgarry_ucred:1.81.0.2 gmcgarry_ucred_base:1.81 nathanw_sa_base:1.81 kqueue-aftermerge:1.81 kqueue-beforemerge:1.81 netbsd-1-6-RELEASE:1.77 netbsd-1-6-RC3:1.77 netbsd-1-6-RC2:1.77 netbsd-1-6-RC1:1.77 netbsd-1-6:1.77.0.4 netbsd-1-6-base:1.77 gehenna-devsw:1.77.0.2 gehenna-devsw-base:1.78 netbsd-1-5-PATCH003:1.58.4.1 eeh-devprop:1.76.0.2 eeh-devprop-base:1.76 newlock:1.75.0.2 newlock-base:1.75 ifpoll-base:1.74 thorpej-mips-cache:1.71.0.4 thorpej-mips-cache-base:1.71 thorpej-devvp-base3:1.71 thorpej-devvp-base2:1.71 post-chs-ubcperf:1.71 pre-chs-ubcperf:1.71 thorpej-devvp:1.71.0.2 thorpej-devvp-base:1.71 netbsd-1-5-PATCH002:1.58.4.1 kqueue:1.69.0.2 kqueue-base:1.81 netbsd-1-5-PATCH001:1.58 thorpej_scsipi_beforemerge:1.68 nathanw_sa:1.67.0.2 thorpej_scsipi_nbase:1.68 netbsd-1-5-RELEASE:1.58 netbsd-1-5-BETA2:1.58 netbsd-1-5-BETA:1.58 netbsd-1-4-PATCH003:1.50 netbsd-1-5-ALPHA2:1.58 netbsd-1-5:1.58.0.4 netbsd-1-5-base:1.58 minoura-xpg4dl-base:1.58 minoura-xpg4dl:1.58.0.2 netbsd-1-4-PATCH002:1.50 chs-ubc2-newbase:1.56 wrstuden-devbsize-19991221:1.56 wrstuden-devbsize:1.55.0.8 wrstuden-devbsize-base:1.56 kame_141_19991130:1.50.6.2 comdex-fall-1999:1.55.0.6 comdex-fall-1999-base:1.55 fvdl-softdep:1.55.0.4 fvdl-softdep-base:1.55 thorpej_scsipi:1.55.0.2 thorpej_scsipi_base:1.68 netbsd-1-4-PATCH001:1.50 kame_14_19990705:1.50.6.1 kame_14_19990628:1.50.6.1 kame:1.50.0.6 chs-ubc2:1.50.0.4 chs-ubc2-base:1.55 netbsd-1-4-RELEASE:1.50 netbsd-1-4:1.50.0.2 netbsd-1-4-base:1.50 netbsd-1-3-PATCH003:1.40 netbsd-1-3-PATCH003-CANDIDATE2:1.40 kenh-if-detach:1.47.0.4 kenh-if-detach-base:1.47 netbsd-1-3-PATCH003-CANDIDATE1:1.40 netbsd-1-3-PATCH003-CANDIDATE0:1.40 chs-ubc:1.47.0.2 chs-ubc-base:1.47 eeh-paddr_t:1.45.0.2 eeh-paddr_t-base:1.45 netbsd-1-3-PATCH002:1.40 netbsd-1-3-PATCH001:1.40 netbsd-1-3-RELEASE:1.40 netbsd-1-3-BETA:1.40 netbsd-1-3:1.40.0.8 netbsd-1-3-base:1.40 thorpej-signal:1.40.0.6 thorpej-signal-base:1.40 marc-pcmcia:1.40.0.4 marc-pcmcia-bp:1.40 marc-pcmcia-base:1.40 bouyer-scsipi:1.40.0.2 is-newarp-before-merge:1.37 netbsd-1-2-PATCH001:1.31.4.1 mrg-vm-swap:1.35.0.6 is-newarp:1.35.0.4 is-newarp-base:1.35 thorpej-setroot:1.35.0.2 netbsd-1-2-RELEASE:1.31 netbsd-1-2-BETA:1.31 netbsd-1-2:1.31.0.4 netbsd-1-2-base:1.31 date-03-may-96:1.1.1.1 netbsd:1.1.1 netbsd-1-1-PATCH001:1.24 netbsd-1-1-RELEASE:1.24 netbsd-1-1:1.24.0.2 netbsd-1-1-base:1.24 netbsd-1-0-PATCH06:1.15.2.2 netbsd-1-0-PATCH05:1.15.2.2 netbsd-1-0-PATCH04:1.15.2.2 netbsd-1-0-PATCH03:1.15.2.2 netbsd-1-0-PATCH02:1.15.2.2 netbsd-1-0-PATCH1:1.15.2.2 netbsd-1-0-PATCH0:1.15.2.2 netbsd-1-0-RELEASE:1.15.2.2 netbsd-1-0:1.15.0.2 netbsd-1-0-base:1.15 magnum-base:1.3 magnum:1.3.0.2; locks; strict; comment @ * @; 1.172 date 2022.09.03.02.47.59; author thorpej; state Exp; branches 1.172.8.1; next 1.171; commitid tQS7Hn7Gj3DaymSD; 1.171 date 2022.08.27.19.15.00; author thorpej; state Exp; branches; next 1.170; commitid wAVGe5rkhA7FeyRD; 1.170 date 2022.08.27.19.04.43; author thorpej; state Exp; branches; next 1.169; commitid 8Nv5bpsdKDCabyRD; 1.169 date 2022.07.06.08.07.23; author riastradh; state Exp; branches; next 1.168; commitid yiCDESc0McjmdOKD; 1.168 date 2022.07.06.08.06.59; author riastradh; state Exp; branches; next 1.167; commitid ZAtBVrRKtPBddOKD; 1.167 date 2020.01.29.04.28.27; author thorpej; state Exp; branches; next 1.166; commitid 5uH8WW48hxhUzxUB; 1.166 date 2019.09.20.08.45.29; author maxv; state Exp; branches 1.166.2.1; next 1.165; commitid tp0iPnONVg6cdJDB; 1.165 date 2019.06.25.12.30.50; author msaitoh; state Exp; branches; next 1.164; commitid cDwxCvaY3YhQfzsB; 1.164 date 2019.01.25.08.51.29; author knakahara; state Exp; branches; next 1.163; commitid tKkqjrTn9xESS89B; 1.163 date 2019.01.11.02.57.21; author knakahara; state Exp; branches; next 1.162; commitid 0nY4mqwK2UAXnj7B; 1.162 date 2019.01.11.02.55.41; author knakahara; state Exp; branches; next 1.161; commitid fCSeCY63t6Olnj7B; 1.161 date 2018.06.26.06.48.02; author msaitoh; state Exp; branches 1.161.2.1; next 1.160; commitid BGd0EgCdw1Br3LHA; 1.160 date 2018.06.25.04.59.42; author msaitoh; state Exp; branches; next 1.159; commitid IkTNs7QW0J5ouCHA; 1.159 date 2017.09.17.20.39.04; author christos; state Exp; branches 1.159.2.1; next 1.158; commitid 6jSdnsPhLjhLIA7A; 1.158 date 2016.10.02.14.17.07; author christos; state Exp; branches 1.158.8.1; next 1.157; 1.157 date 2016.08.07.17.38.34; author christos; state Exp; branches; next 1.156; 1.156 date 2016.08.06.22.54.34; author pgoyette; state Exp; branches; next 1.155; 1.155 date 2016.08.06.12.48.23; author christos; state Exp; branches; next 1.154; 1.154 date 2016.08.06.12.42.40; author pgoyette; state Exp; branches; next 1.153; 1.153 date 2016.08.06.02.35.06; author pgoyette; state Exp; branches; next 1.152; 1.152 date 2016.06.10.13.27.16; author ozaki-r; state Exp; branches 1.152.2.1; next 1.151; 1.151 date 2016.04.28.00.16.56; author ozaki-r; state Exp; branches; next 1.150; 1.150 date 2016.04.20.09.01.04; author knakahara; state Exp; branches; next 1.149; 1.149 date 2015.08.24.22.21.26; author pooka; state Exp; branches; next 1.148; 1.148 date 2015.08.20.11.18.53; author uebayasi; state Exp; branches; next 1.147; 1.147 date 2015.04.20.10.19.54; author roy; state Exp; branches; next 1.146; 1.146 date 2014.07.01.15.03.58; author msaitoh; state Exp; branches 1.146.4.1; next 1.145; 1.145 date 2014.06.30.12.56.51; author ozaki-r; state Exp; branches; next 1.144; 1.144 date 2014.06.05.23.48.16; author rmind; state Exp; branches; next 1.143; 1.143 date 2014.05.17.14.51.09; author rmind; state Exp; branches; next 1.142; 1.142 date 2014.05.15.09.23.03; author msaitoh; state Exp; branches; next 1.141; 1.141 date 2013.09.18.23.34.55; author rmind; state Exp; branches 1.141.2.1; next 1.140; 1.140 date 2013.08.30.15.00.08; author rmind; state Exp; branches; next 1.139; 1.139 date 2013.08.29.14.25.41; author rmind; state Exp; branches; next 1.138; 1.138 date 2012.11.25.09.06.43; author mbalmer; state Exp; branches 1.138.2.1; next 1.137; 1.137 date 2012.10.11.20.05.50; author christos; state Exp; branches; next 1.136; 1.136 date 2011.10.28.22.08.14; author dyoung; state Exp; branches 1.136.2.1 1.136.8.1 1.136.12.1; next 1.135; 1.135 date 2011.10.28.20.13.32; author dyoung; state Exp; branches; next 1.134; 1.134 date 2011.08.07.13.51.37; author rmind; state Exp; branches; next 1.133; 1.133 date 2011.04.02.08.11.32; author mbalmer; state Exp; branches; next 1.132; 1.132 date 2010.08.21.13.19.40; author pgoyette; state Exp; branches 1.132.2.1; next 1.131; 1.131 date 2010.04.05.07.22.23; author joerg; state Exp; branches; next 1.130; 1.130 date 2010.01.19.22.08.01; author pooka; state Exp; branches 1.130.2.1 1.130.4.1; next 1.129; 1.129 date 2009.04.15.20.44.25; author elad; state Exp; branches; next 1.128; 1.128 date 2009.01.19.15.16.34; author yamt; state Exp; branches 1.128.2.1; next 1.127; 1.127 date 2008.12.17.20.51.36; author cegger; state Exp; branches; next 1.126; 1.126 date 2008.11.29.23.15.20; author cube; state Exp; branches; next 1.125; 1.125 date 2008.11.25.02.40.36; author cube; state Exp; branches; next 1.124; 1.124 date 2008.11.07.00.20.13; author dyoung; state Exp; branches; next 1.123; 1.123 date 2008.06.15.16.37.21; author christos; state Exp; branches 1.123.2.1 1.123.4.1; next 1.122; 1.122 date 2008.04.24.11.38.37; author ad; state Exp; branches 1.122.2.1 1.122.4.1 1.122.6.1; next 1.121; 1.121 date 2008.02.07.01.22.01; author dyoung; state Exp; branches 1.121.6.1 1.121.8.1; next 1.120; 1.120 date 2008.01.04.21.18.15; author ad; state Exp; branches; next 1.119; 1.119 date 2007.10.19.12.16.44; author ad; state Exp; branches 1.119.2.1 1.119.8.1; next 1.118; 1.118 date 2007.10.08.16.18.05; author ad; state Exp; branches 1.118.2.1; next 1.117; 1.117 date 2007.09.01.04.32.50; author dyoung; state Exp; branches 1.117.2.1; next 1.116; 1.116 date 2007.07.14.21.02.40; author ad; state Exp; branches 1.116.2.1 1.116.6.1 1.116.8.1; next 1.115; 1.115 date 2007.07.09.21.11.00; author ad; state Exp; branches; next 1.114; 1.114 date 2007.03.07.22.20.05; author liamjfoy; state Exp; branches 1.114.2.1 1.114.4.1; next 1.113; 1.113 date 2007.03.04.06.03.16; author christos; state Exp; branches; next 1.112; 1.112 date 2007.02.17.22.34.08; author dyoung; state Exp; branches; next 1.111; 1.111 date 2006.11.16.01.33.40; author christos; state Exp; branches 1.111.4.1; next 1.110; 1.110 date 2006.10.25.20.28.45; author elad; state Exp; branches; next 1.109; 1.109 date 2006.10.12.01.32.28; author christos; state Exp; branches; next 1.108; 1.108 date 2006.07.23.22.06.12; author ad; state Exp; branches 1.108.4.1 1.108.6.1; next 1.107; 1.107 date 2006.06.07.22.33.42; author kardel; state Exp; branches; next 1.106; 1.106 date 2006.05.14.21.19.33; author elad; state Exp; branches 1.106.2.1; next 1.105; 1.105 date 2006.01.02.01.42.36; author yamt; state Exp; branches 1.105.2.1 1.105.4.1 1.105.6.1 1.105.8.1 1.105.10.1; next 1.104; 1.104 date 2005.12.28.08.13.24; author christos; state Exp; branches 1.104.2.1; next 1.103; 1.103 date 2005.12.11.23.05.25; author thorpej; state Exp; branches; next 1.102; 1.102 date 2005.11.27.05.35.52; author thorpej; state Exp; branches; next 1.101; 1.101 date 2005.05.29.21.22.52; author christos; state Exp; branches 1.101.2.1 1.101.8.1; next 1.100; 1.100 date 2005.05.17.04.14.58; author christos; state Exp; branches; next 1.99; 1.99 date 2005.03.31.21.19.35; author christos; state Exp; branches; next 1.98; 1.98 date 2005.03.31.17.07.39; author explorer; state Exp; branches; next 1.97; 1.97 date 2005.03.31.15.48.13; author christos; state Exp; branches; next 1.96; 1.96 date 2005.02.26.22.45.09; author perry; state Exp; branches; next 1.95; 1.95 date 2004.12.05.15.03.13; author christos; state Exp; branches 1.95.4.1 1.95.6.1; next 1.94; 1.94 date 2004.12.05.15.00.47; author peter; state Exp; branches; next 1.93; 1.93 date 2004.12.05.13.32.03; author he; state Exp; branches; next 1.92; 1.92 date 2004.12.05.05.42.19; author christos; state Exp; branches; next 1.91; 1.91 date 2004.12.05.04.15.16; author christos; state Exp; branches; next 1.90; 1.90 date 2004.07.03.18.11.33; author dyoung; state Exp; branches; next 1.89; 1.89 date 2004.04.21.18.40.39; author itojun; state Exp; branches; next 1.88; 1.88 date 2003.10.28.20.16.28; author mycroft; state Exp; branches; next 1.87; 1.87 date 2003.10.28.20.15.19; author mycroft; state Exp; branches; next 1.86; 1.86 date 2003.10.25.18.29.12; author christos; state Exp; branches; next 1.85; 1.85 date 2003.09.01.16.51.25; author christos; state Exp; branches; next 1.84; 1.84 date 2003.05.02.03.15.24; author itojun; state Exp; branches 1.84.2.1; next 1.83; 1.83 date 2003.03.27.17.50.28; author christos; state Exp; branches; next 1.82; 1.82 date 2003.01.19.23.44.03; author simonb; state Exp; branches; next 1.81; 1.81 date 2002.10.02.02.27.54; author itojun; state Exp; branches; next 1.80; 1.80 date 2002.09.25.23.24.37; author augustss; state Exp; branches; next 1.79; 1.79 date 2002.09.25.16.10.15; author darrenr; state Exp; branches; next 1.78; 1.78 date 2002.07.01.22.09.31; author itojun; state Exp; branches; next 1.77; 1.77 date 2002.05.12.20.38.15; author matt; state Exp; branches 1.77.2.1; next 1.76; 1.76 date 2002.03.17.19.41.10; author atatat; state Exp; branches; next 1.75; 1.75 date 2002.03.05.04.13.01; author itojun; state Exp; branches; next 1.74; 1.74 date 2002.01.14.18.19.15; author kleink; state Exp; branches; next 1.73; 1.73 date 2001.11.13.00.49.35; author lukem; state Exp; branches; next 1.72; 1.72 date 2001.11.12.23.49.41; author lukem; state Exp; branches; next 1.71; 1.71 date 2001.08.05.18.07.55; author jdolecek; state Exp; branches; next 1.70; 1.70 date 2001.07.18.16.43.09; author thorpej; state Exp; branches; next 1.69; 1.69 date 2001.06.14.05.44.24; author itojun; state Exp; branches 1.69.2.1; next 1.68; 1.68 date 2001.04.13.23.30.14; author thorpej; state Exp; branches; next 1.67; 1.67 date 2001.01.17.00.30.51; author thorpej; state Exp; branches 1.67.2.1; next 1.66; 1.66 date 2001.01.15.16.33.30; author thorpej; state Exp; branches; next 1.65; 1.65 date 2000.12.18.19.50.44; author thorpej; state Exp; branches; next 1.64; 1.64 date 2000.12.18.18.57.21; author thorpej; state Exp; branches; next 1.63; 1.63 date 2000.12.12.18.00.27; author thorpej; state Exp; branches; next 1.62; 1.62 date 2000.10.26.01.26.15; author wiz; state Exp; branches; next 1.61; 1.61 date 2000.10.06.04.49.53; author onoe; state Exp; branches; next 1.60; 1.60 date 2000.10.04.02.51.18; author itojun; state Exp; branches; next 1.59; 1.59 date 2000.10.02.03.54.10; author itojun; state Exp; branches; next 1.58; 1.58 date 2000.03.30.09.45.36; author augustss; state Exp; branches 1.58.4.1; next 1.57; 1.57 date 2000.03.23.07.03.25; author thorpej; state Exp; branches; next 1.56; 1.56 date 99.11.27.18.45.08; author hannken; state Exp; branches; next 1.55; 1.55 date 99.07.30.10.35.38; author itojun; state Exp; branches 1.55.2.1 1.55.8.1; next 1.54; 1.54 date 99.07.01.08.12.48; author itojun; state Exp; branches; next 1.53; 1.53 date 99.05.14.21.33.41; author tron; state Exp; branches; next 1.52; 1.52 date 99.05.12.18.50.51; author thorpej; state Exp; branches; next 1.51; 1.51 date 99.05.11.02.18.52; author thorpej; state Exp; branches; next 1.50; 1.50 date 99.01.09.21.47.09; author thorpej; state Exp; branches 1.50.4.1 1.50.6.1; next 1.49; 1.49 date 98.12.10.17.48.40; author christos; state Exp; branches; next 1.48; 1.48 date 98.12.10.11.01.01; author christos; state Exp; branches; next 1.47; 1.47 date 98.09.03.14.12.36; author christos; state Exp; branches 1.47.4.1; next 1.46; 1.46 date 98.08.02.15.09.50; author sommerfe; state Exp; branches; next 1.45; 1.45 date 98.07.09.22.30.01; author thorpej; state Exp; branches; next 1.44; 1.44 date 98.07.08.18.05.48; author sommerfe; state Exp; branches; next 1.43; 1.43 date 98.07.06.13.51.32; author jtk; state Exp; branches; next 1.42; 1.42 date 98.07.05.00.51.26; author jonathan; state Exp; branches; next 1.41; 1.41 date 98.05.02.14.34.24; author christos; state Exp; branches; next 1.40; 1.40 date 97.06.16.17.01.36; author christos; state Exp; branches; next 1.39; 1.39 date 97.05.17.21.11.59; author christos; state Exp; branches; next 1.38; 1.38 date 97.04.16.12.54.42; author is; state Exp; branches; next 1.37; 1.37 date 97.03.12.20.26.50; author christos; state Exp; branches; next 1.36; 1.36 date 97.03.04.21.40.07; author mycroft; state Exp; branches; next 1.35; 1.35 date 96.10.13.02.11.03; author christos; state Exp; branches 1.35.4.1; next 1.34; 1.34 date 96.10.10.22.59.48; author christos; state Exp; branches; next 1.33; 1.33 date 96.06.13.21.50.32; author cgd; state Exp; branches; next 1.32; 1.32 date 96.05.22.13.55.10; author mycroft; state Exp; branches; next 1.31; 1.31 date 96.05.07.02.40.36; author thorpej; state Exp; branches 1.31.4.1; next 1.30; 1.30 date 96.03.19.01.00.49; author paulus; state Exp; branches; next 1.29; 1.29 date 96.03.15.02.28.03; author paulus; state Exp; branches; next 1.28; 1.28 date 96.02.13.22.00.18; author christos; state Exp; branches; next 1.27; 1.27 date 96.02.07.12.43.41; author pk; state Exp; branches; next 1.26; 1.26 date 96.02.07.10.25.58; author pk; state Exp; branches; next 1.25; 1.25 date 95.12.27.06.30.38; author mycroft; state Exp; branches; next 1.24; 1.24 date 95.10.05.05.55.09; author mycroft; state Exp; branches; next 1.23; 1.23 date 95.08.12.23.59.21; author mycroft; state Exp; branches; next 1.22; 1.22 date 95.07.04.06.28.20; author paulus; state Exp; branches; next 1.21; 1.21 date 95.03.08.02.56.58; author cgd; state Exp; branches; next 1.20; 1.20 date 94.10.30.21.48.52; author cgd; state Exp; branches; next 1.19; 1.19 date 94.07.27.09.05.33; author deraadt; state Exp; branches; next 1.18; 1.18 date 94.07.20.01.49.20; author paulus; state Exp; branches; next 1.17; 1.17 date 94.07.20.01.40.11; author paulus; state Exp; branches; next 1.16; 1.16 date 94.07.18.23.45.33; author paulus; state Exp; branches; next 1.15; 1.15 date 94.07.03.06.44.03; author deraadt; state Exp; branches 1.15.2.1; next 1.14; 1.14 date 94.06.29.06.36.16; author cgd; state Exp; branches; next 1.13; 1.13 date 94.06.20.00.35.39; author paulus; state Exp; branches; next 1.12; 1.12 date 94.06.14.03.09.23; author paulus; state Exp; branches; next 1.11; 1.11 date 94.05.29.23.44.23; author paulus; state Exp; branches; next 1.10; 1.10 date 94.05.24.02.33.56; author cgd; state Exp; branches; next 1.9; 1.9 date 94.05.13.06.02.48; author mycroft; state Exp; branches; next 1.8; 1.8 date 94.05.08.12.33.49; author paulus; state Exp; branches; next 1.7; 1.7 date 94.01.25.05.56.06; author deraadt; state Exp; branches; next 1.6; 1.6 date 93.12.23.07.36.06; author cgd; state Exp; branches; next 1.5; 1.5 date 93.12.18.00.40.54; author mycroft; state Exp; branches; next 1.4; 1.4 date 93.11.04.03.45.23; author paulus; state Exp; branches; next 1.3; 1.3 date 93.09.02.12.10.59; author paulus; state Exp; branches 1.3.2.1; next 1.2; 1.2 date 93.08.31.00.05.27; author paulus; state Exp; branches; next 1.1; 1.1 date 93.08.14.06.38.37; author deraadt; state Exp; branches; next ; 1.172.8.1 date 2023.11.15.02.08.34; author thorpej; state Exp; branches; next 1.172.8.2; commitid a7TDys3OCitEfEME; 1.172.8.2 date 2023.11.16.04.30.22; author thorpej; state Exp; branches; next ; commitid jPOkwjTSslkk0NME; 1.166.2.1 date 2020.02.29.20.21.06; author ad; state Exp; branches; next ; commitid OjSb8ro7YQETQBYB; 1.161.2.1 date 2019.06.10.22.09.45; author christos; state Exp; branches; next 1.161.2.2; commitid jtc8rnCzWiEEHGqB; 1.161.2.2 date 2020.04.08.14.08.57; author martin; state Exp; branches; next 1.161.2.3; commitid Qli2aW9E74UFuA3C; 1.161.2.3 date 2020.04.13.08.05.15; author martin; state Exp; branches; next ; commitid X01YhRUPVUDaec4C; 1.159.2.1 date 2018.06.25.07.26.06; author pgoyette; state Exp; branches; next 1.159.2.2; commitid 8PtAu9af7VvhiDHA; 1.159.2.2 date 2018.07.28.04.38.10; author pgoyette; state Exp; branches; next 1.159.2.3; commitid 1UP1xAIUxv1ZgRLA; 1.159.2.3 date 2019.01.18.08.50.58; author pgoyette; state Exp; branches; next 1.159.2.4; commitid Lmlzg3OVT2cd6f8B; 1.159.2.4 date 2019.01.26.22.00.36; author pgoyette; state Exp; branches; next ; commitid JKpcmvSjdT25dl9B; 1.158.8.1 date 2018.07.26.23.55.31; author snj; state Exp; branches; next 1.158.8.2; commitid 4ZuNPH2dz2G9MHLA; 1.158.8.2 date 2019.01.11.15.55.01; author martin; state Exp; branches; next ; commitid WfZuTO9pgD6MGn7B; 1.152.2.1 date 2016.11.04.14.49.20; author pgoyette; state Exp; branches; next ; 1.146.4.1 date 2015.06.06.14.40.25; author skrll; state Exp; branches; next 1.146.4.2; 1.146.4.2 date 2015.09.22.12.06.10; author skrll; state Exp; branches; next 1.146.4.3; 1.146.4.3 date 2016.04.22.15.44.17; author skrll; state Exp; branches; next 1.146.4.4; 1.146.4.4 date 2016.05.29.08.44.38; author skrll; state Exp; branches; next 1.146.4.5; 1.146.4.5 date 2016.07.09.20.25.21; author skrll; state Exp; branches; next 1.146.4.6; 1.146.4.6 date 2016.10.05.20.56.08; author skrll; state Exp; branches; next ; 1.141.2.1 date 2014.08.10.06.56.15; author tls; state Exp; branches; next ; 1.138.2.1 date 2014.05.18.17.46.12; author rmind; state Exp; branches; next ; 1.136.2.1 date 2012.10.30.17.22.43; author yamt; state Exp; branches; next 1.136.2.2; 1.136.2.2 date 2013.01.16.05.33.48; author yamt; state Exp; branches; next 1.136.2.3; 1.136.2.3 date 2014.05.22.11.41.09; author yamt; state Exp; branches; next ; 1.136.8.1 date 2012.10.31.16.07.46; author riz; state Exp; branches; next ; 1.136.12.1 date 2012.11.20.03.02.47; author tls; state Exp; branches; next 1.136.12.2; 1.136.12.2 date 2013.02.25.00.30.01; author tls; state Exp; branches; next 1.136.12.3; 1.136.12.3 date 2014.08.20.00.04.34; author tls; state Exp; branches; next 1.136.12.4; 1.136.12.4 date 2017.12.03.11.39.02; author jdolecek; state Exp; branches; next ; commitid XcIYRZTAh1LmerhA; 1.132.2.1 date 2011.06.06.09.09.52; author jruoho; state Exp; branches; next ; 1.130.2.1 date 2010.04.30.14.44.19; author uebayasi; state Exp; branches; next 1.130.2.2; 1.130.2.2 date 2010.10.22.07.22.38; author uebayasi; state Exp; branches; next ; 1.130.4.1 date 2010.05.30.05.18.01; author rmind; state Exp; branches; next 1.130.4.2; 1.130.4.2 date 2011.03.05.20.55.51; author rmind; state Exp; branches; next 1.130.4.3; 1.130.4.3 date 2011.04.21.01.42.13; author rmind; state Exp; branches; next ; 1.128.2.1 date 2009.05.13.17.22.19; author jym; state Exp; branches; next ; 1.123.2.1 date 2008.12.13.01.15.25; author haad; state Exp; branches; next ; 1.123.4.1 date 2009.01.19.13.20.11; author skrll; state Exp; branches; next 1.123.4.2; 1.123.4.2 date 2009.03.03.18.33.38; author skrll; state Exp; branches; next 1.123.4.3; 1.123.4.3 date 2009.04.28.07.37.16; author skrll; state Exp; branches; next ; 1.122.2.1 date 2009.05.04.08.14.15; author yamt; state Exp; branches; next 1.122.2.2; 1.122.2.2 date 2010.03.11.15.04.27; author yamt; state Exp; branches; next 1.122.2.3; 1.122.2.3 date 2010.08.11.22.54.54; author yamt; state Exp; branches; next 1.122.2.4; 1.122.2.4 date 2010.10.09.03.32.36; author yamt; state Exp; branches; next ; 1.122.4.1 date 2008.06.23.04.31.58; author wrstuden; state Exp; branches; next ; 1.122.6.1 date 2008.06.18.16.33.50; author simonb; state Exp; branches; next ; 1.121.6.1 date 2008.06.02.13.24.22; author mjf; state Exp; branches; next 1.121.6.2; 1.121.6.2 date 2008.06.29.09.33.18; author mjf; state Exp; branches; next 1.121.6.3; 1.121.6.3 date 2009.01.17.13.29.31; author mjf; state Exp; branches; next ; 1.121.8.1 date 2008.05.18.12.35.27; author yamt; state Exp; branches; next 1.121.8.2; 1.121.8.2 date 2008.06.17.09.15.13; author yamt; state Exp; branches; next ; 1.119.2.1 date 2008.02.18.21.07.01; author mjf; state Exp; branches; next ; 1.119.8.1 date 2008.01.08.22.11.48; author bouyer; state Exp; branches; next ; 1.118.2.1 date 2007.10.25.22.40.07; author bouyer; state Exp; branches; next ; 1.117.2.1 date 2007.10.14.11.48.59; author yamt; state Exp; branches; next ; 1.116.2.1 date 2007.09.03.10.23.10; author skrll; state Exp; branches; next ; 1.116.6.1 date 2007.09.03.16.48.56; author jmcneill; state Exp; branches; next 1.116.6.2; 1.116.6.2 date 2007.10.26.15.49.02; author joerg; state Exp; branches; next ; 1.116.8.1 date 2007.11.06.23.33.32; author matt; state Exp; branches; next 1.116.8.2; 1.116.8.2 date 2008.01.09.01.57.12; author matt; state Exp; branches; next 1.116.8.3; 1.116.8.3 date 2008.03.23.02.05.05; author matt; state Exp; branches; next ; 1.114.2.1 date 2007.06.17.21.31.50; author ad; state Exp; branches; next 1.114.2.2; 1.114.2.2 date 2007.07.01.21.50.44; author ad; state Exp; branches; next 1.114.2.3; 1.114.2.3 date 2007.07.15.13.27.53; author ad; state Exp; branches; next 1.114.2.4; 1.114.2.4 date 2007.07.15.15.52.59; author ad; state Exp; branches; next 1.114.2.5; 1.114.2.5 date 2007.10.09.15.22.26; author ad; state Exp; branches; next 1.114.2.6; 1.114.2.6 date 2007.10.23.20.17.17; author ad; state Exp; branches; next ; 1.114.4.1 date 2007.07.11.20.10.58; author mjf; state Exp; branches; next ; 1.111.4.1 date 2007.02.27.16.54.43; author yamt; state Exp; branches; next 1.111.4.2; 1.111.4.2 date 2007.03.12.05.59.12; author rmind; state Exp; branches; next ; 1.108.4.1 date 2006.11.18.21.39.29; author ad; state Exp; branches; next ; 1.108.6.1 date 2006.10.22.06.07.24; author yamt; state Exp; branches; next 1.108.6.2; 1.108.6.2 date 2006.12.10.07.19.00; author yamt; state Exp; branches; next ; 1.106.2.1 date 2006.06.19.04.09.12; author chap; state Exp; branches; next ; 1.105.2.1 date 2006.09.09.02.58.06; author rpaulo; state Exp; branches; next ; 1.105.4.1 date 2006.02.04.14.18.52; author simonb; state Exp; branches; next 1.105.4.2; 1.105.4.2 date 2006.06.01.22.38.37; author kardel; state Exp; branches; next ; 1.105.6.1 date 2006.05.24.10.58.56; author yamt; state Exp; branches; next 1.105.6.2; 1.105.6.2 date 2006.06.26.12.53.39; author yamt; state Exp; branches; next 1.105.6.3; 1.105.6.3 date 2006.08.11.15.46.14; author yamt; state Exp; branches; next ; 1.105.8.1 date 2006.03.08.01.11.55; author elad; state Exp; branches; next 1.105.8.2; 1.105.8.2 date 2006.03.10.15.05.22; author elad; state Exp; branches; next 1.105.8.3; 1.105.8.3 date 2006.05.06.23.31.58; author christos; state Exp; branches; next ; 1.105.10.1 date 2006.05.24.15.50.44; author tron; state Exp; branches; next ; 1.104.2.1 date 2006.01.15.10.02.57; author yamt; state Exp; branches; next ; 1.101.2.1 date 2006.06.21.15.10.27; author yamt; state Exp; branches; next 1.101.2.2; 1.101.2.2 date 2006.12.30.20.50.20; author yamt; state Exp; branches; next 1.101.2.3; 1.101.2.3 date 2007.02.26.09.11.35; author yamt; state Exp; branches; next 1.101.2.4; 1.101.2.4 date 2007.09.03.14.42.09; author yamt; state Exp; branches; next 1.101.2.5; 1.101.2.5 date 2007.10.27.11.36.02; author yamt; state Exp; branches; next 1.101.2.6; 1.101.2.6 date 2008.01.21.09.47.05; author yamt; state Exp; branches; next 1.101.2.7; 1.101.2.7 date 2008.02.11.14.59.59; author yamt; state Exp; branches; next ; 1.101.8.1 date 2005.11.29.21.23.29; author yamt; state Exp; branches; next ; 1.95.4.1 date 2005.04.29.11.29.31; author kent; state Exp; branches; next ; 1.95.6.1 date 2005.03.19.08.36.31; author yamt; state Exp; branches; next ; 1.84.2.1 date 2004.08.03.10.54.15; author skrll; state Exp; branches; next 1.84.2.2; 1.84.2.2 date 2004.09.18.14.54.16; author skrll; state Exp; branches; next 1.84.2.3; 1.84.2.3 date 2004.09.21.13.36.38; author skrll; state Exp; branches; next 1.84.2.4; 1.84.2.4 date 2004.12.18.09.32.50; author skrll; state Exp; branches; next 1.84.2.5; 1.84.2.5 date 2005.03.04.16.52.58; author skrll; state Exp; branches; next 1.84.2.6; 1.84.2.6 date 2005.04.01.14.31.34; author skrll; state Exp; branches; next 1.84.2.7; 1.84.2.7 date 2005.11.10.14.10.32; author skrll; state Exp; branches; next 1.84.2.8; 1.84.2.8 date 2005.12.11.10.29.19; author christos; state Exp; branches; next ; 1.77.2.1 date 2002.07.15.10.36.48; author gehenna; state Exp; branches; next ; 1.69.2.1 date 2001.08.03.04.13.50; author lukem; state Exp; branches; next 1.69.2.2; 1.69.2.2 date 2001.08.25.06.16.57; author thorpej; state Exp; branches; next 1.69.2.3; 1.69.2.3 date 2002.01.10.20.02.08; author thorpej; state Exp; branches; next 1.69.2.4; 1.69.2.4 date 2002.02.11.20.10.28; author jdolecek; state Exp; branches; next 1.69.2.5; 1.69.2.5 date 2002.03.16.16.02.06; author jdolecek; state Exp; branches; next 1.69.2.6; 1.69.2.6 date 2002.06.23.17.50.25; author jdolecek; state Exp; branches; next 1.69.2.7; 1.69.2.7 date 2002.09.06.08.48.55; author jdolecek; state Exp; branches; next 1.69.2.8; 1.69.2.8 date 2002.10.10.18.43.45; author jdolecek; state Exp; branches; next ; 1.67.2.1 date 2001.03.05.22.49.54; author nathanw; state Exp; branches; next 1.67.2.2; 1.67.2.2 date 2001.06.21.20.08.09; author nathanw; state Exp; branches; next 1.67.2.3; 1.67.2.3 date 2001.08.24.00.12.12; author nathanw; state Exp; branches; next 1.67.2.4; 1.67.2.4 date 2001.11.14.19.17.23; author nathanw; state Exp; branches; next 1.67.2.5; 1.67.2.5 date 2002.02.28.04.15.00; author nathanw; state Exp; branches; next 1.67.2.6; 1.67.2.6 date 2002.04.01.07.48.21; author nathanw; state Exp; branches; next 1.67.2.7; 1.67.2.7 date 2002.06.20.03.48.15; author nathanw; state Exp; branches; next 1.67.2.8; 1.67.2.8 date 2002.06.24.22.11.32; author nathanw; state Exp; branches; next 1.67.2.9; 1.67.2.9 date 2002.07.12.01.40.29; author nathanw; state Exp; branches; next 1.67.2.10; 1.67.2.10 date 2002.08.01.02.46.39; author nathanw; state Exp; branches; next ; 1.58.4.1 date 2001.08.16.16.52.39; author tv; state Exp; branches; next ; 1.55.2.1 date 2000.11.20.18.10.04; author bouyer; state Exp; branches; next 1.55.2.2; 1.55.2.2 date 2000.11.22.16.05.54; author bouyer; state Exp; branches; next 1.55.2.3; 1.55.2.3 date 2000.12.13.15.50.31; author bouyer; state Exp; branches; next 1.55.2.4; 1.55.2.4 date 2001.01.05.17.36.51; author bouyer; state Exp; branches; next 1.55.2.5; 1.55.2.5 date 2001.01.18.09.23.51; author bouyer; state Exp; branches; next 1.55.2.6; 1.55.2.6 date 2001.04.21.17.46.40; author bouyer; state Exp; branches; next ; 1.55.8.1 date 99.12.27.18.36.10; author wrstuden; state Exp; branches; next ; 1.50.4.1 date 99.06.21.01.27.34; author thorpej; state Exp; branches; next 1.50.4.2; 1.50.4.2 date 99.07.01.23.45.20; author thorpej; state Exp; branches; next 1.50.4.3; 1.50.4.3 date 99.08.02.22.32.28; author thorpej; state Exp; branches; next ; 1.50.6.1 date 99.06.28.06.36.56; author itojun; state Exp; branches; next 1.50.6.2; 1.50.6.2 date 99.11.30.13.35.06; author itojun; state Exp; branches; next ; 1.47.4.1 date 98.12.11.04.53.05; author kenh; state Exp; branches; next ; 1.35.4.1 date 97.03.12.15.56.58; author is; state Exp; branches; next ; 1.31.4.1 date 96.12.11.03.43.51; author mycroft; state Exp; branches; next ; 1.15.2.1 date 94.07.20.02.56.01; author cgd; state Exp; branches; next 1.15.2.2; 1.15.2.2 date 94.07.28.05.17.58; author cgd; state Exp; branches; next ; 1.3.2.1 date 93.09.24.08.53.59; author mycroft; state Exp; branches; next 1.3.2.2; 1.3.2.2 date 93.10.16.10.49.27; author mycroft; state Exp; branches; next 1.3.2.3; 1.3.2.3 date 93.10.27.01.42.19; author mycroft; state Exp; branches; next 1.3.2.4; 1.3.2.4 date 93.11.14.20.19.58; author mycroft; state Exp; branches; next ; desc @@ 1.172 log @Garbage-collect the remaining vestiges of netisr. @ text @/* $NetBSD: if_ppp.c,v 1.171 2022/08/27 19:15:00 thorpej Exp $ */ /* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */ /* * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver. * * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "Carnegie Mellon University" must not be used to * endorse or promote products derived from this software without * prior written permission. For permission or any legal * details, please contact * Office of Technology Transfer * Carnegie Mellon University * 5000 Forbes Avenue * Pittsburgh, PA 15213-3890 * (412) 268-4387, fax: (412) 268-7395 * tech-transfer@@andrew.cmu.edu * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by Computing Services * at Carnegie Mellon University (http://www.cmu.edu/computing/)." * * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Based on: * @@(#)if_sl.c 7.6.1.2 (Berkeley) 2/15/89 * * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Serial Line interface * * Rick Adams * Center for Seismic Studies * 1300 N 17th Street, Suite 1450 * Arlington, Virginia 22209 * (703)276-7900 * rick@@seismo.ARPA * seismo!rick * * Pounded on heavily by Chris Torek (chris@@mimsy.umd.edu, umcp-cs!chris). * Converted to 4.3BSD Beta by Chris Torek. * Other changes made at Berkeley, based in part on code by Kirk Smith. * * Converted to 4.3BSD+ 386BSD by Brad Parker (brad@@cayman.com) * Added VJ tcp header compression; more unified ioctls * * Extensively modified by Paul Mackerras (paulus@@cs.anu.edu.au). * Cleaned up a lot of the mbuf-related code to fix bugs that * caused system crashes and packet corruption. Changed pppstart * so that it doesn't just give up with a collision if the whole * packet doesn't fit in the output ring buffer. * * Added priority queueing for interactive IP packets, following * the model of if_sl.c, plus hooks for bpf. * Paul Mackerras (paulus@@cs.anu.edu.au). */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ /* * XXX IMP ME HARDER * * This is an explanation of that comment. This code used to use * splimp() to block both network and tty interrupts. However, * that call is deprecated. So, we have replaced the uses of * splimp() with splhigh() in order to applomplish what it needs * to accomplish, and added that happy little comment. */ #include __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.171 2022/08/27 19:15:00 thorpej Exp $"); #ifdef _KERNEL_OPT #include "ppp.h" #include "opt_inet.h" #include "opt_gateway.h" #include "opt_ppp.h" #endif #ifdef INET #define VJC #endif #define PPP_COMPRESS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef INET #include #endif #include #include #ifdef VJC #include #endif #include #include #include #include #ifdef PPP_COMPRESS #define PACKETPTR struct mbuf * #include #endif #include "ioconf.h" static int pppsioctl(struct ifnet *, u_long, void *); static void ppp_requeue(struct ppp_softc *); static void ppp_ccp(struct ppp_softc *, struct mbuf *m, int rcvd); static void ppp_ccp_closed(struct ppp_softc *); static void ppp_inproc(struct ppp_softc *, struct mbuf *); static void pppdumpm(struct mbuf *m0); #ifdef ALTQ static void ppp_ifstart(struct ifnet *ifp); #endif static void pppintr(void *); extern struct linesw ppp_disc; /* * We define two link layer specific mbuf flags, to mark high-priority * packets for output, and received packets following lost/corrupted * packets. */ #define M_HIGHPRI M_LINK0 /* output packet for sc_fastq */ #define M_ERRMARK M_LINK1 /* rx packet following lost/corrupted pkt */ static int ppp_clone_create(struct if_clone *, int); static int ppp_clone_destroy(struct ifnet *); static struct ppp_softc *ppp_create(const char *, int); static struct { LIST_HEAD(ppp_sclist, ppp_softc) list; kmutex_t lock; } ppp_softcs __cacheline_aligned; struct if_clone ppp_cloner = IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy); #ifdef PPP_COMPRESS static LIST_HEAD(, compressor) ppp_compressors = { NULL }; static kmutex_t ppp_compressors_mtx; static int ppp_compressor_init(void); static int ppp_compressor_destroy(void); static struct compressor *ppp_get_compressor(uint8_t); static void ppp_compressor_rele(struct compressor *); #endif /* PPP_COMPRESS */ /* * Called from boot code to establish ppp interfaces. */ void pppattach(int n __unused) { /* * Nothing to do here, initialization is handled by the * module initialization code in pppinit() below). */ } static void pppinit(void) { /* Init the compressor sub-sub-system */ ppp_compressor_init(); if (ttyldisc_attach(&ppp_disc) != 0) panic("%s", __func__); mutex_init(&ppp_softcs.lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softcs.list); if_clone_attach(&ppp_cloner); } static int pppdetach(void) { int error = 0; if (!LIST_EMPTY(&ppp_softcs.list)) error = EBUSY; if (error == 0) error = ttyldisc_detach(&ppp_disc); if (error == 0) { mutex_destroy(&ppp_softcs.lock); if_clone_detach(&ppp_cloner); ppp_compressor_destroy(); } return error; } static struct ppp_softc * ppp_create(const char *name, int unit) { struct ppp_softc *sc, *sci, *scl = NULL; sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); mutex_enter(&ppp_softcs.lock); if (unit == -1) { int i = 0; LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) { scl = sci; if (i < sci->sc_unit) { unit = i; break; } else { #ifdef DIAGNOSTIC KASSERT(i == sci->sc_unit); #endif i++; } } if (unit == -1) unit = i; } else { LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) { scl = sci; if (unit < sci->sc_unit) break; else if (unit == sci->sc_unit) { free(sc, M_DEVBUF); mutex_exit(&ppp_softcs.lock); return NULL; } } } if (sci != NULL) LIST_INSERT_BEFORE(sci, sc, sc_iflist); else if (scl != NULL) LIST_INSERT_AFTER(scl, sc, sc_iflist); else LIST_INSERT_HEAD(&ppp_softcs.list, sc, sc_iflist); mutex_exit(&ppp_softcs.lock); if_initname(&sc->sc_if, name, sc->sc_unit = unit); callout_init(&sc->sc_timo_ch, 0); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; #ifdef ALTQ sc->sc_if.if_start = ppp_ifstart; #endif IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); IFQ_SET_MAXLEN(&sc->sc_inq, IFQ_MAXLEN); IFQ_SET_MAXLEN(&sc->sc_fastq, IFQ_MAXLEN); IFQ_SET_MAXLEN(&sc->sc_rawq, IFQ_MAXLEN); IFQ_LOCK_INIT(&sc->sc_fastq); /* Ratio of 1:2 packets between the regular and the fast queue */ sc->sc_maxfastq = 2; IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, 0); return sc; } static int ppp_clone_create(struct if_clone *ifc, int unit) { return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0; } static int ppp_clone_destroy(struct ifnet *ifp) { struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc; if (sc->sc_devp != NULL) return EBUSY; /* Not removing it */ mutex_enter(&ppp_softcs.lock); LIST_REMOVE(sc, sc_iflist); mutex_exit(&ppp_softcs.lock); bpf_detach(ifp); if_detach(ifp); IFQ_LOCK_DESTROY(&sc->sc_fastq); free(sc, M_DEVBUF); return 0; } /* * Allocate a ppp interface unit and initialize it. */ struct ppp_softc * pppalloc(pid_t pid) { struct ppp_softc *sc = NULL, *scf; int i; mutex_enter(&ppp_softcs.lock); LIST_FOREACH(scf, &ppp_softcs.list, sc_iflist) { if (scf->sc_xfer == pid) { scf->sc_xfer = 0; mutex_exit(&ppp_softcs.lock); return scf; } if (scf->sc_devp == NULL && sc == NULL) sc = scf; } mutex_exit(&ppp_softcs.lock); if (sc == NULL) sc = ppp_create(ppp_cloner.ifc_name, -1); sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); if (sc->sc_si == NULL) { printf("%s: unable to establish softintr\n", sc->sc_if.if_xname); return NULL; } sc->sc_flags = 0; sc->sc_mru = PPP_MRU; sc->sc_relinq = NULL; (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats)); #ifdef VJC sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); if (sc->sc_comp) sl_compress_init(sc->sc_comp); #endif #ifdef PPP_COMPRESS sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; #endif /* PPP_COMPRESS */ for (i = 0; i < NUM_NP; ++i) sc->sc_npmode[i] = NPMODE_ERROR; sc->sc_npqueue = NULL; sc->sc_npqtail = &sc->sc_npqueue; sc->sc_last_sent = sc->sc_last_recv = time_second; return sc; } /* * Deallocate a ppp unit. Must be called at splsoftnet or higher. */ void pppdealloc(struct ppp_softc *sc) { struct mbuf *m; softint_disestablish(sc->sc_si); if_down(&sc->sc_if); sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); sc->sc_devp = NULL; sc->sc_xfer = 0; for (;;) { IF_DEQUEUE(&sc->sc_rawq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_inq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) break; m_freem(m); } while ((m = sc->sc_npqueue) != NULL) { sc->sc_npqueue = m->m_nextpkt; m_freem(m); } if (sc->sc_togo != NULL) { m_freem(sc->sc_togo); sc->sc_togo = NULL; } #ifdef PPP_COMPRESS ppp_ccp_closed(sc); sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; #endif /* PPP_COMPRESS */ #ifdef PPP_FILTER if (sc->sc_pass_filt_in.bf_insns != 0) { free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); sc->sc_pass_filt_in.bf_insns = 0; sc->sc_pass_filt_in.bf_len = 0; } if (sc->sc_pass_filt_out.bf_insns != 0) { free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); sc->sc_pass_filt_out.bf_insns = 0; sc->sc_pass_filt_out.bf_len = 0; } if (sc->sc_active_filt_in.bf_insns != 0) { free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); sc->sc_active_filt_in.bf_insns = 0; sc->sc_active_filt_in.bf_len = 0; } if (sc->sc_active_filt_out.bf_insns != 0) { free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); sc->sc_active_filt_out.bf_insns = 0; sc->sc_active_filt_out.bf_len = 0; } #endif /* PPP_FILTER */ #ifdef VJC if (sc->sc_comp != 0) { free(sc->sc_comp, M_DEVBUF); sc->sc_comp = 0; } #endif (void)ppp_clone_destroy(&sc->sc_if); } /* * Ioctl routine for generic ppp devices. */ int pppioctl(struct ppp_softc *sc, u_long cmd, void *data, int flag, struct lwp *l) { int s, error, flags, mru, npx; u_int nb; struct ppp_option_data *odp; struct compressor *cp; struct npioctl *npi; time_t t; #ifdef PPP_FILTER struct bpf_program *bp, *nbp; struct bpf_insn *newcode, *oldcode; int newcodelen; #endif /* PPP_FILTER */ #ifdef PPP_COMPRESS u_char ccp_option[CCP_MAX_OPTION_LENGTH]; #endif switch (cmd) { case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return EPERM; break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return EPERM; break; default: break; } switch (cmd) { case FIONREAD: *(int *)data = sc->sc_inq.ifq_len; break; case PPPIOCGUNIT: *(int *)data = sc->sc_unit; break; case PPPIOCGFLAGS: *(u_int *)data = sc->sc_flags; break; case PPPIOCGRAWIN: { struct ppp_rawin *rwin = (struct ppp_rawin *)data; u_char c, q = 0; for (c = sc->sc_rawin_start; c < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[c++]; for (c = 0; c < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[c++]; rwin->count = sc->sc_rawin.count; } break; case PPPIOCSFLAGS: flags = *(int *)data & SC_MASK; s = splsoftnet(); #ifdef PPP_COMPRESS if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN)) ppp_ccp_closed(sc); #endif splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags; splx(s); break; case PPPIOCSMRU: mru = *(int *)data; if (mru >= PPP_MINMRU && mru <= PPP_MAXMRU) sc->sc_mru = mru; break; case PPPIOCGMRU: *(int *)data = sc->sc_mru; break; #ifdef VJC case PPPIOCSMAXCID: if (sc->sc_comp) { s = splsoftnet(); sl_compress_setup(sc->sc_comp, *(int *)data); splx(s); } break; #endif case PPPIOCXFERUNIT: sc->sc_xfer = l->l_proc->p_pid; break; #ifdef PPP_COMPRESS case PPPIOCSCOMPRESS: odp = (struct ppp_option_data *)data; nb = odp->length; if (nb > sizeof(ccp_option)) nb = sizeof(ccp_option); if (nb < 3) return EINVAL; if ((error = copyin(odp->ptr, ccp_option, nb)) != 0) return error; /* preliminary check on the length byte */ if (ccp_option[1] < 2) return EINVAL; cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return EINVAL; /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); } sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return error; #endif /* PPP_COMPRESS */ case PPPIOCGNPMODE: case PPPIOCSNPMODE: npi = (struct npioctl *)data; switch (npi->protocol) { case PPP_IP: npx = NP_IP; break; case PPP_IPV6: npx = NP_IPV6; break; default: return EINVAL; } if (cmd == PPPIOCGNPMODE) { npi->mode = sc->sc_npmode[npx]; } else { if (npi->mode != sc->sc_npmode[npx]) { s = splnet(); sc->sc_npmode[npx] = npi->mode; if (npi->mode != NPMODE_QUEUE) { ppp_requeue(sc); ppp_restart(sc); } splx(s); } } break; case PPPIOCGIDLE: s = splsoftnet(); t = time_second; ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent; ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv; splx(s); break; #ifdef PPP_FILTER case PPPIOCSPASS: case PPPIOCSACTIVE: /* These are no longer supported. */ return EOPNOTSUPP; case PPPIOCSIPASS: case PPPIOCSOPASS: case PPPIOCSIACTIVE: case PPPIOCSOACTIVE: nbp = (struct bpf_program *)data; if ((unsigned) nbp->bf_len > BPF_MAXINSNS) return EINVAL; newcodelen = nbp->bf_len * sizeof(struct bpf_insn); if (newcodelen != 0) { newcode = malloc(newcodelen, M_DEVBUF, M_WAITOK); /* WAITOK -- malloc() never fails. */ if ((error = copyin((void *)nbp->bf_insns, (void *)newcode, newcodelen)) != 0) { free(newcode, M_DEVBUF); return error; } if (!bpf_validate(newcode, nbp->bf_len)) { free(newcode, M_DEVBUF); return EINVAL; } } else newcode = 0; switch (cmd) { case PPPIOCSIPASS: bp = &sc->sc_pass_filt_in; break; case PPPIOCSOPASS: bp = &sc->sc_pass_filt_out; break; case PPPIOCSIACTIVE: bp = &sc->sc_active_filt_in; break; case PPPIOCSOACTIVE: bp = &sc->sc_active_filt_out; break; default: free(newcode, M_DEVBUF); return EPASSTHROUGH; } oldcode = bp->bf_insns; s = splnet(); bp->bf_len = nbp->bf_len; bp->bf_insns = newcode; splx(s); if (oldcode != 0) free(oldcode, M_DEVBUF); break; #endif /* PPP_FILTER */ default: return EPASSTHROUGH; } return 0; } /* * Process an ioctl request to the ppp network interface. */ static int pppsioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ppp_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; #ifdef PPP_COMPRESS struct ppp_comp_stats *pcp; #endif int s = splnet(), error = 0; switch (cmd) { case SIOCSIFFLAGS: if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; if ((ifp->if_flags & IFF_RUNNING) == 0) ifp->if_flags &= ~IFF_UP; break; case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: printf("%s: af%d not supported\n", ifp->if_xname, ifa->ifa_addr->sa_family); error = EAFNOSUPPORT; break; } ifa->ifa_rtrequest = p2p_rtrequest; break; case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { error = EAFNOSUPPORT; break; } switch (ifreq_getaddr(cmd, ifr)->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: error = EAFNOSUPPORT; break; } break; case SIOCGPPPSTATS: psp = &((struct ifpppstatsreq *)data)->stats; memset(psp, 0, sizeof(*psp)); psp->p = sc->sc_stats; #if defined(VJC) && !defined(SL_NO_STATS) if (sc->sc_comp) { psp->vj.vjs_packets = sc->sc_comp->sls_packets; psp->vj.vjs_compressed = sc->sc_comp->sls_compressed; psp->vj.vjs_searches = sc->sc_comp->sls_searches; psp->vj.vjs_misses = sc->sc_comp->sls_misses; psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin; psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin; psp->vj.vjs_errorin = sc->sc_comp->sls_errorin; psp->vj.vjs_tossed = sc->sc_comp->sls_tossed; } #endif /* VJC */ break; #ifdef PPP_COMPRESS case SIOCGPPPCSTATS: pcp = &((struct ifpppcstatsreq *)data)->stats; memset(pcp, 0, sizeof(*pcp)); if (sc->sc_xc_state != NULL) (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c); if (sc->sc_rc_state != NULL) (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d); break; #endif /* PPP_COMPRESS */ default: if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; } splx(s); return error; } /* * Queue a packet. Start transmission if not active. * Packet is placed in Information field of PPP frame. */ int pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, const struct rtentry *rtp) { struct ppp_softc *sc = ifp->if_softc; int protocol, address, control; u_char *cp; int s, error; #ifdef INET struct ip *ip; #endif struct ifqueue *ifq; enum NPmode mode; int len; if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { error = ENETDOWN; /* sort of */ goto bad; } IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family); /* * Compute PPP header. */ m0->m_flags &= ~M_HIGHPRI; switch (dst->sa_family) { #ifdef INET case AF_INET: address = PPP_ALLSTATIONS; control = PPP_UI; protocol = PPP_IP; mode = sc->sc_npmode[NP_IP]; /* * If this packet has the "low delay" bit set in the IP header, * put it on the fastq instead. */ ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; break; #endif #ifdef INET6 case AF_INET6: address = PPP_ALLSTATIONS; /*XXX*/ control = PPP_UI; /*XXX*/ protocol = PPP_IPV6; mode = sc->sc_npmode[NP_IPV6]; #if 0 /* XXX flowinfo/traffic class, maybe? */ /* * If this packet has the "low delay" bit set in the IP header, * put it on the fastq instead. */ ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; #endif break; #endif case AF_UNSPEC: address = PPP_ADDRESS(dst->sa_data); control = PPP_CONTROL(dst->sa_data); protocol = PPP_PROTOCOL(dst->sa_data); mode = NPMODE_PASS; break; default: printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); error = EAFNOSUPPORT; goto bad; } /* * Drop this packet, or return an error, if necessary. */ if (mode == NPMODE_ERROR) { error = ENETDOWN; goto bad; } if (mode == NPMODE_DROP) { error = 0; goto bad; } /* * Add PPP header. */ M_PREPEND(m0, PPP_HDRLEN, M_DONTWAIT); if (m0 == NULL) { error = ENOBUFS; goto bad; } cp = mtod(m0, u_char *); *cp++ = address; *cp++ = control; *cp++ = protocol >> 8; *cp++ = protocol & 0xff; len = m_length(m0); if (sc->sc_flags & SC_LOG_OUTPKT) { printf("%s output: ", ifp->if_xname); pppdumpm(m0); } if ((protocol & 0x8000) == 0) { #ifdef PPP_FILTER /* * Apply the pass and active filters to the packet, * but only if it is a data packet. */ if (sc->sc_pass_filt_out.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *)m0, len, 0) == 0) { error = 0; /* drop this packet */ goto bad; } /* * Update the time we sent the most recent packet. */ if (sc->sc_active_filt_out.bf_insns == 0 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *)m0, len, 0)) sc->sc_last_sent = time_second; #else /* * Update the time we sent the most recent packet. */ sc->sc_last_sent = time_second; #endif /* PPP_FILTER */ } /* * See if bpf wants to look at the packet. */ bpf_mtap(&sc->sc_if, m0, BPF_D_OUT); /* * Put the packet on the appropriate queue. */ s = splnet(); if (mode == NPMODE_QUEUE) { /* XXX we should limit the number of packets on this queue */ *sc->sc_npqtail = m0; m0->m_nextpkt = NULL; sc->sc_npqtail = &m0->m_nextpkt; } else { ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) { splx(s); if_statinc(&sc->sc_if, if_oerrors); sc->sc_stats.ppp_oerrors++; return error; } ppp_restart(sc); } if_statadd2(ifp, if_opackets, 1, if_obytes, len); splx(s); return 0; bad: m_freem(m0); return error; } /* * After a change in the NPmode for some NP, move packets from the * npqueue to the send queue or the fast queue as appropriate. * Should be called at splnet, since we muck with the queues. */ static void ppp_requeue(struct ppp_softc *sc) { struct mbuf *m, **mpp; struct ifqueue *ifq; enum NPmode mode; int error; for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) { switch (PPP_PROTOCOL(mtod(m, u_char *))) { case PPP_IP: mode = sc->sc_npmode[NP_IP]; break; case PPP_IPV6: mode = sc->sc_npmode[NP_IPV6]; break; default: mode = NPMODE_PASS; } switch (mode) { case NPMODE_PASS: /* * This packet can now go on one of the queues to * be sent. */ *mpp = m->m_nextpkt; m->m_nextpkt = NULL; ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m)) != 0) { if_statinc(&sc->sc_if, if_oerrors); sc->sc_stats.ppp_oerrors++; } break; case NPMODE_DROP: case NPMODE_ERROR: *mpp = m->m_nextpkt; m_freem(m); break; case NPMODE_QUEUE: mpp = &m->m_nextpkt; break; } } sc->sc_npqtail = mpp; } /* * Transmitter has finished outputting some stuff; * remember to call sc->sc_start later at splsoftnet. */ void ppp_restart(struct ppp_softc *sc) { int s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_TBUSY; softint_schedule(sc->sc_si); splx(s); } /* * Get a packet to send. This procedure is intended to be called at * splsoftnet, since it may involve time-consuming operations such as * applying VJ compression, packet compression, address/control and/or * protocol field compression to the packet. */ struct mbuf * ppp_dequeue(struct ppp_softc *sc) { struct mbuf *m, *mp; u_char *cp; int address, control, protocol; int s; /* * Grab a packet to send: first try the fast queue, then the * normal queue. */ s = splnet(); if (sc->sc_nfastq < sc->sc_maxfastq) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; else IFQ_DEQUEUE(&sc->sc_if.if_snd, m); } else { sc->sc_nfastq = 0; IFQ_DEQUEUE(&sc->sc_if.if_snd, m); if (m == NULL) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; } } splx(s); if (m == NULL) return NULL; ++sc->sc_stats.ppp_opackets; /* * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. */ cp = mtod(m, u_char *); address = PPP_ADDRESS(cp); control = PPP_CONTROL(cp); protocol = PPP_PROTOCOL(cp); switch (protocol) { case PPP_IP: #ifdef VJC /* * If the packet is a TCP/IP packet, see if we can compress it. */ if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) { struct ip *ip; int type; mp = m; ip = (struct ip *)(cp + PPP_HDRLEN); if (mp->m_len <= PPP_HDRLEN) { mp = mp->m_next; if (mp == NULL) break; ip = mtod(mp, struct ip *); } /* * This code assumes the IP/TCP header is in one * non-shared mbuf */ if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; cp = mtod(m, u_char *); cp[0] = address; /* Header has moved */ cp[1] = control; cp[2] = 0; break; } /* Update protocol in PPP header */ cp[3] = protocol; } } #endif /* VJC */ break; #ifdef PPP_COMPRESS case PPP_CCP: ppp_ccp(sc, m, 0); break; #endif /* PPP_COMPRESS */ } #ifdef PPP_COMPRESS if (protocol != PPP_LCP && protocol != PPP_CCP && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) { struct mbuf *mcomp = NULL; int slen; slen = 0; for (mp = m; mp != NULL; mp = mp->m_next) slen += mp->m_len; (*sc->sc_xcomp->compress) (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN); if (mcomp != NULL) { if (sc->sc_flags & SC_CCP_UP) { /* * Send the compressed packet instead of the * original. */ m_freem(m); m = mcomp; cp = mtod(m, u_char *); protocol = cp[3]; } else { /* * Can't transmit compressed packets until CCP * is up. */ m_freem(mcomp); } } } #endif /* PPP_COMPRESS */ /* * Compress the address/control and protocol, if possible. */ if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS && control == PPP_UI && protocol != PPP_ALLSTATIONS && protocol != PPP_LCP) { /* can compress address/control */ m->m_data += 2; m->m_len -= 2; } if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) { /* can compress protocol */ if (mtod(m, u_char *) == cp) { cp[2] = cp[1]; /* move address/control up */ cp[1] = cp[0]; } ++m->m_data; --m->m_len; } return m; } /* * Software interrupt routine, called at splsoftnet. */ static void pppintr(void *arg) { struct ppp_softc *sc = arg; struct mbuf *m; int s; mutex_enter(softnet_lock); if (!(sc->sc_flags & SC_TBUSY) && (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0 || sc->sc_fastq.ifq_head || sc->sc_outm)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_TBUSY; splx(s); (*sc->sc_start)(sc); } for (;;) { s = splnet(); IF_DEQUEUE(&sc->sc_rawq, m); splx(s); if (m == NULL) break; ppp_inproc(sc, m); } mutex_exit(softnet_lock); } #ifdef PPP_COMPRESS /* * Handle a CCP packet. `rcvd' is 1 if the packet was received, * 0 if it is about to be transmitted. */ static void ppp_ccp(struct ppp_softc *sc, struct mbuf *m, int rcvd) { u_char *dp, *ep; struct mbuf *mp; int slen, s; /* * Get a pointer to the data after the PPP header. */ if (m->m_len <= PPP_HDRLEN) { mp = m->m_next; if (mp == NULL) return; dp = mtod(mp, u_char *); } else { mp = m; dp = mtod(mp, u_char *) + PPP_HDRLEN; } ep = mtod(mp, u_char *) + mp->m_len; if (dp + CCP_HDRLEN > ep) return; slen = CCP_LENGTH(dp); if (dp + slen > ep) { if (sc->sc_flags & SC_DEBUG) printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n", dp, slen, mtod(mp, u_char *), mp->m_len); return; } switch (CCP_CODE(dp)) { case CCP_CONFREQ: case CCP_TERMREQ: case CCP_TERMACK: /* CCP must be going down - disable compression */ if (sc->sc_flags & SC_CCP_UP) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN); splx(s); } break; case CCP_CONFACK: if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP) && slen >= CCP_HDRLEN + CCP_OPT_MINLEN && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) { if (!rcvd) { /* We're agreeing to send compressed packets. */ if (sc->sc_xc_state != NULL && (*sc->sc_xcomp->comp_init)(sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_COMP_RUN; splx(s); } } else { /* * Peer is agreeing to send compressed * packets. */ if (sc->sc_rc_state != NULL && (*sc->sc_rcomp->decomp_init)( sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_mru, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_DECOMP_RUN; sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR); splx(s); } } } break; case CCP_RESETACK: if (sc->sc_flags & SC_CCP_UP) { if (!rcvd) { if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state); } else { if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) { (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DC_ERROR; splx(s); } } } break; } } /* * CCP is down; free (de)compressor state if necessary. */ static void ppp_ccp_closed(struct ppp_softc *sc) { if (sc->sc_xc_state) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); sc->sc_xc_state = NULL; } if (sc->sc_rc_state) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); sc->sc_rc_state = NULL; } } #endif /* PPP_COMPRESS */ /* * PPP packet input routine. * The caller has checked and removed the FCS and has inserted * the address/control bytes and the protocol high byte if they * were omitted. */ void ppppktin(struct ppp_softc *sc, struct mbuf *m, int lost) { int s = splhigh(); /* XXX IMP ME HARDER */ if (lost) m->m_flags |= M_ERRMARK; IF_ENQUEUE(&sc->sc_rawq, m); softint_schedule(sc->sc_si); splx(s); } /* * Process a received PPP packet, doing decompression as necessary. * Should be called at splsoftnet. */ #define COMPTYPE(proto) \ ((proto) == PPP_VJC_COMP ? TYPE_COMPRESSED_TCP \ : TYPE_UNCOMPRESSED_TCP) static void ppp_inproc(struct ppp_softc *sc, struct mbuf *m) { struct ifnet *ifp = &sc->sc_if; pktqueue_t *pktq = NULL; struct ifqueue *inq = NULL; int s, ilen, proto, rv; u_char *cp, adrs, ctrl; struct mbuf *mp, *dmp = NULL; #ifdef VJC int xlen; u_char *iphdr; u_int hlen; #endif sc->sc_stats.ppp_ipackets++; if (sc->sc_flags & SC_LOG_INPKT) { ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; printf("%s: got %d bytes\n", ifp->if_xname, ilen); pppdumpm(m); } cp = mtod(m, u_char *); adrs = PPP_ADDRESS(cp); ctrl = PPP_CONTROL(cp); proto = PPP_PROTOCOL(cp); if (m->m_flags & M_ERRMARK) { m->m_flags &= ~M_ERRMARK; s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; splx(s); } #ifdef PPP_COMPRESS /* * Decompress this packet if necessary, update the receiver's * dictionary, or take appropriate action on a CCP packet. */ if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN) && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) { /* Decompress this packet */ rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp); if (rv == DECOMP_OK) { m_freem(m); if (dmp == NULL) { /* * No error, but no decompressed packet * produced */ return; } m = dmp; cp = mtod(m, u_char *); proto = PPP_PROTOCOL(cp); } else { /* * An error has occurred in decompression. * Pass the compressed packet up to pppd, which may * take CCP down or issue a Reset-Req. */ if (sc->sc_flags & SC_DEBUG) printf("%s: decompress failed %d\n", ifp->if_xname, rv); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; if (rv == DECOMP_ERROR) sc->sc_flags |= SC_DC_ERROR; else sc->sc_flags |= SC_DC_FERROR; splx(s); } } else { if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m); if (proto == PPP_CCP) ppp_ccp(sc, m, 1); } #endif ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; #ifdef VJC if (sc->sc_flags & SC_VJ_RESET) { /* * If we've missed a packet, we must toss subsequent compressed * packets which don't have an explicit connection ID. */ if (sc->sc_comp) sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_VJ_RESET; splx(s); } /* * See if we have a VJ-compressed packet to uncompress. */ if (proto == PPP_VJC_COMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen <= 0) { if (sc->sc_flags & SC_DEBUG) { printf("%s: VJ uncompress failed" " on type comp\n", ifp->if_xname); } goto bad; } /* Copy the PPP and IP headers into a new mbuf. */ MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp == NULL) goto bad; mp->m_len = 0; mp->m_next = NULL; if (hlen + PPP_HDRLEN > MHLEN) { MCLGET(mp, M_DONTWAIT); if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) { /* Lose if big headers and no clusters */ m_freem(mp); goto bad; } } cp = mtod(mp, u_char *); cp[0] = adrs; cp[1] = ctrl; cp[2] = 0; cp[3] = PPP_IP; proto = PPP_IP; bcopy(iphdr, cp + PPP_HDRLEN, hlen); mp->m_len = hlen + PPP_HDRLEN; /* * Trim the PPP and VJ headers off the old mbuf * and stick the new and old mbufs together. */ m->m_data += PPP_HDRLEN + xlen; m->m_len -= PPP_HDRLEN + xlen; if (m->m_len <= M_TRAILINGSPACE(mp)) { bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len); mp->m_len += m->m_len; mp->m_next = m_free(m); } else mp->m_next = m; m = mp; ilen += hlen - xlen; } else if (proto == PPP_VJC_UNCOMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen < 0) { if (sc->sc_flags & SC_DEBUG) { printf("%s: VJ uncompress failed" " on type uncomp\n", ifp->if_xname); } goto bad; } proto = PPP_IP; cp[3] = PPP_IP; } #endif /* VJC */ /* * If the packet will fit in a header mbuf, don't waste a * whole cluster on it. */ if (ilen <= MHLEN && (m->m_flags & M_EXT)) { MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp != NULL) { m_copydata(m, 0, ilen, mtod(mp, void *)); m_freem(m); m = mp; m->m_len = ilen; } } m->m_pkthdr.len = ilen; m_set_rcvif(m, ifp); if ((proto & 0x8000) == 0) { #ifdef PPP_FILTER /* * See whether we want to pass this packet, and * if it counts as link activity. */ if (sc->sc_pass_filt_in.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *)m, ilen, 0) == 0) { /* drop this packet */ m_freem(m); return; } if (sc->sc_active_filt_in.bf_insns == 0 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *)m, ilen, 0)) sc->sc_last_recv = time_second; #else /* * Record the time that we received this packet. */ sc->sc_last_recv = time_second; #endif /* PPP_FILTER */ } /* See if bpf wants to look at the packet. */ bpf_mtap(&sc->sc_if, m, BPF_D_IN); switch (proto) { #ifdef INET case PPP_IP: /* * IP packet - take off the ppp header and pass it up to IP. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IP] != NPMODE_PASS) { /* Interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; #ifdef GATEWAY if (ipflow_fastforward(m)) return; #endif pktq = ip_pktq; break; #endif #ifdef INET6 case PPP_IPV6: /* * IPv6 packet - take off the ppp header and pass it up to * IPv6. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; #ifdef GATEWAY if (ip6flow_fastforward(&m)) return; #endif pktq = ip6_pktq; break; #endif default: /* * Some other protocol - place on input queue for read(). */ inq = &sc->sc_inq; pktq = NULL; break; } /* * Put the packet on the appropriate input queue. */ s = splnet(); /* pktq: inet or inet6 cases */ if (__predict_true(pktq)) { if (__predict_false(!pktq_enqueue(pktq, m, 0))) { splx(s); if_statinc(ifp, if_iqdrops); goto bad; } if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen); splx(s); return; } /* ifq: other protocol cases */ if (!inq) { splx(s); goto bad; } if (IF_QFULL(inq)) { IF_DROP(inq); splx(s); if (sc->sc_flags & SC_DEBUG) printf("%s: input queue full\n", ifp->if_xname); if_statinc(ifp, if_iqdrops); goto bad; } IF_ENQUEUE(inq, m); splx(s); if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen); (*sc->sc_ctlp)(sc); return; bad: m_freem(m); if_statinc(&sc->sc_if, if_ierrors); sc->sc_stats.ppp_ierrors++; } #define MAX_DUMP_BYTES 128 static void pppdumpm(struct mbuf *m0) { char buf[3*MAX_DUMP_BYTES+4]; char *bp = buf; struct mbuf *m; for (m = m0; m; m = m->m_next) { int l = m->m_len; u_char *rptr = (u_char *)m->m_data; while (l--) { if (bp > buf + sizeof(buf) - 4) goto done; /* Convert byte to ascii hex */ *bp++ = hexdigits[*rptr >> 4]; *bp++ = hexdigits[*rptr++ & 0xf]; } if (m->m_next) { if (bp > buf + sizeof(buf) - 3) goto done; *bp++ = '|'; } else *bp++ = ' '; } done: if (m) *bp++ = '>'; *bp = 0; printf("%s\n", buf); } #ifdef ALTQ /* * A wrapper to transmit a packet from if_start since ALTQ uses * if_start to send a packet. */ static void ppp_ifstart(struct ifnet *ifp) { struct ppp_softc *sc; sc = ifp->if_softc; (*sc->sc_start)(sc); } #endif static const struct ppp_known_compressor { uint8_t code; const char *module; } ppp_known_compressors[] = { { CI_DEFLATE, "ppp_deflate" }, { CI_DEFLATE_DRAFT, "ppp_deflate" }, { CI_BSD_COMPRESS, "ppp_bsdcomp" }, { CI_MPPE, "ppp_mppe" }, { 0, NULL } }; static int ppp_compressor_init(void) { mutex_init(&ppp_compressors_mtx, MUTEX_DEFAULT, IPL_NONE); return 0; } static int ppp_compressor_destroy(void) { mutex_destroy(&ppp_compressors_mtx); return 0; } static void ppp_compressor_rele(struct compressor *cp) { mutex_enter(&ppp_compressors_mtx); --cp->comp_refcnt; mutex_exit(&ppp_compressors_mtx); } static struct compressor * ppp_get_compressor_noload(uint8_t ci, bool hold) { struct compressor *cp; KASSERT(mutex_owned(&ppp_compressors_mtx)); LIST_FOREACH(cp, &ppp_compressors, comp_list) { if (cp->compress_proto == ci) { if (hold) ++cp->comp_refcnt; return cp; } } return NULL; } static struct compressor * ppp_get_compressor(uint8_t ci) { struct compressor *cp = NULL; const struct ppp_known_compressor *pkc; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp != NULL) return cp; kernconfig_lock(); mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp == NULL) { /* Not found, so try to autoload a module */ for (pkc = ppp_known_compressors; pkc->module != NULL; pkc++) { if (pkc->code == ci) { if (module_autoload(pkc->module, MODULE_CLASS_MISC) != 0) break; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); break; } } } kernconfig_unlock(); return cp; } int ppp_register_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != NULL) error = EEXIST; } if (!error) { for (i = 0; i < ncomp; i++) { pc[i].comp_refcnt = 0; LIST_INSERT_HEAD(&ppp_compressors, &pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } int ppp_unregister_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != &pc[i]) error = ENOENT; else if (pc[i].comp_refcnt != 0) error = EBUSY; } if (!error) { for (i = 0; i < ncomp; i++) { LIST_REMOVE(&pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } /* * Module infrastructure */ #include "if_module.h" #ifdef PPP_FILTER #define PPP_DEP "bpf_filter," #else #define PPP_DEP #endif IF_MODULE(MODULE_CLASS_DRIVER, ppp, PPP_DEP "slcompress") @ 1.172.8.1 log @Rename ifq_enqueue() -> if_enqueue(), ifq_enqueue2() -> if_enqueue2(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.172 2022/09/03 02:47:59 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.172 2022/09/03 02:47:59 thorpej Exp $"); d1022 1 a1022 1 if ((error = if_enqueue2(&sc->sc_if, ifq, m0)) != 0) { d1074 1 a1074 1 if ((error = if_enqueue2(&sc->sc_if, ifq, m)) != 0) { @ 1.172.8.2 log @IFQ_CLASSIFY() -> ifq_classify_packet(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.172.8.1 2023/11/15 02:08:34 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.172.8.1 2023/11/15 02:08:34 thorpej Exp $"); d890 1 a890 1 ifq_classify_packet(&ifp->if_snd, m0, dst->sa_family); @ 1.171 log @Ensure that all queues passed to ifq_enqueue2() have a valid ifq_lock. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.170 2022/08/27 19:04:43 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.170 2022/08/27 19:04:43 thorpej Exp $"); a139 1 #include @ 1.170 log @Consistently use IFQ_SET_MAXLEN(), rather than open-coding it. NFC. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.169 2022/07/06 08:07:23 riastradh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.169 2022/07/06 08:07:23 riastradh Exp $"); d326 2 d358 2 @ 1.169 log @net/if_ppp.c: Avoid user-controlled overrun in PPPIOCSCOMPRESS. Reported-by: syzbot+2c7bda7dc2b6c0d4f279@@syzkaller.appspotmail.com @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.168 2022/07/06 08:06:59 riastradh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.168 2022/07/06 08:06:59 riastradh Exp $"); d322 4 a325 3 sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; @ 1.168 log @net/if_ppp.c: Sprinkle KNF. No functional change intended. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $"); d600 2 @ 1.167 log @Adopt . @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.166 2019/09/20 08:45:29 maxv Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.166 2019/09/20 08:45:29 maxv Exp $"); d326 1 a326 1 sc->sc_maxfastq = 2; d387 1 a387 1 return (NULL); d517 1 a517 1 return (EPERM); d524 1 a524 1 return (EPERM); d596 1 a596 1 odp = (struct ppp_option_data *) data; d601 1 a601 1 return (error); d604 1 a604 1 return (EINVAL); d611 1 a611 1 return (EINVAL); /* no handler found */ d653 1 a653 1 return (error); d658 1 a658 1 npi = (struct npioctl *) data; d702 1 a702 1 nbp = (struct bpf_program *) data; d738 1 a738 1 return (EPASSTHROUGH); d751 1 a751 1 return (EPASSTHROUGH); d753 1 a753 1 return (0); d820 1 a820 1 psp = &((struct ifpppstatsreq *) data)->stats; d839 1 a839 1 pcp = &((struct ifpppcstatsreq *) data)->stats; d854 1 a854 1 return (error); d876 4 a879 2 if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { d978 2 a979 2 if (sc->sc_pass_filt_out.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_out.bf_insns, d988 2 a989 2 if (sc->sc_active_filt_out.bf_insns == 0 || bpf_filter(sc->sc_active_filt_out.bf_insns, d1020 1 a1020 1 return (error); d1027 1 a1027 1 return (0); d1031 1 a1031 1 return (error); d1163 1 a1163 1 ip = (struct ip *) (cp + PPP_HDRLEN); d1204 2 a1205 2 if (protocol != PPP_LCP && protocol != PPP_CCP && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) { d1269 4 a1272 3 if (!(sc->sc_flags & SC_TBUSY) && (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0 || sc->sc_fastq.ifq_head || sc->sc_outm)) { d1338 4 a1341 3 if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP) && slen >= CCP_HDRLEN + CCP_OPT_MINLEN && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) { d1344 4 a1347 4 if (sc->sc_xc_state != NULL && (*sc->sc_xcomp->comp_init) (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, d1358 4 a1361 3 if (sc->sc_rc_state != NULL && (*sc->sc_rcomp->decomp_init) (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, d1366 2 a1367 1 sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR); d1433 3 a1435 2 #define COMPTYPE(proto) ((proto) == PPP_VJC_COMP ? TYPE_COMPRESSED_TCP: \ TYPE_UNCOMPRESSED_TCP) d1479 5 a1483 2 if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN) && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) { a1551 1 d1553 3 a1555 2 if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type comp\n", d1557 1 a1606 1 d1608 3 a1610 2 if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type uncomp\n", d1612 1 d1643 2 a1644 2 if (sc->sc_pass_filt_in.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_in.bf_insns, d1650 2 a1651 2 if (sc->sc_active_filt_in.bf_insns == 0 || bpf_filter(sc->sc_active_filt_in.bf_insns, d1671 2 a1672 2 if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IP] != NPMODE_PASS) { d1694 2 a1695 2 if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { d1703 1 a1703 1 #ifdef GATEWAY @ 1.166 log @dedup @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.165 2019/06/25 12:30:50 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.165 2019/06/25 12:30:50 msaitoh Exp $"); d1016 1 a1016 1 sc->sc_if.if_oerrors++; d1022 1 a1022 2 ifp->if_opackets++; ifp->if_obytes += len; d1067 1 a1067 1 sc->sc_if.if_oerrors++; d1717 1 a1717 1 ifp->if_iqdrops++; d1720 1 a1720 2 ifp->if_ipackets++; ifp->if_ibytes += ilen; d1735 1 a1735 1 ifp->if_iqdrops++; d1740 1 a1740 2 ifp->if_ipackets++; ifp->if_ibytes += ilen; d1748 1 a1748 1 sc->sc_if.if_ierrors++; @ 1.166.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.167 2020/01/29 04:28:27 thorpej Exp $"); d1016 1 a1016 1 if_statinc(&sc->sc_if, if_oerrors); d1022 2 a1023 1 if_statadd2(ifp, if_opackets, 1, if_obytes, len); d1068 1 a1068 1 if_statinc(&sc->sc_if, if_oerrors); d1718 1 a1718 1 if_statinc(ifp, if_iqdrops); d1721 2 a1722 1 if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen); d1737 1 a1737 1 if_statinc(ifp, if_iqdrops); d1742 2 a1743 1 if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen); d1751 1 a1751 1 if_statinc(&sc->sc_if, if_ierrors); @ 1.165 log @ Simplify "LIST_HEAD();" to make the code more understandable. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.164 2019/01/25 08:51:29 knakahara Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.164 2019/01/25 08:51:29 knakahara Exp $"); a183 13 * Some useful mbuf macros not in mbuf.h. */ #define M_IS_CLUSTER(m) ((m)->m_flags & M_EXT) #define M_DATASTART(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \ (m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat) #define M_DATASIZE(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \ (m)->m_flags & M_PKTHDR ? MHLEN: MLEN) /* d1614 1 a1614 1 if (ilen <= MHLEN && M_IS_CLUSTER(m)) { @ 1.164 log @Add __cacheline_aligned to ppp softc list and its mutex just in case. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.163 2019/01/11 02:57:21 knakahara Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.163 2019/01/11 02:57:21 knakahara Exp $"); a208 1 LIST_HEAD(ppp_sclist, ppp_softc); d210 1 a210 1 struct ppp_sclist list; @ 1.163 log @Fix missing splx in ppp_inproc(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.162 2019/01/11 02:55:41 knakahara Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.162 2019/01/11 02:55:41 knakahara Exp $"); d209 5 a213 2 static LIST_HEAD(, ppp_softc) ppp_softc_list; static kmutex_t ppp_list_lock; d251 2 a252 2 mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softc_list); d261 1 a261 1 if (!LIST_EMPTY(&ppp_softc_list)) d268 1 a268 1 mutex_destroy(&ppp_list_lock); d283 1 a283 1 mutex_enter(&ppp_list_lock); d286 1 a286 1 LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { d301 1 a301 1 LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { d307 1 a307 1 mutex_exit(&ppp_list_lock); d318 1 a318 1 LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist); d320 1 a320 1 mutex_exit(&ppp_list_lock); d362 1 a362 1 mutex_enter(&ppp_list_lock); d364 1 a364 1 mutex_exit(&ppp_list_lock); d382 2 a383 2 mutex_enter(&ppp_list_lock); LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) { d386 1 a386 1 mutex_exit(&ppp_list_lock); d392 1 a392 1 mutex_exit(&ppp_list_lock); @ 1.162 log @Fix missing mutex_exit in ppp_create(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.161 2018/06/26 06:48:02 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.161 2018/06/26 06:48:02 msaitoh Exp $"); d1728 1 d1740 1 @ 1.161 log @ Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same as FreeBSD. This change also fixes a bug that the direction is misunderstand on some environment by passing the direction to bpf_mtap*() instead of checking m->m_pkthdr.rcvif. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.160 2018/06/25 04:59:42 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.160 2018/06/25 04:59:42 msaitoh Exp $"); d304 1 @ 1.161.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.164 2019/01/25 08:51:29 knakahara Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.164 2019/01/25 08:51:29 knakahara Exp $"); d209 2 a210 5 LIST_HEAD(ppp_sclist, ppp_softc); static struct { struct ppp_sclist list; kmutex_t lock; } ppp_softcs __cacheline_aligned; d248 2 a249 2 mutex_init(&ppp_softcs.lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softcs.list); d258 1 a258 1 if (!LIST_EMPTY(&ppp_softcs.list)) d265 1 a265 1 mutex_destroy(&ppp_softcs.lock); d280 1 a280 1 mutex_enter(&ppp_softcs.lock); d283 1 a283 1 LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) { d298 1 a298 1 LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) { a303 1 mutex_exit(&ppp_softcs.lock); d314 1 a314 1 LIST_INSERT_HEAD(&ppp_softcs.list, sc, sc_iflist); d316 1 a316 1 mutex_exit(&ppp_softcs.lock); d358 1 a358 1 mutex_enter(&ppp_softcs.lock); d360 1 a360 1 mutex_exit(&ppp_softcs.lock); d378 2 a379 2 mutex_enter(&ppp_softcs.lock); LIST_FOREACH(scf, &ppp_softcs.list, sc_iflist) { d382 1 a382 1 mutex_exit(&ppp_softcs.lock); d388 1 a388 1 mutex_exit(&ppp_softcs.lock); a1726 1 splx(s); a1737 1 splx(s); @ 1.161.2.2 log @Merge changes from current as of 20200406 @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d1030 1 a1030 1 if_statinc(&sc->sc_if, if_oerrors); d1036 2 a1037 1 if_statadd2(ifp, if_opackets, 1, if_obytes, len); d1082 1 a1082 1 if_statinc(&sc->sc_if, if_oerrors); d1732 1 a1732 1 if_statinc(ifp, if_iqdrops); d1735 2 a1736 1 if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen); d1751 1 a1751 1 if_statinc(ifp, if_iqdrops); d1756 2 a1757 1 if_statadd2(ifp, if_ipackets, 1, if_ibytes, ilen); d1765 1 a1765 1 if_statinc(&sc->sc_if, if_ierrors); @ 1.161.2.3 log @Mostly merge changes from HEAD upto 20200411 @ text @d184 13 d209 1 d211 1 a211 1 LIST_HEAD(ppp_sclist, ppp_softc) list; d1627 1 a1627 1 if (ilen <= MHLEN && (m->m_flags & M_EXT)) { @ 1.160 log @ Remove duplicated inclusion of net/bpf.h. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.159 2017/09/17 20:39:04 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.159 2017/09/17 20:39:04 christos Exp $"); d1011 1 a1011 1 bpf_mtap(&sc->sc_if, m0); d1662 1 a1662 1 bpf_mtap(&sc->sc_if, m); @ 1.159 log @Add one more not supported error @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $"); a141 3 #ifdef PPP_FILTER #include #endif a150 1 @ 1.159.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.160 2018/06/25 04:59:42 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.160 2018/06/25 04:59:42 msaitoh Exp $"); d142 3 d154 1 @ 1.159.2.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.161 2018/06/26 06:48:02 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.161 2018/06/26 06:48:02 msaitoh Exp $"); d1011 1 a1011 1 bpf_mtap(&sc->sc_if, m0, BPF_D_OUT); d1662 1 a1662 1 bpf_mtap(&sc->sc_if, m, BPF_D_IN); @ 1.159.2.3 log @Synch with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.159.2.2 2018/07/28 04:38:10 pgoyette Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.159.2.2 2018/07/28 04:38:10 pgoyette Exp $"); a303 1 mutex_exit(&ppp_list_lock); a1726 1 splx(s); a1737 1 splx(s); @ 1.159.2.4 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.159.2.3 2019/01/18 08:50:58 pgoyette Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.159.2.3 2019/01/18 08:50:58 pgoyette Exp $"); d209 2 a210 5 LIST_HEAD(ppp_sclist, ppp_softc); static struct { struct ppp_sclist list; kmutex_t lock; } ppp_softcs __cacheline_aligned; d248 2 a249 2 mutex_init(&ppp_softcs.lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softcs.list); d258 1 a258 1 if (!LIST_EMPTY(&ppp_softcs.list)) d265 1 a265 1 mutex_destroy(&ppp_softcs.lock); d280 1 a280 1 mutex_enter(&ppp_softcs.lock); d283 1 a283 1 LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) { d298 1 a298 1 LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) { d304 1 a304 1 mutex_exit(&ppp_softcs.lock); d315 1 a315 1 LIST_INSERT_HEAD(&ppp_softcs.list, sc, sc_iflist); d317 1 a317 1 mutex_exit(&ppp_softcs.lock); d359 1 a359 1 mutex_enter(&ppp_softcs.lock); d361 1 a361 1 mutex_exit(&ppp_softcs.lock); d379 2 a380 2 mutex_enter(&ppp_softcs.lock); LIST_FOREACH(scf, &ppp_softcs.list, sc_iflist) { d383 1 a383 1 mutex_exit(&ppp_softcs.lock); d389 1 a389 1 mutex_exit(&ppp_softcs.lock); @ 1.158 log @MFREE -> m_free @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.157 2016/08/07 17:38:34 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.157 2016/08/07 17:38:34 christos Exp $"); d804 2 @ 1.158.8.1 log @Pull up following revision(s) (requested by msaitoh in ticket #938): sys/arch/acorn32/podulebus/if_ie.c: revision 1.41 sys/arch/amiga/dev/if_es.c: revision 1.58 sys/arch/amiga/dev/if_qn.c: revision 1.45 sys/arch/arm/at91/at91emac.c: revision 1.20 sys/arch/arm/ep93xx/epe.c: revision 1.37 sys/arch/emips/ebus/if_le_ebus.c: revision 1.14 sys/arch/emips/ebus/if_le_ebus.c: revision 1.15 sys/arch/mac68k/dev/if_mc.c: revision 1.46 sys/arch/macppc/dev/am79c950.c: revision 1.39 sys/arch/newsmips/apbus/if_sn.c: revision 1.40 sys/arch/next68k/dev/mb8795.c: revision 1.59 sys/arch/playstation2/dev/if_smap.c: revision 1.25 sys/arch/playstation2/dev/if_smap.c: revision 1.26 sys/arch/sun2/dev/if_ec.c: revision 1.28 sys/arch/sun3/dev/if_ie.c: revision 1.63 sys/arch/x68k/dev/if_ne_intio.c: revision 1.19 sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75 sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63 sys/dev/bi/if_ni.c: revision 1.45 sys/dev/cadence/if_cemac.c: revision 1.12 sys/dev/ic/am7990.c: revision 1.78 sys/dev/ic/am79900.c: revision 1.27 sys/dev/ic/an.c: revision 1.67 sys/dev/ic/cs89x0.c: revision 1.40 sys/dev/ic/dm9000.c: revision 1.13 sys/dev/ic/dm9000.c: revision 1.14 sys/dev/ic/dp8390.c: revision 1.88 sys/dev/ic/elink3.c: revision 1.141 sys/dev/ic/elinkxl.c: revision 1.122 sys/dev/ic/hme.c: revision 1.98 sys/dev/ic/i82586.c: revision 1.77 sys/dev/ic/lance.c: revision 1.53 sys/dev/ic/mb86950.c: revision 1.27 sys/dev/ic/mb86960.c: revision 1.86 sys/dev/ic/mtd803.c: revision 1.34 sys/dev/ic/pdq_ifsubr.c: revision 1.59 sys/dev/ic/rrunner.c: revision 1.86 sys/dev/ic/seeq8005.c: revision 1.58 sys/dev/ic/sgec.c: revision 1.47 sys/dev/ic/smc90cx6.c: revision 1.72 sys/dev/ic/smc91cxx.c: revision 1.96 sys/dev/ic/tropic.c: revision 1.49 sys/dev/ic/wi.c: revision 1.245 sys/dev/isa/if_eg.c: revision 1.93 sys/dev/isa/if_el.c: revision 1.95 sys/dev/isa/if_iy.c: revision 1.101 sys/dev/ofw/ofnet.c: revision 1.58 sys/dev/pci/if_alc.c: revision 1.27 sys/dev/pci/if_de.c: revision 1.152 sys/dev/pci/if_fpa.c: revision 1.61 sys/dev/pci/if_jme.c: revision 1.34 sys/dev/pci/if_tl.c: revision 1.108 sys/dev/pci/if_vte.c: revision 1.19 sys/dev/pci/ixgbe/ixgbe.h: revision 1.50 sys/dev/pcmcia/if_cnw.c: revision 1.62 sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17 sys/dev/pcmcia/if_ray.c: revision 1.89 sys/dev/pcmcia/if_xi.c: revision 1.81 sys/dev/pcmcia/mhzc.c: revision 1.51 sys/dev/pcmcia/xirc.c: revision 1.34 sys/dev/qbus/if_de.c: revision 1.33 sys/dev/qbus/if_qe.c: revision 1.78 sys/dev/qbus/if_qt.c: revision 1.22 sys/dev/sbus/be.c: revision 1.87 sys/dev/sbus/qe.c: revision 1.68 sys/dev/scsipi/if_se.c: revision 1.96 sys/dev/usb/if_atu.c: revision 1.59 sys/net/if_l2tp.c: revision 1.28 via patch sys/net/if_ppp.c: revision 1.160 It's not required to include net/bpfdesc.h. Remove it. -- Simplify like other drivers. NULL check of ifp->if_bpf is done in bpf_mtap(), so it's not required to do it here. -- Remove duplicated inclusion of net/bpf.h. -- Remove duplicated inclusion of net/bpf.h. -- Simplify bpf_mtap() call. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $"); d142 3 d154 1 @ 1.158.8.2 log @Pull up following revision(s) (requested by knakahara in ticket #1162): sys/net/if_ppp.c: revision 1.162 sys/net/if_ppp.c: revision 1.163 Fix missing mutex_exit in ppp_create(). Fix missing splx in ppp_inproc(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.158.8.1 2018/07/26 23:55:31 snj Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.158.8.1 2018/07/26 23:55:31 snj Exp $"); a303 1 mutex_exit(&ppp_list_lock); a1724 1 splx(s); a1735 1 splx(s); @ 1.157 log @modularize some more drivers and merge the module glue @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.156 2016/08/06 22:54:34 pgoyette Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.156 2016/08/06 22:54:34 pgoyette Exp $"); d1596 1 a1596 1 MFREE(m, mp->m_next); @ 1.156 log @Destroy the mutex when detaching ppp. Otherwise on a re-attach (ie, module reload) we can end up with a panic "lock already initialized" @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.155 2016/08/06 12:48:23 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.155 2016/08/06 12:48:23 christos Exp $"); d246 2 d268 5 a272 1 mutex_destroy(&ppp_list_lock); d1953 1 d1961 1 a1961 60 MODULE(MODULE_CLASS_DRIVER, if_ppp, PPP_DEP "slcompress"); #ifdef _MODULE CFDRIVER_DECL(ppp, DV_IFNET, NULL); #endif static int if_ppp_modcmd(modcmd_t cmd, void *arg) { int error = 0; switch (cmd) { case MODULE_CMD_INIT: /* Init the compressor sub-sub-system */ ppp_compressor_init(); #ifdef _MODULE error = config_cfdriver_attach(&ppp_cd); if (error) { aprint_error("%s: unable to register cfdriver for" "%s, error %d\n", __func__, ppp_cd.cd_name, error); ppp_compressor_destroy(); break; } #endif /* Init the unit list and line discipline stuff */ pppinit(); break; case MODULE_CMD_FINI: /* * Make sure it's ok to detach - no units left, and * line discipline is removed */ error = pppdetach(); if (error != 0) break; #ifdef _MODULE /* Remove device from autoconf database */ error = config_cfdriver_detach(&ppp_cd); if (error) { aprint_error("%s: failed to detach %s cfdriver, " "error %d\n", __func__, ppp_cd.cd_name, error); break; } #endif ppp_compressor_destroy(); break; case MODULE_CMD_STAT: error = ENOTTY; break; default: error = ENOTTY; break; } return error; } @ 1.155 log @make strip and slip modular, and cosmetic for ppp. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.154 2016/08/06 12:42:40 pgoyette Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.154 2016/08/06 12:42:40 pgoyette Exp $"); d266 2 @ 1.154 log @Change the internal name of the module to match its external (file system) name. Otherwise "bad things" can happen, such as modload(8) being able to load a second copy! @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.153 2016/08/06 02:35:06 pgoyette Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.153 2016/08/06 02:35:06 pgoyette Exp $"); d248 1 a248 1 panic("pppattach"); d258 1 a258 1 int error; d262 1 d265 1 @ 1.153 log @Modularize the ppp driver, and adjust dependencies of the compressor modules. For now, this is still included as a built-in module in GENERIC kernels. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.152 2016/06/10 13:27:16 ozaki-r Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.152 2016/06/10 13:27:16 ozaki-r Exp $"); d1950 1 a1950 1 MODULE(MODULE_CLASS_DRIVER, ppp, PPP_DEP "slcompress"); d1957 1 a1957 1 ppp_modcmd(modcmd_t cmd, void *arg) @ 1.152 log @Introduce m_set_rcvif and m_reset_rcvif The API is used to set (or reset) a received interface of a mbuf. They are counterpart of m_get_rcvif, which will come in another commit, hide internal of rcvif operation, and reduce the diff of the upcoming change. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.151 2016/04/28 00:16:56 ozaki-r Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.151 2016/04/28 00:16:56 ozaki-r Exp $"); d107 1 a108 2 #ifdef _KERNEL_OPT d135 2 d185 2 a219 1 ONCE_DECL(ppp_compressor_mtx_init); d224 1 d236 10 a245 1 extern struct linesw ppp_disc; d253 12 a264 1 RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d1824 8 a1898 2 RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d1939 71 @ 1.152.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $ */ d105 3 a107 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.158 2016/10/02 14:17:07 christos Exp $"); d1563 1 a1563 1 mp->m_next = m_free(m); @ 1.151 log @Constify rtentry of if_output We no longer need to change rtentry below if_output. The change makes it clear where rtentries are changed (or not) and helps forthcoming locking (os psrefing) rtentries. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.150 2016/04/20 09:01:04 knakahara Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.150 2016/04/20 09:01:04 knakahara Exp $"); d1603 1 a1603 1 m->m_pkthdr.rcvif = ifp; @ 1.150 log @IFQ_ENQUEUE refactor (3/3) : eliminate pktattr argument from IFQ_ENQUEUE caller @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.149 2015/08/24 22:21:26 pooka Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.149 2015/08/24 22:21:26 pooka Exp $"); d842 1 a842 1 struct rtentry *rtp) @ 1.149 log @sprinkle _KERNEL_OPT @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.148 2015/08/20 11:18:53 uebayasi Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.148 2015/08/20 11:18:53 uebayasi Exp $"); a853 1 ALTQ_DECL(struct altq_pktattr pktattr;) d861 1 a861 1 IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); d993 1 a993 2 if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { d1046 1 a1046 2 if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA ALTQ_DECL(NULL))) != 0) { @ 1.148 log @Honor pseudo attach decl generated by config(1). @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d109 1 d113 1 @ 1.147 log @Introduce p2p_rtrequest() so that IFF_POINTOPOINT interfaces can work with RTF_LOCAL. Fixes PR kern/49829. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146 2014/07/01 15:03:58 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146 2014/07/01 15:03:58 msaitoh Exp $"); d168 2 d229 1 a229 1 pppattach(void) @ 1.146 log @KNF. No functional change. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.145 2014/06/30 12:56:51 ozaki-r Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.145 2014/06/30 12:56:51 ozaki-r Exp $"); d770 1 @ 1.146.4.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.147 2015/04/20 10:19:54 roy Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.147 2015/04/20 10:19:54 roy Exp $"); a769 1 ifa->ifa_rtrequest = p2p_rtrequest; @ 1.146.4.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146.4.1 2015/06/06 14:40:25 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146.4.1 2015/06/06 14:40:25 skrll Exp $"); a108 1 #ifdef _KERNEL_OPT a111 1 #endif a167 2 #include "ioconf.h" d227 1 a227 1 pppattach(int n __unused) d303 1 a303 1 sc->sc_maxfastq = 2; d1670 1 a1670 1 #ifdef GATEWAY @ 1.146.4.3 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146.4.2 2015/09/22 12:06:10 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146.4.2 2015/09/22 12:06:10 skrll Exp $"); d854 1 d862 1 a862 1 IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family); d994 2 a995 1 if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) { d1048 2 a1049 1 if ((error = ifq_enqueue2(&sc->sc_if, ifq, m)) != 0) { @ 1.146.4.4 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146.4.3 2016/04/22 15:44:17 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146.4.3 2016/04/22 15:44:17 skrll Exp $"); d842 1 a842 1 const struct rtentry *rtp) @ 1.146.4.5 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146.4.4 2016/05/29 08:44:38 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146.4.4 2016/05/29 08:44:38 skrll Exp $"); d1603 1 a1603 1 m_set_rcvif(m, ifp); @ 1.146.4.6 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146.4.5 2016/07/09 20:25:21 skrll Exp $ */ d105 3 a107 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146.4.5 2016/07/09 20:25:21 skrll Exp $"); a109 1 #include "ppp.h" a135 2 #include #include a183 2 extern struct linesw ppp_disc; d217 1 a221 1 static int ppp_compressor_destroy(void); d233 1 a233 12 /* * Nothing to do here, initialization is handled by the * module initialization code in pppinit() below). */ } static void pppinit(void) { /* Init the compressor sub-sub-system */ ppp_compressor_init(); d236 1 a236 1 panic("%s", __func__); d241 1 a241 20 } static int pppdetach(void) { int error = 0; if (!LIST_EMPTY(&ppp_softc_list)) error = EBUSY; if (error == 0) error = ttyldisc_detach(&ppp_disc); if (error == 0) { mutex_destroy(&ppp_list_lock); if_clone_detach(&ppp_cloner); ppp_compressor_destroy(); } return error; d1563 1 a1563 1 mp->m_next = m_free(m); a1800 8 static int ppp_compressor_destroy(void) { mutex_destroy(&ppp_compressors_mtx); return 0; } d1868 2 a1909 13 /* * Module infrastructure */ #include "if_module.h" #ifdef PPP_FILTER #define PPP_DEP "bpf_filter," #else #define PPP_DEP #endif IF_MODULE(MODULE_CLASS_DRIVER, ppp, PPP_DEP "slcompress") @ 1.145 log @Cleanup ppp_inproc - Remove unnecessary variable isr - Use pktq instead of rv to switch between inet/inet6 and other protocols ok msaitoh@@ and rmind@@ @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.144 2014/06/05 23:48:16 rmind Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.144 2014/06/05 23:48:16 rmind Exp $"); d185 2 a186 2 #define M_DATASTART(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \ d189 2 a190 2 #define M_DATASIZE(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \ d201 2 a202 2 static int ppp_clone_create(struct if_clone *, int); static int ppp_clone_destroy(struct ifnet *); d229 1 a229 1 extern struct linesw ppp_disc; d231 2 a232 2 if (ttyldisc_attach(&ppp_disc) != 0) panic("pppattach"); d234 4 a237 4 mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softc_list); if_clone_attach(&ppp_cloner); RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d243 1 a243 1 struct ppp_softc *sc, *sci, *scl = NULL; d245 1 a245 1 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d247 9 a255 9 mutex_enter(&ppp_list_lock); if (unit == -1) { int i = 0; LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (i < sci->sc_unit) { unit = i; break; } else { d257 1 a257 1 KASSERT(i == sci->sc_unit); d259 15 a273 2 i++; } a274 13 if (unit == -1) unit = i; } else { LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (unit < sci->sc_unit) break; else if (unit == sci->sc_unit) { free(sc, M_DEVBUF); return NULL; } } } d276 19 a294 19 if (sci != NULL) LIST_INSERT_BEFORE(sci, sc, sc_iflist); else if (scl != NULL) LIST_INSERT_AFTER(scl, sc, sc_iflist); else LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist); mutex_exit(&ppp_list_lock); if_initname(&sc->sc_if, name, sc->sc_unit = unit); callout_init(&sc->sc_timo_ch, 0); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; d296 1 a296 1 sc->sc_if.if_start = ppp_ifstart; d298 11 a308 11 IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; /* Ratio of 1:2 packets between the regular and the fast queue */ sc->sc_maxfastq = 2; IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, 0); return sc; d314 1 a314 1 return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0; d320 1 a320 1 struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc; d322 2 a323 2 if (sc->sc_devp != NULL) return EBUSY; /* Not removing it */ d325 3 a327 3 mutex_enter(&ppp_list_lock); LIST_REMOVE(sc, sc_iflist); mutex_exit(&ppp_list_lock); d329 2 a330 2 bpf_detach(ifp); if_detach(ifp); d332 2 a333 2 free(sc, M_DEVBUF); return 0; d342 2 a343 2 struct ppp_softc *sc = NULL, *scf; int i; d345 25 a369 24 mutex_enter(&ppp_list_lock); LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) { if (scf->sc_xfer == pid) { scf->sc_xfer = 0; mutex_exit(&ppp_list_lock); return scf; } if (scf->sc_devp == NULL && sc == NULL) sc = scf; } mutex_exit(&ppp_list_lock); if (sc == NULL) sc = ppp_create(ppp_cloner.ifc_name, -1); sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); if (sc->sc_si == NULL) { printf("%s: unable to establish softintr\n", sc->sc_if.if_xname); return (NULL); } sc->sc_flags = 0; sc->sc_mru = PPP_MRU; sc->sc_relinq = NULL; (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats)); d371 3 a373 3 sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); if (sc->sc_comp) sl_compress_init(sc->sc_comp); d376 2 a377 2 sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; d379 5 a383 5 for (i = 0; i < NUM_NP; ++i) sc->sc_npmode[i] = NPMODE_ERROR; sc->sc_npqueue = NULL; sc->sc_npqtail = &sc->sc_npqueue; sc->sc_last_sent = sc->sc_last_recv = time_second; d385 1 a385 1 return sc; d394 1 a394 1 struct mbuf *m; d396 31 a426 31 softint_disestablish(sc->sc_si); if_down(&sc->sc_if); sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); sc->sc_devp = NULL; sc->sc_xfer = 0; for (;;) { IF_DEQUEUE(&sc->sc_rawq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_inq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) break; m_freem(m); } while ((m = sc->sc_npqueue) != NULL) { sc->sc_npqueue = m->m_nextpkt; m_freem(m); } if (sc->sc_togo != NULL) { m_freem(sc->sc_togo); sc->sc_togo = NULL; } d428 3 a430 3 ppp_ccp_closed(sc); sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; d433 20 a452 20 if (sc->sc_pass_filt_in.bf_insns != 0) { free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); sc->sc_pass_filt_in.bf_insns = 0; sc->sc_pass_filt_in.bf_len = 0; } if (sc->sc_pass_filt_out.bf_insns != 0) { free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); sc->sc_pass_filt_out.bf_insns = 0; sc->sc_pass_filt_out.bf_len = 0; } if (sc->sc_active_filt_in.bf_insns != 0) { free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); sc->sc_active_filt_in.bf_insns = 0; sc->sc_active_filt_in.bf_len = 0; } if (sc->sc_active_filt_out.bf_insns != 0) { free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); sc->sc_active_filt_out.bf_insns = 0; sc->sc_active_filt_out.bf_len = 0; } d455 4 a458 4 if (sc->sc_comp != 0) { free(sc->sc_comp, M_DEVBUF); sc->sc_comp = 0; } d460 1 a460 1 (void)ppp_clone_destroy(&sc->sc_if); d470 6 a475 6 int s, error, flags, mru, npx; u_int nb; struct ppp_option_data *odp; struct compressor *cp; struct npioctl *npi; time_t t; d477 3 a479 3 struct bpf_program *bp, *nbp; struct bpf_insn *newcode, *oldcode; int newcodelen; d482 1 a482 1 u_char ccp_option[CCP_MAX_OPTION_LENGTH]; d485 21 a505 21 switch (cmd) { case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return (EPERM); break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return (EPERM); break; default: break; } d507 4 a510 4 switch (cmd) { case FIONREAD: *(int *)data = sc->sc_inq.ifq_len; break; d512 3 a514 3 case PPPIOCGUNIT: *(int *)data = sc->sc_unit; break; d516 3 a518 3 case PPPIOCGFLAGS: *(u_int *)data = sc->sc_flags; break; d520 1 a520 1 case PPPIOCGRAWIN: d522 2 a523 2 struct ppp_rawin *rwin = (struct ppp_rawin *)data; u_char c, q = 0; d525 2 a526 2 for (c = sc->sc_rawin_start; c < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d528 2 a529 2 for (c = 0; c < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d531 1 a531 1 rwin->count = sc->sc_rawin.count; d535 3 a537 3 case PPPIOCSFLAGS: flags = *(int *)data & SC_MASK; s = splsoftnet(); d539 2 a540 2 if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN)) ppp_ccp_closed(sc); d542 4 a545 4 splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags; splx(s); break; d547 5 a551 5 case PPPIOCSMRU: mru = *(int *)data; if (mru >= PPP_MINMRU && mru <= PPP_MAXMRU) sc->sc_mru = mru; break; d553 3 a555 3 case PPPIOCGMRU: *(int *)data = sc->sc_mru; break; d558 7 a564 7 case PPPIOCSMAXCID: if (sc->sc_comp) { s = splsoftnet(); sl_compress_setup(sc->sc_comp, *(int *)data); splx(s); } break; d567 3 a569 3 case PPPIOCXFERUNIT: sc->sc_xfer = l->l_proc->p_pid; break; d572 59 a630 58 case PPPIOCSCOMPRESS: odp = (struct ppp_option_data *) data; nb = odp->length; if (nb > sizeof(ccp_option)) nb = sizeof(ccp_option); if ((error = copyin(odp->ptr, ccp_option, nb)) != 0) return (error); if (ccp_option[1] < 2) /* preliminary check on the length byte */ return (EINVAL); cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); } sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); d633 25 a657 22 case PPPIOCGNPMODE: case PPPIOCSNPMODE: npi = (struct npioctl *) data; switch (npi->protocol) { case PPP_IP: npx = NP_IP; break; case PPP_IPV6: npx = NP_IPV6; break; default: return EINVAL; } if (cmd == PPPIOCGNPMODE) { npi->mode = sc->sc_npmode[npx]; } else { if (npi->mode != sc->sc_npmode[npx]) { s = splnet(); sc->sc_npmode[npx] = npi->mode; if (npi->mode != NPMODE_QUEUE) { ppp_requeue(sc); ppp_restart(sc); d659 7 d667 1 a667 3 } } break; d669 5 a673 7 case PPPIOCGIDLE: s = splsoftnet(); t = time_second; ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent; ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv; splx(s); break; a674 29 #ifdef PPP_FILTER case PPPIOCSPASS: case PPPIOCSACTIVE: /* These are no longer supported. */ return EOPNOTSUPP; case PPPIOCSIPASS: case PPPIOCSOPASS: case PPPIOCSIACTIVE: case PPPIOCSOACTIVE: nbp = (struct bpf_program *) data; if ((unsigned) nbp->bf_len > BPF_MAXINSNS) return EINVAL; newcodelen = nbp->bf_len * sizeof(struct bpf_insn); if (newcodelen != 0) { newcode = malloc(newcodelen, M_DEVBUF, M_WAITOK); /* WAITOK -- malloc() never fails. */ if ((error = copyin((void *)nbp->bf_insns, (void *)newcode, newcodelen)) != 0) { free(newcode, M_DEVBUF); return error; } if (!bpf_validate(newcode, nbp->bf_len)) { free(newcode, M_DEVBUF); return EINVAL; } } else newcode = 0; switch (cmd) { d676 29 a704 2 bp = &sc->sc_pass_filt_in; break; d706 3 a708 3 case PPPIOCSOPASS: bp = &sc->sc_pass_filt_out; break; d710 16 a725 3 case PPPIOCSIACTIVE: bp = &sc->sc_active_filt_in; break; a726 3 case PPPIOCSOACTIVE: bp = &sc->sc_active_filt_out; break; d728 1 a728 2 free(newcode, M_DEVBUF); return (EPASSTHROUGH); d730 1 a730 14 oldcode = bp->bf_insns; s = splnet(); bp->bf_len = nbp->bf_len; bp->bf_insns = newcode; splx(s); if (oldcode != 0) free(oldcode, M_DEVBUF); break; #endif /* PPP_FILTER */ default: return (EPASSTHROUGH); } return (0); d739 4 a742 4 struct ppp_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; d744 1 a744 1 struct ppp_comp_stats *pcp; d746 1 a746 1 int s = splnet(), error = 0; d748 6 a753 3 switch (cmd) { case SIOCSIFFLAGS: if ((error = ifioctl_common(ifp, cmd, data)) != 0) a754 3 if ((ifp->if_flags & IFF_RUNNING) == 0) ifp->if_flags &= ~IFF_UP; break; d756 2 a757 2 case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { d759 2 a760 2 case AF_INET: break; d763 2 a764 2 case AF_INET6: break; d766 5 a770 5 default: error = EAFNOSUPPORT; break; } break; d772 7 a778 7 case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { error = EAFNOSUPPORT; break; } switch (ifreq_getaddr(cmd, ifr)->sa_family) { d780 2 a781 2 case AF_INET: break; d784 2 a785 2 case AF_INET6: break; d787 5 a791 5 default: error = EAFNOSUPPORT; break; } break; d793 4 a796 4 case SIOCGPPPSTATS: psp = &((struct ifpppstatsreq *) data)->stats; memset(psp, 0, sizeof(*psp)); psp->p = sc->sc_stats; d798 10 a807 10 if (sc->sc_comp) { psp->vj.vjs_packets = sc->sc_comp->sls_packets; psp->vj.vjs_compressed = sc->sc_comp->sls_compressed; psp->vj.vjs_searches = sc->sc_comp->sls_searches; psp->vj.vjs_misses = sc->sc_comp->sls_misses; psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin; psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin; psp->vj.vjs_errorin = sc->sc_comp->sls_errorin; psp->vj.vjs_tossed = sc->sc_comp->sls_tossed; } d809 1 a809 1 break; d812 8 a819 8 case SIOCGPPPCSTATS: pcp = &((struct ifpppcstatsreq *) data)->stats; memset(pcp, 0, sizeof(*pcp)); if (sc->sc_xc_state != NULL) (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c); if (sc->sc_rc_state != NULL) (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d); break; d822 7 a828 7 default: if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; } splx(s); return (error); d839 4 a842 4 struct ppp_softc *sc = ifp->if_softc; int protocol, address, control; u_char *cp; int s, error; d844 1 a844 1 struct ip *ip; d846 12 a857 24 struct ifqueue *ifq; enum NPmode mode; int len; ALTQ_DECL(struct altq_pktattr pktattr;) if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { error = ENETDOWN; /* sort of */ goto bad; } IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); /* * Compute PPP header. */ m0->m_flags &= ~M_HIGHPRI; switch (dst->sa_family) { #ifdef INET case AF_INET: address = PPP_ALLSTATIONS; control = PPP_UI; protocol = PPP_IP; mode = sc->sc_npmode[NP_IP]; d860 1 a860 2 * If this packet has the "low delay" bit set in the IP header, * put it on the fastq instead. d862 17 a878 4 ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; break; d881 5 a885 5 case AF_INET6: address = PPP_ALLSTATIONS; /*XXX*/ control = PPP_UI; /*XXX*/ protocol = PPP_IPV6; mode = sc->sc_npmode[NP_IPV6]; d892 3 a894 3 ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; d896 1 a896 1 break; d898 12 a909 45 case AF_UNSPEC: address = PPP_ADDRESS(dst->sa_data); control = PPP_CONTROL(dst->sa_data); protocol = PPP_PROTOCOL(dst->sa_data); mode = NPMODE_PASS; break; default: printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); error = EAFNOSUPPORT; goto bad; } /* * Drop this packet, or return an error, if necessary. */ if (mode == NPMODE_ERROR) { error = ENETDOWN; goto bad; } if (mode == NPMODE_DROP) { error = 0; goto bad; } /* * Add PPP header. */ M_PREPEND(m0, PPP_HDRLEN, M_DONTWAIT); if (m0 == NULL) { error = ENOBUFS; goto bad; } cp = mtod(m0, u_char *); *cp++ = address; *cp++ = control; *cp++ = protocol >> 8; *cp++ = protocol & 0xff; len = m_length(m0); if (sc->sc_flags & SC_LOG_OUTPKT) { printf("%s output: ", ifp->if_xname); pppdumpm(m0); } a910 2 if ((protocol & 0x8000) == 0) { #ifdef PPP_FILTER d912 1 a912 2 * Apply the pass and active filters to the packet, * but only if it is a data packet. d914 7 a920 5 if (sc->sc_pass_filt_out.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *)m0, len, 0) == 0) { error = 0; /* drop this packet */ goto bad; d924 1 a924 1 * Update the time we sent the most recent packet. d926 39 a964 4 if (sc->sc_active_filt_out.bf_insns == 0 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *)m0, len, 0)) sc->sc_last_sent = time_second; d966 7 d974 1 a974 1 * Update the time we sent the most recent packet. d976 1 a976 3 sc->sc_last_sent = time_second; #endif /* PPP_FILTER */ } d978 22 a999 27 /* * See if bpf wants to look at the packet. */ bpf_mtap(&sc->sc_if, m0); /* * Put the packet on the appropriate queue. */ s = splnet(); if (mode == NPMODE_QUEUE) { /* XXX we should limit the number of packets on this queue */ *sc->sc_npqtail = m0; m0->m_nextpkt = NULL; sc->sc_npqtail = &m0->m_nextpkt; } else { ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { splx(s); sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; return (error); } ppp_restart(sc); } ifp->if_opackets++; ifp->if_obytes += len; d1001 2 a1002 2 splx(s); return (0); d1005 2 a1006 2 m_freem(m0); return (error); d1017 16 a1032 4 struct mbuf *m, **mpp; struct ifqueue *ifq; enum NPmode mode; int error; d1034 15 a1048 11 for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) { switch (PPP_PROTOCOL(mtod(m, u_char *))) { case PPP_IP: mode = sc->sc_npmode[NP_IP]; break; case PPP_IPV6: mode = sc->sc_npmode[NP_IPV6]; break; default: mode = NPMODE_PASS; } d1050 5 a1054 14 switch (mode) { case NPMODE_PASS: /* * This packet can now go on one of the queues to be sent. */ *mpp = m->m_nextpkt; m->m_nextpkt = NULL; ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA ALTQ_DECL(NULL))) != 0) { sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; } break; d1056 4 a1059 9 case NPMODE_DROP: case NPMODE_ERROR: *mpp = m->m_nextpkt; m_freem(m); break; case NPMODE_QUEUE: mpp = &m->m_nextpkt; break; d1061 1 a1061 2 } sc->sc_npqtail = mpp; d1071 1 a1071 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1073 3 a1075 3 sc->sc_flags &= ~SC_TBUSY; softint_schedule(sc->sc_si); splx(s); d1087 24 a1110 23 struct mbuf *m, *mp; u_char *cp; int address, control, protocol; int s; /* * Grab a packet to send: first try the fast queue, then the * normal queue. */ s = splnet(); if (sc->sc_nfastq < sc->sc_maxfastq) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; else IFQ_DEQUEUE(&sc->sc_if.if_snd, m); } else { sc->sc_nfastq = 0; IFQ_DEQUEUE(&sc->sc_if.if_snd, m); if (m == NULL) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; d1112 1 a1112 2 } splx(s); d1114 2 a1115 2 if (m == NULL) return NULL; d1117 1 a1117 1 ++sc->sc_stats.ppp_opackets; d1119 8 a1126 8 /* * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. */ cp = mtod(m, u_char *); address = PPP_ADDRESS(cp); control = PPP_CONTROL(cp); protocol = PPP_PROTOCOL(cp); d1128 2 a1129 2 switch (protocol) { case PPP_IP: d1131 37 a1167 30 /* * If the packet is a TCP/IP packet, see if we can compress it. */ if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) { struct ip *ip; int type; mp = m; ip = (struct ip *) (cp + PPP_HDRLEN); if (mp->m_len <= PPP_HDRLEN) { mp = mp->m_next; if (mp == NULL) break; ip = mtod(mp, struct ip *); } /* this code assumes the IP/TCP header is in one non-shared mbuf */ if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; cp = mtod(m, u_char *); cp[0] = address; /* header has moved */ cp[1] = control; cp[2] = 0; break; a1168 3 cp[3] = protocol; /* update protocol in PPP header */ } } d1170 1 a1170 1 break; d1173 3 a1175 3 case PPP_CCP: ppp_ccp(sc, m, 0); break; d1177 1 a1177 1 } d1180 28 a1207 21 if (protocol != PPP_LCP && protocol != PPP_CCP && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) { struct mbuf *mcomp = NULL; int slen; slen = 0; for (mp = m; mp != NULL; mp = mp->m_next) slen += mp->m_len; (*sc->sc_xcomp->compress) (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN); if (mcomp != NULL) { if (sc->sc_flags & SC_CCP_UP) { /* Send the compressed packet instead of the original. */ m_freem(m); m = mcomp; cp = mtod(m, u_char *); protocol = cp[3]; } else { /* Can't transmit compressed packets until CCP is up. */ m_freem(mcomp); } a1208 1 } d1211 19 a1229 19 /* * Compress the address/control and protocol, if possible. */ if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS && control == PPP_UI && protocol != PPP_ALLSTATIONS && protocol != PPP_LCP) { /* can compress address/control */ m->m_data += 2; m->m_len -= 2; } if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) { /* can compress protocol */ if (mtod(m, u_char *) == cp) { cp[2] = cp[1]; /* move address/control up */ cp[1] = cp[0]; } ++m->m_data; --m->m_len; } d1231 1 a1231 1 return m; d1266 1 a1266 1 * Handle a CCP packet. `rcvd' is 1 if the packet was received, d1272 3 a1274 16 u_char *dp, *ep; struct mbuf *mp; int slen, s; /* * Get a pointer to the data after the PPP header. */ if (m->m_len <= PPP_HDRLEN) { mp = m->m_next; if (mp == NULL) return; dp = mtod(mp, u_char *); } else { mp = m; dp = mtod(mp, u_char *) + PPP_HDRLEN; } d1276 12 a1287 10 ep = mtod(mp, u_char *) + mp->m_len; if (dp + CCP_HDRLEN > ep) return; slen = CCP_LENGTH(dp); if (dp + slen > ep) { if (sc->sc_flags & SC_DEBUG) printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n", dp, slen, mtod(mp, u_char *), mp->m_len); return; } d1289 9 a1297 9 switch (CCP_CODE(dp)) { case CCP_CONFREQ: case CCP_TERMREQ: case CCP_TERMACK: /* CCP must be going down - disable compression */ if (sc->sc_flags & SC_CCP_UP) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN); splx(s); a1298 1 break; d1300 9 a1308 25 case CCP_CONFACK: if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP) && slen >= CCP_HDRLEN + CCP_OPT_MINLEN && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) { if (!rcvd) { /* we're agreeing to send compressed packets. */ if (sc->sc_xc_state != NULL && (*sc->sc_xcomp->comp_init) (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_COMP_RUN; splx(s); } } else { /* peer is agreeing to send compressed packets. */ if (sc->sc_rc_state != NULL && (*sc->sc_rcomp->decomp_init) (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_mru, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_DECOMP_RUN; sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR); splx(s); d1310 35 a1344 3 } } break; d1346 13 a1358 11 case CCP_RESETACK: if (sc->sc_flags & SC_CCP_UP) { if (!rcvd) { if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state); } else { if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) { (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DC_ERROR; splx(s); d1360 1 a1360 1 } a1361 2 break; } d1370 10 a1379 10 if (sc->sc_xc_state) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); sc->sc_xc_state = NULL; } if (sc->sc_rc_state) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); sc->sc_rc_state = NULL; } d1392 1 a1392 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1394 5 a1398 5 if (lost) m->m_flags |= M_ERRMARK; IF_ENQUEUE(&sc->sc_rawq, m); softint_schedule(sc->sc_si); splx(s); d1405 2 a1406 2 #define COMPTYPE(proto) ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \ TYPE_UNCOMPRESSED_TCP) d1411 6 a1416 6 struct ifnet *ifp = &sc->sc_if; pktqueue_t *pktq = NULL; struct ifqueue *inq = NULL; int s, ilen, proto, rv; u_char *cp, adrs, ctrl; struct mbuf *mp, *dmp = NULL; d1418 3 a1420 3 int xlen; u_char *iphdr; u_int hlen; d1423 9 a1431 1 sc->sc_stats.ppp_ipackets++; d1433 11 a1443 19 if (sc->sc_flags & SC_LOG_INPKT) { ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; printf("%s: got %d bytes\n", ifp->if_xname, ilen); pppdumpm(m); } cp = mtod(m, u_char *); adrs = PPP_ADDRESS(cp); ctrl = PPP_CONTROL(cp); proto = PPP_PROTOCOL(cp); if (m->m_flags & M_ERRMARK) { m->m_flags &= ~M_ERRMARK; s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; splx(s); } d1446 38 a1483 17 /* * Decompress this packet if necessary, update the receiver's * dictionary, or take appropriate action on a CCP packet. */ if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN) && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) { /* decompress this packet */ rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp); if (rv == DECOMP_OK) { m_freem(m); if (dmp == NULL) { /* no error, but no decompressed packet produced */ return; } m = dmp; cp = mtod(m, u_char *); proto = PPP_PROTOCOL(cp); d1486 10 a1495 29 /* * An error has occurred in decompression. * Pass the compressed packet up to pppd, which may take * CCP down or issue a Reset-Req. */ if (sc->sc_flags & SC_DEBUG) printf("%s: decompress failed %d\n", ifp->if_xname, rv); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; if (rv == DECOMP_ERROR) sc->sc_flags |= SC_DC_ERROR; else sc->sc_flags |= SC_DC_FERROR; splx(s); } } else { if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) { (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m); } if (proto == PPP_CCP) { ppp_ccp(sc, m, 1); } } #endif ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; d1498 12 a1509 1 if (sc->sc_flags & SC_VJ_RESET) { d1511 1 a1511 2 * If we've missed a packet, we must toss subsequent compressed * packets which don't have an explicit connection ID. d1513 68 a1580 6 if (sc->sc_comp) sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_VJ_RESET; splx(s); } d1582 2 a1583 30 /* * See if we have a VJ-compressed packet to uncompress. */ if (proto == PPP_VJC_COMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen <= 0) { if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type comp\n", ifp->if_xname); goto bad; } /* Copy the PPP and IP headers into a new mbuf. */ MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp == NULL) goto bad; mp->m_len = 0; mp->m_next = NULL; if (hlen + PPP_HDRLEN > MHLEN) { MCLGET(mp, M_DONTWAIT); if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) { m_freem(mp); goto bad; /* lose if big headers and no clusters */ } d1585 1 a1585 8 cp = mtod(mp, u_char *); cp[0] = adrs; cp[1] = ctrl; cp[2] = 0; cp[3] = PPP_IP; proto = PPP_IP; bcopy(iphdr, cp + PPP_HDRLEN, hlen); mp->m_len = hlen + PPP_HDRLEN; d1588 2 a1589 2 * Trim the PPP and VJ headers off the old mbuf * and stick the new and old mbufs together. d1591 11 a1601 30 m->m_data += PPP_HDRLEN + xlen; m->m_len -= PPP_HDRLEN + xlen; if (m->m_len <= M_TRAILINGSPACE(mp)) { bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len); mp->m_len += m->m_len; MFREE(m, mp->m_next); } else mp->m_next = m; m = mp; ilen += hlen - xlen; } else if (proto == PPP_VJC_UNCOMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen < 0) { if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type uncomp\n", ifp->if_xname); goto bad; } proto = PPP_IP; cp[3] = PPP_IP; } #endif /* VJC */ d1603 1 a1603 17 /* * If the packet will fit in a header mbuf, don't waste a * whole cluster on it. */ if (ilen <= MHLEN && M_IS_CLUSTER(m)) { MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp != NULL) { m_copydata(m, 0, ilen, mtod(mp, void *)); m_freem(m); m = mp; m->m_len = ilen; } } m->m_pkthdr.len = ilen; m->m_pkthdr.rcvif = ifp; if ((proto & 0x8000) == 0) { d1605 15 a1619 15 /* * See whether we want to pass this packet, and * if it counts as link activity. */ if (sc->sc_pass_filt_in.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *)m, ilen, 0) == 0) { /* drop this packet */ m_freem(m); return; } if (sc->sc_active_filt_in.bf_insns == 0 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *)m, ilen, 0)) sc->sc_last_recv = time_second; d1621 4 a1624 4 /* * Record the time that we received this packet. */ sc->sc_last_recv = time_second; d1626 1 a1626 1 } d1628 2 a1629 2 /* See if bpf wants to look at the packet. */ bpf_mtap(&sc->sc_if, m); d1631 1 a1631 1 switch (proto) { d1633 13 a1645 13 case PPP_IP: /* * IP packet - take off the ppp header and pass it up to IP. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IP] != NPMODE_PASS) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; d1647 2 a1648 2 if (ipflow_fastforward(m)) return; d1650 2 a1651 2 pktq = ip_pktq; break; d1655 17 a1671 16 case PPP_IPV6: /* * IPv6 packet - take off the ppp header and pass it up to IPv6. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; #ifdef GATEWAY if (ip6flow_fastforward(&m)) return; d1673 2 a1674 2 pktq = ip6_pktq; break; d1677 9 a1685 1 default: d1687 1 a1687 1 * Some other protocol - place on input queue for read(). d1689 13 a1701 4 inq = &sc->sc_inq; pktq = NULL; break; } d1703 11 a1713 10 /* * Put the packet on the appropriate input queue. */ s = splnet(); /* pktq: inet or inet6 cases */ if (__predict_true(pktq)) { if (__predict_false(!pktq_enqueue(pktq, m, 0))) { ifp->if_iqdrops++; goto bad; d1715 2 d1719 3 a1721 1 splx(s); a1722 1 } d1724 4 a1727 25 /* ifq: other protocol cases */ if (!inq) { goto bad; } if (IF_QFULL(inq)) { IF_DROP(inq); splx(s); if (sc->sc_flags & SC_DEBUG) printf("%s: input queue full\n", ifp->if_xname); ifp->if_iqdrops++; goto bad; } IF_ENQUEUE(inq, m); splx(s); ifp->if_ipackets++; ifp->if_ibytes += ilen; (*sc->sc_ctlp)(sc); return; bad: m_freem(m); sc->sc_if.if_ierrors++; sc->sc_stats.ppp_ierrors++; d1735 23 a1757 22 char buf[3*MAX_DUMP_BYTES+4]; char *bp = buf; struct mbuf *m; for (m = m0; m; m = m->m_next) { int l = m->m_len; u_char *rptr = (u_char *)m->m_data; while (l--) { if (bp > buf + sizeof(buf) - 4) goto done; *bp++ = hexdigits[*rptr >> 4]; /* convert byte to ascii hex */ *bp++ = hexdigits[*rptr++ & 0xf]; } if (m->m_next) { if (bp > buf + sizeof(buf) - 3) goto done; *bp++ = '|'; } else *bp++ = ' '; } d1759 4 a1762 4 if (m) *bp++ = '>'; *bp = 0; printf("%s\n", buf); d1767 1 a1767 1 * a wrapper to transmit a packet from if_start since ALTQ uses d1846 1 a1846 1 MODULE_CLASS_MISC) != 0) d1871 1 a1871 1 false) != NULL) d1894 1 a1894 1 false) != &pc[i]) @ 1.144 log @- Implement pktqueue interface for lockless IP input queue. - Replace ipintrq and ip6intrq with the pktqueue mechanism. - Eliminate kernel-lock from ipintr() and ip6intr(). - Some preparation work to push softnet_lock out of ipintr(). Discussed on tech-net. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.143 2014/05/17 14:51:09 rmind Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.143 2014/05/17 14:51:09 rmind Exp $"); a1398 1 int isr = 0; a1608 1 rv = 0; d1659 1 a1659 1 rv = 1; d1668 1 a1676 2 if (rv) (*sc->sc_ctlp)(sc); d1680 1 a1692 3 if (__predict_true(isr)) { schednetisr(isr); } d1697 1 a1697 2 if (rv) (*sc->sc_ctlp)(sc); @ 1.143 log @ppp_inproc: handle non-IP protocols correctly (hi msaitoh); PR/48813. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.142 2014/05/15 09:23:03 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.142 2014/05/15 09:23:03 msaitoh Exp $"); d1394 2 a1395 1 struct ifqueue *inq; d1630 1 a1630 2 isr = NETISR_IP; inq = &ipintrq; d1652 1 a1652 2 isr = NETISR_IPV6; inq = &ip6intrq; d1669 17 @ 1.142 log @ Save a NETISR_* value in a variable and call schednetisr() after enqueue a packet for readability and future modification. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.141 2013/09/18 23:34:55 rmind Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.141 2013/09/18 23:34:55 rmind Exp $"); d1679 3 a1681 1 schednetisr(isr); @ 1.141 log @Add bpf_filter_ext() to use with BPF COP, restore bpf_filter() as it was originally to preserve compatibility. Similarly, add bpf_validate_ext() which takes bpf_ctx_t. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.140 2013/08/30 15:00:08 rmind Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.140 2013/08/30 15:00:08 rmind Exp $"); d1398 1 d1629 1 a1629 1 schednetisr(NETISR_IP); d1652 1 a1652 1 schednetisr(NETISR_IPV6); d1679 1 @ 1.141.2.1 log @Rebase. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.146 2014/07/01 15:03:58 msaitoh Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146 2014/07/01 15:03:58 msaitoh Exp $"); d185 2 a186 2 #define M_DATASTART(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \ d189 2 a190 2 #define M_DATASIZE(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \ d201 2 a202 2 static int ppp_clone_create(struct if_clone *, int); static int ppp_clone_destroy(struct ifnet *); d229 1 a229 1 extern struct linesw ppp_disc; d231 2 a232 2 if (ttyldisc_attach(&ppp_disc) != 0) panic("pppattach"); d234 4 a237 4 mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softc_list); if_clone_attach(&ppp_cloner); RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d243 1 a243 1 struct ppp_softc *sc, *sci, *scl = NULL; d245 1 a245 1 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d247 9 a255 9 mutex_enter(&ppp_list_lock); if (unit == -1) { int i = 0; LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (i < sci->sc_unit) { unit = i; break; } else { d257 1 a257 1 KASSERT(i == sci->sc_unit); d259 14 a272 15 i++; } } if (unit == -1) unit = i; } else { LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (unit < sci->sc_unit) break; else if (unit == sci->sc_unit) { free(sc, M_DEVBUF); return NULL; } } d274 1 d276 19 a294 19 if (sci != NULL) LIST_INSERT_BEFORE(sci, sc, sc_iflist); else if (scl != NULL) LIST_INSERT_AFTER(scl, sc, sc_iflist); else LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist); mutex_exit(&ppp_list_lock); if_initname(&sc->sc_if, name, sc->sc_unit = unit); callout_init(&sc->sc_timo_ch, 0); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; d296 1 a296 1 sc->sc_if.if_start = ppp_ifstart; d298 11 a308 11 IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; /* Ratio of 1:2 packets between the regular and the fast queue */ sc->sc_maxfastq = 2; IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, 0); return sc; d314 1 a314 1 return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0; d320 1 a320 1 struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc; d322 2 a323 2 if (sc->sc_devp != NULL) return EBUSY; /* Not removing it */ d325 3 a327 3 mutex_enter(&ppp_list_lock); LIST_REMOVE(sc, sc_iflist); mutex_exit(&ppp_list_lock); d329 2 a330 2 bpf_detach(ifp); if_detach(ifp); d332 2 a333 2 free(sc, M_DEVBUF); return 0; d342 2 a343 2 struct ppp_softc *sc = NULL, *scf; int i; d345 24 a368 25 mutex_enter(&ppp_list_lock); LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) { if (scf->sc_xfer == pid) { scf->sc_xfer = 0; mutex_exit(&ppp_list_lock); return scf; } if (scf->sc_devp == NULL && sc == NULL) sc = scf; } mutex_exit(&ppp_list_lock); if (sc == NULL) sc = ppp_create(ppp_cloner.ifc_name, -1); sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); if (sc->sc_si == NULL) { printf("%s: unable to establish softintr\n", sc->sc_if.if_xname); return (NULL); } sc->sc_flags = 0; sc->sc_mru = PPP_MRU; sc->sc_relinq = NULL; (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats)); d370 3 a372 3 sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); if (sc->sc_comp) sl_compress_init(sc->sc_comp); d375 2 a376 2 sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; d378 5 a382 5 for (i = 0; i < NUM_NP; ++i) sc->sc_npmode[i] = NPMODE_ERROR; sc->sc_npqueue = NULL; sc->sc_npqtail = &sc->sc_npqueue; sc->sc_last_sent = sc->sc_last_recv = time_second; d384 1 a384 1 return sc; d393 1 a393 1 struct mbuf *m; d395 31 a425 31 softint_disestablish(sc->sc_si); if_down(&sc->sc_if); sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); sc->sc_devp = NULL; sc->sc_xfer = 0; for (;;) { IF_DEQUEUE(&sc->sc_rawq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_inq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) break; m_freem(m); } while ((m = sc->sc_npqueue) != NULL) { sc->sc_npqueue = m->m_nextpkt; m_freem(m); } if (sc->sc_togo != NULL) { m_freem(sc->sc_togo); sc->sc_togo = NULL; } d427 3 a429 3 ppp_ccp_closed(sc); sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; d432 20 a451 20 if (sc->sc_pass_filt_in.bf_insns != 0) { free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); sc->sc_pass_filt_in.bf_insns = 0; sc->sc_pass_filt_in.bf_len = 0; } if (sc->sc_pass_filt_out.bf_insns != 0) { free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); sc->sc_pass_filt_out.bf_insns = 0; sc->sc_pass_filt_out.bf_len = 0; } if (sc->sc_active_filt_in.bf_insns != 0) { free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); sc->sc_active_filt_in.bf_insns = 0; sc->sc_active_filt_in.bf_len = 0; } if (sc->sc_active_filt_out.bf_insns != 0) { free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); sc->sc_active_filt_out.bf_insns = 0; sc->sc_active_filt_out.bf_len = 0; } d454 4 a457 4 if (sc->sc_comp != 0) { free(sc->sc_comp, M_DEVBUF); sc->sc_comp = 0; } d459 1 a459 1 (void)ppp_clone_destroy(&sc->sc_if); d469 6 a474 6 int s, error, flags, mru, npx; u_int nb; struct ppp_option_data *odp; struct compressor *cp; struct npioctl *npi; time_t t; d476 3 a478 3 struct bpf_program *bp, *nbp; struct bpf_insn *newcode, *oldcode; int newcodelen; d481 1 a481 1 u_char ccp_option[CCP_MAX_OPTION_LENGTH]; d484 21 a504 21 switch (cmd) { case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return (EPERM); break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return (EPERM); break; default: break; } d506 4 a509 4 switch (cmd) { case FIONREAD: *(int *)data = sc->sc_inq.ifq_len; break; d511 3 a513 3 case PPPIOCGUNIT: *(int *)data = sc->sc_unit; break; d515 3 a517 3 case PPPIOCGFLAGS: *(u_int *)data = sc->sc_flags; break; d519 1 a519 1 case PPPIOCGRAWIN: d521 2 a522 2 struct ppp_rawin *rwin = (struct ppp_rawin *)data; u_char c, q = 0; d524 2 a525 2 for (c = sc->sc_rawin_start; c < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d527 2 a528 2 for (c = 0; c < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d530 1 a530 1 rwin->count = sc->sc_rawin.count; d534 3 a536 3 case PPPIOCSFLAGS: flags = *(int *)data & SC_MASK; s = splsoftnet(); d538 2 a539 2 if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN)) ppp_ccp_closed(sc); d541 4 a544 4 splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags; splx(s); break; d546 5 a550 5 case PPPIOCSMRU: mru = *(int *)data; if (mru >= PPP_MINMRU && mru <= PPP_MAXMRU) sc->sc_mru = mru; break; d552 3 a554 3 case PPPIOCGMRU: *(int *)data = sc->sc_mru; break; d557 7 a563 7 case PPPIOCSMAXCID: if (sc->sc_comp) { s = splsoftnet(); sl_compress_setup(sc->sc_comp, *(int *)data); splx(s); } break; d566 3 a568 3 case PPPIOCXFERUNIT: sc->sc_xfer = l->l_proc->p_pid; break; d571 58 a628 59 case PPPIOCSCOMPRESS: odp = (struct ppp_option_data *) data; nb = odp->length; if (nb > sizeof(ccp_option)) nb = sizeof(ccp_option); if ((error = copyin(odp->ptr, ccp_option, nb)) != 0) return (error); /* preliminary check on the length byte */ if (ccp_option[1] < 2) return (EINVAL); cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); } sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); d631 22 a652 12 case PPPIOCGNPMODE: case PPPIOCSNPMODE: npi = (struct npioctl *) data; switch (npi->protocol) { case PPP_IP: npx = NP_IP; break; case PPP_IPV6: npx = NP_IPV6; break; default: return EINVAL; d654 4 a657 14 if (cmd == PPPIOCGNPMODE) { npi->mode = sc->sc_npmode[npx]; } else { if (npi->mode != sc->sc_npmode[npx]) { s = splnet(); sc->sc_npmode[npx] = npi->mode; if (npi->mode != NPMODE_QUEUE) { ppp_requeue(sc); ppp_restart(sc); } splx(s); } } break; d659 7 a665 7 case PPPIOCGIDLE: s = splsoftnet(); t = time_second; ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent; ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv; splx(s); break; d668 31 a698 4 case PPPIOCSPASS: case PPPIOCSACTIVE: /* These are no longer supported. */ return EOPNOTSUPP; a699 1 case PPPIOCSIPASS: d701 3 d705 3 d709 14 a722 46 nbp = (struct bpf_program *) data; if ((unsigned) nbp->bf_len > BPF_MAXINSNS) return EINVAL; newcodelen = nbp->bf_len * sizeof(struct bpf_insn); if (newcodelen != 0) { newcode = malloc(newcodelen, M_DEVBUF, M_WAITOK); /* WAITOK -- malloc() never fails. */ if ((error = copyin((void *)nbp->bf_insns, (void *)newcode, newcodelen)) != 0) { free(newcode, M_DEVBUF); return error; } if (!bpf_validate(newcode, nbp->bf_len)) { free(newcode, M_DEVBUF); return EINVAL; } } else newcode = 0; switch (cmd) { case PPPIOCSIPASS: bp = &sc->sc_pass_filt_in; break; case PPPIOCSOPASS: bp = &sc->sc_pass_filt_out; break; case PPPIOCSIACTIVE: bp = &sc->sc_active_filt_in; break; case PPPIOCSOACTIVE: bp = &sc->sc_active_filt_out; break; default: free(newcode, M_DEVBUF); return (EPASSTHROUGH); } oldcode = bp->bf_insns; s = splnet(); bp->bf_len = nbp->bf_len; bp->bf_insns = newcode; splx(s); if (oldcode != 0) free(oldcode, M_DEVBUF); break; d725 4 a728 4 default: return (EPASSTHROUGH); } return (0); d737 4 a740 4 struct ppp_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; d742 1 a742 1 struct ppp_comp_stats *pcp; d744 1 a744 1 int s = splnet(), error = 0; d746 3 a748 6 switch (cmd) { case SIOCSIFFLAGS: if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; if ((ifp->if_flags & IFF_RUNNING) == 0) ifp->if_flags &= ~IFF_UP; d750 3 d754 2 a755 2 case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { d757 2 a758 2 case AF_INET: break; d761 2 a762 2 case AF_INET6: break; d764 5 a768 5 default: error = EAFNOSUPPORT; break; } break; d770 7 a776 7 case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { error = EAFNOSUPPORT; break; } switch (ifreq_getaddr(cmd, ifr)->sa_family) { d778 2 a779 2 case AF_INET: break; d782 2 a783 2 case AF_INET6: break; d785 5 a789 5 default: error = EAFNOSUPPORT; break; } break; d791 4 a794 4 case SIOCGPPPSTATS: psp = &((struct ifpppstatsreq *) data)->stats; memset(psp, 0, sizeof(*psp)); psp->p = sc->sc_stats; d796 10 a805 10 if (sc->sc_comp) { psp->vj.vjs_packets = sc->sc_comp->sls_packets; psp->vj.vjs_compressed = sc->sc_comp->sls_compressed; psp->vj.vjs_searches = sc->sc_comp->sls_searches; psp->vj.vjs_misses = sc->sc_comp->sls_misses; psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin; psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin; psp->vj.vjs_errorin = sc->sc_comp->sls_errorin; psp->vj.vjs_tossed = sc->sc_comp->sls_tossed; } d807 1 a807 1 break; d810 8 a817 8 case SIOCGPPPCSTATS: pcp = &((struct ifpppcstatsreq *) data)->stats; memset(pcp, 0, sizeof(*pcp)); if (sc->sc_xc_state != NULL) (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c); if (sc->sc_rc_state != NULL) (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d); break; d820 7 a826 7 default: if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; } splx(s); return (error); d837 4 a840 4 struct ppp_softc *sc = ifp->if_softc; int protocol, address, control; u_char *cp; int s, error; d842 1 a842 1 struct ip *ip; d844 24 a867 12 struct ifqueue *ifq; enum NPmode mode; int len; ALTQ_DECL(struct altq_pktattr pktattr;) if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { error = ENETDOWN; /* sort of */ goto bad; } IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); d870 2 a871 1 * Compute PPP header. d873 4 a876 17 m0->m_flags &= ~M_HIGHPRI; switch (dst->sa_family) { #ifdef INET case AF_INET: address = PPP_ALLSTATIONS; control = PPP_UI; protocol = PPP_IP; mode = sc->sc_npmode[NP_IP]; /* * If this packet has the "low delay" bit set in the IP header, * put it on the fastq instead. */ ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; break; d879 5 a883 5 case AF_INET6: address = PPP_ALLSTATIONS; /*XXX*/ control = PPP_UI; /*XXX*/ protocol = PPP_IPV6; mode = sc->sc_npmode[NP_IPV6]; d890 3 a892 3 ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; d894 1 a894 1 break; d896 45 a940 12 case AF_UNSPEC: address = PPP_ADDRESS(dst->sa_data); control = PPP_CONTROL(dst->sa_data); protocol = PPP_PROTOCOL(dst->sa_data); mode = NPMODE_PASS; break; default: printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); error = EAFNOSUPPORT; goto bad; } d942 2 d945 2 a946 1 * Drop this packet, or return an error, if necessary. d948 5 a952 7 if (mode == NPMODE_ERROR) { error = ENETDOWN; goto bad; } if (mode == NPMODE_DROP) { error = 0; goto bad; d956 1 a956 1 * Add PPP header. d958 4 a961 39 M_PREPEND(m0, PPP_HDRLEN, M_DONTWAIT); if (m0 == NULL) { error = ENOBUFS; goto bad; } cp = mtod(m0, u_char *); *cp++ = address; *cp++ = control; *cp++ = protocol >> 8; *cp++ = protocol & 0xff; len = m_length(m0); if (sc->sc_flags & SC_LOG_OUTPKT) { printf("%s output: ", ifp->if_xname); pppdumpm(m0); } if ((protocol & 0x8000) == 0) { #ifdef PPP_FILTER /* * Apply the pass and active filters to the packet, * but only if it is a data packet. */ if (sc->sc_pass_filt_out.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *)m0, len, 0) == 0) { error = 0; /* drop this packet */ goto bad; } /* * Update the time we sent the most recent packet. */ if (sc->sc_active_filt_out.bf_insns == 0 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *)m0, len, 0)) sc->sc_last_sent = time_second; a962 7 /* * Update the time we sent the most recent packet. */ sc->sc_last_sent = time_second; #endif /* PPP_FILTER */ } d964 1 a964 1 * See if bpf wants to look at the packet. d966 3 a968 1 bpf_mtap(&sc->sc_if, m0); d970 27 a996 22 /* * Put the packet on the appropriate queue. */ s = splnet(); if (mode == NPMODE_QUEUE) { /* XXX we should limit the number of packets on this queue */ *sc->sc_npqtail = m0; m0->m_nextpkt = NULL; sc->sc_npqtail = &m0->m_nextpkt; } else { ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { splx(s); sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; return (error); } ppp_restart(sc); } ifp->if_opackets++; ifp->if_obytes += len; d998 2 a999 2 splx(s); return (0); d1002 2 a1003 2 m_freem(m0); return (error); d1014 4 a1017 16 struct mbuf *m, **mpp; struct ifqueue *ifq; enum NPmode mode; int error; for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) { switch (PPP_PROTOCOL(mtod(m, u_char *))) { case PPP_IP: mode = sc->sc_npmode[NP_IP]; break; case PPP_IPV6: mode = sc->sc_npmode[NP_IPV6]; break; default: mode = NPMODE_PASS; } d1019 11 a1029 15 switch (mode) { case NPMODE_PASS: /* * This packet can now go on one of the queues to * be sent. */ *mpp = m->m_nextpkt; m->m_nextpkt = NULL; ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA ALTQ_DECL(NULL))) != 0) { sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; } break; d1031 14 a1044 5 case NPMODE_DROP: case NPMODE_ERROR: *mpp = m->m_nextpkt; m_freem(m); break; d1046 9 a1054 4 case NPMODE_QUEUE: mpp = &m->m_nextpkt; break; } d1056 2 a1057 1 sc->sc_npqtail = mpp; d1067 1 a1067 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1069 3 a1071 3 sc->sc_flags &= ~SC_TBUSY; softint_schedule(sc->sc_si); splx(s); d1083 26 a1108 4 struct mbuf *m, *mp; u_char *cp; int address, control, protocol; int s; d1110 2 a1111 21 /* * Grab a packet to send: first try the fast queue, then the * normal queue. */ s = splnet(); if (sc->sc_nfastq < sc->sc_maxfastq) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; else IFQ_DEQUEUE(&sc->sc_if.if_snd, m); } else { sc->sc_nfastq = 0; IFQ_DEQUEUE(&sc->sc_if.if_snd, m); if (m == NULL) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; } } splx(s); d1113 1 a1113 2 if (m == NULL) return NULL; d1115 8 a1122 1 ++sc->sc_stats.ppp_opackets; d1124 3 d1128 1 a1128 2 * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. d1130 27 a1156 45 cp = mtod(m, u_char *); address = PPP_ADDRESS(cp); control = PPP_CONTROL(cp); protocol = PPP_PROTOCOL(cp); switch (protocol) { case PPP_IP: #ifdef VJC /* * If the packet is a TCP/IP packet, see if we can compress it. */ if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) { struct ip *ip; int type; mp = m; ip = (struct ip *) (cp + PPP_HDRLEN); if (mp->m_len <= PPP_HDRLEN) { mp = mp->m_next; if (mp == NULL) break; ip = mtod(mp, struct ip *); } /* * This code assumes the IP/TCP header is in one * non-shared mbuf */ if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; cp = mtod(m, u_char *); cp[0] = address; /* Header has moved */ cp[1] = control; cp[2] = 0; break; } /* Update protocol in PPP header */ cp[3] = protocol; } d1158 3 d1162 1 a1162 1 break; d1165 3 a1167 3 case PPP_CCP: ppp_ccp(sc, m, 0); break; d1169 1 a1169 1 } d1172 21 a1192 28 if (protocol != PPP_LCP && protocol != PPP_CCP && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) { struct mbuf *mcomp = NULL; int slen; slen = 0; for (mp = m; mp != NULL; mp = mp->m_next) slen += mp->m_len; (*sc->sc_xcomp->compress) (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN); if (mcomp != NULL) { if (sc->sc_flags & SC_CCP_UP) { /* * Send the compressed packet instead of the * original. */ m_freem(m); m = mcomp; cp = mtod(m, u_char *); protocol = cp[3]; } else { /* * Can't transmit compressed packets until CCP * is up. */ m_freem(mcomp); } } d1194 1 d1197 19 a1215 19 /* * Compress the address/control and protocol, if possible. */ if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS && control == PPP_UI && protocol != PPP_ALLSTATIONS && protocol != PPP_LCP) { /* can compress address/control */ m->m_data += 2; m->m_len -= 2; } if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) { /* can compress protocol */ if (mtod(m, u_char *) == cp) { cp[2] = cp[1]; /* move address/control up */ cp[1] = cp[0]; } ++m->m_data; --m->m_len; } d1217 1 a1217 1 return m; d1252 1 a1252 1 * Handle a CCP packet. `rcvd' is 1 if the packet was received, d1258 16 a1273 3 u_char *dp, *ep; struct mbuf *mp; int slen, s; d1275 10 a1284 12 /* * Get a pointer to the data after the PPP header. */ if (m->m_len <= PPP_HDRLEN) { mp = m->m_next; if (mp == NULL) return; dp = mtod(mp, u_char *); } else { mp = m; dp = mtod(mp, u_char *) + PPP_HDRLEN; } d1286 9 a1294 9 ep = mtod(mp, u_char *) + mp->m_len; if (dp + CCP_HDRLEN > ep) return; slen = CCP_LENGTH(dp); if (dp + slen > ep) { if (sc->sc_flags & SC_DEBUG) printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n", dp, slen, mtod(mp, u_char *), mp->m_len); return; d1296 1 d1298 25 a1322 9 switch (CCP_CODE(dp)) { case CCP_CONFREQ: case CCP_TERMREQ: case CCP_TERMACK: /* CCP must be going down - disable compression */ if (sc->sc_flags & SC_CCP_UP) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN); splx(s); d1324 3 a1326 1 break; d1328 11 a1338 31 case CCP_CONFACK: if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP) && slen >= CCP_HDRLEN + CCP_OPT_MINLEN && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) { if (!rcvd) { /* We're agreeing to send compressed packets. */ if (sc->sc_xc_state != NULL && (*sc->sc_xcomp->comp_init) (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_COMP_RUN; splx(s); } } else { /* * Peer is agreeing to send compressed * packets. */ if (sc->sc_rc_state != NULL && (*sc->sc_rcomp->decomp_init) (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_mru, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_DECOMP_RUN; sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR); splx(s); } } d1340 1 a1340 17 break; case CCP_RESETACK: if (sc->sc_flags & SC_CCP_UP) { if (!rcvd) { if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state); } else { if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) { (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DC_ERROR; splx(s); } } } break; d1342 2 d1352 10 a1361 10 if (sc->sc_xc_state) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); sc->sc_xc_state = NULL; } if (sc->sc_rc_state) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); sc->sc_rc_state = NULL; } d1374 1 a1374 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1376 5 a1380 5 if (lost) m->m_flags |= M_ERRMARK; IF_ENQUEUE(&sc->sc_rawq, m); softint_schedule(sc->sc_si); splx(s); d1387 2 a1388 2 #define COMPTYPE(proto) ((proto) == PPP_VJC_COMP ? TYPE_COMPRESSED_TCP: \ TYPE_UNCOMPRESSED_TCP) d1393 5 a1397 6 struct ifnet *ifp = &sc->sc_if; pktqueue_t *pktq = NULL; struct ifqueue *inq = NULL; int s, ilen, proto, rv; u_char *cp, adrs, ctrl; struct mbuf *mp, *dmp = NULL; d1399 3 a1401 3 int xlen; u_char *iphdr; u_int hlen; d1404 1 a1404 1 sc->sc_stats.ppp_ipackets++; d1406 19 a1424 19 if (sc->sc_flags & SC_LOG_INPKT) { ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; printf("%s: got %d bytes\n", ifp->if_xname, ilen); pppdumpm(m); } cp = mtod(m, u_char *); adrs = PPP_ADDRESS(cp); ctrl = PPP_CONTROL(cp); proto = PPP_PROTOCOL(cp); if (m->m_flags & M_ERRMARK) { m->m_flags &= ~M_ERRMARK; s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; splx(s); } d1427 17 a1443 38 /* * Decompress this packet if necessary, update the receiver's * dictionary, or take appropriate action on a CCP packet. */ if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN) && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) { /* Decompress this packet */ rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp); if (rv == DECOMP_OK) { m_freem(m); if (dmp == NULL) { /* * No error, but no decompressed packet * produced */ return; } m = dmp; cp = mtod(m, u_char *); proto = PPP_PROTOCOL(cp); } else { /* * An error has occurred in decompression. * Pass the compressed packet up to pppd, which may * take CCP down or issue a Reset-Req. */ if (sc->sc_flags & SC_DEBUG) printf("%s: decompress failed %d\n", ifp->if_xname, rv); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; if (rv == DECOMP_ERROR) sc->sc_flags |= SC_DC_ERROR; else sc->sc_flags |= SC_DC_FERROR; splx(s); } d1446 29 a1474 10 if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m); if (proto == PPP_CCP) ppp_ccp(sc, m, 1); } #endif ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; d1477 1 a1477 12 if (sc->sc_flags & SC_VJ_RESET) { /* * If we've missed a packet, we must toss subsequent compressed * packets which don't have an explicit connection ID. */ if (sc->sc_comp) sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_VJ_RESET; splx(s); } d1479 2 a1480 1 * See if we have a VJ-compressed packet to uncompress. d1482 6 a1487 14 if (proto == PPP_VJC_COMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen <= 0) { if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type comp\n", ifp->if_xname); goto bad; } d1489 30 a1518 56 /* Copy the PPP and IP headers into a new mbuf. */ MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp == NULL) goto bad; mp->m_len = 0; mp->m_next = NULL; if (hlen + PPP_HDRLEN > MHLEN) { MCLGET(mp, M_DONTWAIT); if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) { /* Lose if big headers and no clusters */ m_freem(mp); goto bad; } } cp = mtod(mp, u_char *); cp[0] = adrs; cp[1] = ctrl; cp[2] = 0; cp[3] = PPP_IP; proto = PPP_IP; bcopy(iphdr, cp + PPP_HDRLEN, hlen); mp->m_len = hlen + PPP_HDRLEN; /* * Trim the PPP and VJ headers off the old mbuf * and stick the new and old mbufs together. */ m->m_data += PPP_HDRLEN + xlen; m->m_len -= PPP_HDRLEN + xlen; if (m->m_len <= M_TRAILINGSPACE(mp)) { bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len); mp->m_len += m->m_len; MFREE(m, mp->m_next); } else mp->m_next = m; m = mp; ilen += hlen - xlen; } else if (proto == PPP_VJC_UNCOMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen < 0) { if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type uncomp\n", ifp->if_xname); goto bad; } proto = PPP_IP; cp[3] = PPP_IP; d1520 8 a1527 1 #endif /* VJC */ d1530 2 a1531 2 * If the packet will fit in a header mbuf, don't waste a * whole cluster on it. d1533 46 a1578 11 if (ilen <= MHLEN && M_IS_CLUSTER(m)) { MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp != NULL) { m_copydata(m, 0, ilen, mtod(mp, void *)); m_freem(m); m = mp; m->m_len = ilen; } } m->m_pkthdr.len = ilen; m->m_pkthdr.rcvif = ifp; d1580 1 a1580 1 if ((proto & 0x8000) == 0) { d1582 15 a1596 15 /* * See whether we want to pass this packet, and * if it counts as link activity. */ if (sc->sc_pass_filt_in.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *)m, ilen, 0) == 0) { /* drop this packet */ m_freem(m); return; } if (sc->sc_active_filt_in.bf_insns == 0 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *)m, ilen, 0)) sc->sc_last_recv = time_second; d1598 4 a1601 4 /* * Record the time that we received this packet. */ sc->sc_last_recv = time_second; d1603 1 a1603 1 } d1605 2 a1606 2 /* See if bpf wants to look at the packet. */ bpf_mtap(&sc->sc_if, m); d1608 2 a1609 1 switch (proto) { d1611 13 a1623 13 case PPP_IP: /* * IP packet - take off the ppp header and pass it up to IP. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IP] != NPMODE_PASS) { /* Interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; d1625 2 a1626 2 if (ipflow_fastforward(m)) return; d1628 3 a1630 2 pktq = ip_pktq; break; d1634 16 a1649 17 case PPP_IPV6: /* * IPv6 packet - take off the ppp header and pass it up to * IPv6. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; #ifdef GATEWAY if (ip6flow_fastforward(&m)) return; d1651 3 a1653 2 pktq = ip6_pktq; break; d1656 1 a1656 9 default: /* * Some other protocol - place on input queue for read(). */ inq = &sc->sc_inq; pktq = NULL; break; } d1658 1 a1658 1 * Put the packet on the appropriate input queue. d1660 4 a1663 13 s = splnet(); /* pktq: inet or inet6 cases */ if (__predict_true(pktq)) { if (__predict_false(!pktq_enqueue(pktq, m, 0))) { ifp->if_iqdrops++; goto bad; } ifp->if_ipackets++; ifp->if_ibytes += ilen; splx(s); return; } d1665 6 a1670 13 /* ifq: other protocol cases */ if (!inq) { goto bad; } if (IF_QFULL(inq)) { IF_DROP(inq); splx(s); if (sc->sc_flags & SC_DEBUG) printf("%s: input queue full\n", ifp->if_xname); ifp->if_iqdrops++; goto bad; } IF_ENQUEUE(inq, m); d1672 9 a1680 2 ifp->if_ipackets++; ifp->if_ibytes += ilen; d1682 1 d1685 1 a1685 1 return; d1687 4 a1690 4 bad: m_freem(m); sc->sc_if.if_ierrors++; sc->sc_stats.ppp_ierrors++; d1698 22 a1719 23 char buf[3*MAX_DUMP_BYTES+4]; char *bp = buf; struct mbuf *m; for (m = m0; m; m = m->m_next) { int l = m->m_len; u_char *rptr = (u_char *)m->m_data; while (l--) { if (bp > buf + sizeof(buf) - 4) goto done; /* Convert byte to ascii hex */ *bp++ = hexdigits[*rptr >> 4]; *bp++ = hexdigits[*rptr++ & 0xf]; } if (m->m_next) { if (bp > buf + sizeof(buf) - 3) goto done; *bp++ = '|'; } else *bp++ = ' '; } d1721 4 a1724 4 if (m) *bp++ = '>'; *bp = 0; printf("%s\n", buf); d1729 1 a1729 1 * A wrapper to transmit a packet from if_start since ALTQ uses d1808 1 a1808 1 MODULE_CLASS_MISC) != 0) d1833 1 a1833 1 false) != NULL) d1856 1 a1856 1 false) != &pc[i]) @ 1.140 log @bpf_filter: add a custom argument which can be passed to coprocessor routine. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.139 2013/08/29 14:25:41 rmind Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.139 2013/08/29 14:25:41 rmind Exp $"); d949 1 a949 1 && bpf_filter(bpf_def_ctx, NULL, sc->sc_pass_filt_out.bf_insns, d959 1 a959 1 || bpf_filter(bpf_def_ctx, NULL, sc->sc_active_filt_out.bf_insns, d1587 1 a1587 1 && bpf_filter(bpf_def_ctx, NULL, sc->sc_pass_filt_in.bf_insns, d1594 1 a1594 1 || bpf_filter(bpf_def_ctx, NULL, sc->sc_active_filt_in.bf_insns, @ 1.139 log @Implement BPF_COP/BPF_COPX instructions in the misc category (BPF_MISC) which add a capability to call external functions in a predetermined way. It can be thought as a BPF "coprocessor" -- a generic mechanism to offload more complex packet inspection operations. There is no default coprocessor and this functionality is not targeted to the /dev/bpf. This is primarily targeted to the kernel subsystems, therefore there is no way to set a custom coprocessor at the userlevel. Discussed on: tech-net@@ OK: core@@ @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.138 2012/11/25 09:06:43 mbalmer Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.138 2012/11/25 09:06:43 mbalmer Exp $"); d949 1 a949 1 && bpf_filter(bpf_def_ctx, sc->sc_pass_filt_out.bf_insns, d959 1 a959 1 || bpf_filter(bpf_def_ctx, sc->sc_active_filt_out.bf_insns, d1587 1 a1587 1 && bpf_filter(bpf_def_ctx, sc->sc_pass_filt_in.bf_insns, d1594 1 a1594 1 || bpf_filter(bpf_def_ctx, sc->sc_active_filt_in.bf_insns, @ 1.138 log @Don't check mp for NULL twice. From Michael W. Bomardieri via tech-net@@NetBSD.org. Thanks! @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.137 2012/10/11 20:05:50 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.137 2012/10/11 20:05:50 christos Exp $"); d949 2 a950 2 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *) m0, len, 0) == 0) { d959 2 a960 2 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *) m0, len, 0)) d1587 2 a1588 2 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *) m, ilen, 0) == 0) { d1594 2 a1595 2 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *) m, ilen, 0)) @ 1.138.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.138 2012/11/25 09:06:43 mbalmer Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.138 2012/11/25 09:06:43 mbalmer Exp $"); d949 2 a950 2 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *)m0, len, 0) == 0) { d959 2 a960 2 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *)m0, len, 0)) a1397 1 int isr = 0; d1587 2 a1588 2 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *)m, ilen, 0) == 0) { d1594 2 a1595 2 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *)m, ilen, 0)) d1628 1 a1628 1 isr = NETISR_IP; d1651 1 a1651 1 isr = NETISR_IPV6; a1677 3 if (__predict_true(isr)) { schednetisr(isr); } @ 1.137 log @PR/47058: Antti Kantee: If the ipv6 flow code modifies the mbuf, pass the change up to the caller. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.136 2011/10/28 22:08:14 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.136 2011/10/28 22:08:14 dyoung Exp $"); d1269 1 a1269 1 dp = (mp != NULL)? mtod(mp, u_char *): NULL; @ 1.136 log @For these interfaces, the implementation of SIOCSIFDSTADDR is identical to SIOCINITIFADDR, and SIOCSIFDSTADDR callers always fall back to SIOCINITIFADDR, so just get rid of the SIOCSIFDSTADDR case. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.135 2011/10/28 20:13:32 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.135 2011/10/28 20:13:32 dyoung Exp $"); d1648 1 a1648 1 if (ip6flow_fastforward(m)) @ 1.136.12.1 log @Resync to 2012-11-19 00:00:00 UTC @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.137 2012/10/11 20:05:50 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.137 2012/10/11 20:05:50 christos Exp $"); d1648 1 a1648 1 if (ip6flow_fastforward(&m)) @ 1.136.12.2 log @resync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.136.12.1 2012/11/20 03:02:47 tls Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.136.12.1 2012/11/20 03:02:47 tls Exp $"); d1269 1 a1269 1 dp = mtod(mp, u_char *); @ 1.136.12.3 log @Rebase to HEAD as of a few days ago. @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d185 2 a186 2 #define M_DATASTART(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \ d189 2 a190 2 #define M_DATASIZE(m) \ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \ d201 2 a202 2 static int ppp_clone_create(struct if_clone *, int); static int ppp_clone_destroy(struct ifnet *); d229 1 a229 1 extern struct linesw ppp_disc; d231 2 a232 2 if (ttyldisc_attach(&ppp_disc) != 0) panic("pppattach"); d234 4 a237 4 mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&ppp_softc_list); if_clone_attach(&ppp_cloner); RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d243 1 a243 1 struct ppp_softc *sc, *sci, *scl = NULL; d245 1 a245 1 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d247 9 a255 9 mutex_enter(&ppp_list_lock); if (unit == -1) { int i = 0; LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (i < sci->sc_unit) { unit = i; break; } else { d257 1 a257 1 KASSERT(i == sci->sc_unit); d259 14 a272 15 i++; } } if (unit == -1) unit = i; } else { LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (unit < sci->sc_unit) break; else if (unit == sci->sc_unit) { free(sc, M_DEVBUF); return NULL; } } d274 1 d276 19 a294 19 if (sci != NULL) LIST_INSERT_BEFORE(sci, sc, sc_iflist); else if (scl != NULL) LIST_INSERT_AFTER(scl, sc, sc_iflist); else LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist); mutex_exit(&ppp_list_lock); if_initname(&sc->sc_if, name, sc->sc_unit = unit); callout_init(&sc->sc_timo_ch, 0); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; d296 1 a296 1 sc->sc_if.if_start = ppp_ifstart; d298 11 a308 11 IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; /* Ratio of 1:2 packets between the regular and the fast queue */ sc->sc_maxfastq = 2; IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, 0); return sc; d314 1 a314 1 return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0; d320 1 a320 1 struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc; d322 2 a323 2 if (sc->sc_devp != NULL) return EBUSY; /* Not removing it */ d325 3 a327 3 mutex_enter(&ppp_list_lock); LIST_REMOVE(sc, sc_iflist); mutex_exit(&ppp_list_lock); d329 2 a330 2 bpf_detach(ifp); if_detach(ifp); d332 2 a333 2 free(sc, M_DEVBUF); return 0; d342 2 a343 2 struct ppp_softc *sc = NULL, *scf; int i; d345 24 a368 25 mutex_enter(&ppp_list_lock); LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) { if (scf->sc_xfer == pid) { scf->sc_xfer = 0; mutex_exit(&ppp_list_lock); return scf; } if (scf->sc_devp == NULL && sc == NULL) sc = scf; } mutex_exit(&ppp_list_lock); if (sc == NULL) sc = ppp_create(ppp_cloner.ifc_name, -1); sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); if (sc->sc_si == NULL) { printf("%s: unable to establish softintr\n", sc->sc_if.if_xname); return (NULL); } sc->sc_flags = 0; sc->sc_mru = PPP_MRU; sc->sc_relinq = NULL; (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats)); d370 3 a372 3 sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); if (sc->sc_comp) sl_compress_init(sc->sc_comp); d375 2 a376 2 sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; d378 5 a382 5 for (i = 0; i < NUM_NP; ++i) sc->sc_npmode[i] = NPMODE_ERROR; sc->sc_npqueue = NULL; sc->sc_npqtail = &sc->sc_npqueue; sc->sc_last_sent = sc->sc_last_recv = time_second; d384 1 a384 1 return sc; d393 1 a393 1 struct mbuf *m; d395 31 a425 31 softint_disestablish(sc->sc_si); if_down(&sc->sc_if); sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); sc->sc_devp = NULL; sc->sc_xfer = 0; for (;;) { IF_DEQUEUE(&sc->sc_rawq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_inq, m); if (m == NULL) break; m_freem(m); } for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) break; m_freem(m); } while ((m = sc->sc_npqueue) != NULL) { sc->sc_npqueue = m->m_nextpkt; m_freem(m); } if (sc->sc_togo != NULL) { m_freem(sc->sc_togo); sc->sc_togo = NULL; } d427 3 a429 3 ppp_ccp_closed(sc); sc->sc_xc_state = NULL; sc->sc_rc_state = NULL; d432 20 a451 20 if (sc->sc_pass_filt_in.bf_insns != 0) { free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); sc->sc_pass_filt_in.bf_insns = 0; sc->sc_pass_filt_in.bf_len = 0; } if (sc->sc_pass_filt_out.bf_insns != 0) { free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); sc->sc_pass_filt_out.bf_insns = 0; sc->sc_pass_filt_out.bf_len = 0; } if (sc->sc_active_filt_in.bf_insns != 0) { free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); sc->sc_active_filt_in.bf_insns = 0; sc->sc_active_filt_in.bf_len = 0; } if (sc->sc_active_filt_out.bf_insns != 0) { free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); sc->sc_active_filt_out.bf_insns = 0; sc->sc_active_filt_out.bf_len = 0; } d454 4 a457 4 if (sc->sc_comp != 0) { free(sc->sc_comp, M_DEVBUF); sc->sc_comp = 0; } d459 1 a459 1 (void)ppp_clone_destroy(&sc->sc_if); d469 6 a474 6 int s, error, flags, mru, npx; u_int nb; struct ppp_option_data *odp; struct compressor *cp; struct npioctl *npi; time_t t; d476 3 a478 3 struct bpf_program *bp, *nbp; struct bpf_insn *newcode, *oldcode; int newcodelen; d481 1 a481 1 u_char ccp_option[CCP_MAX_OPTION_LENGTH]; d484 21 a504 21 switch (cmd) { case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return (EPERM); break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), NULL) != 0) return (EPERM); break; default: break; } d506 4 a509 4 switch (cmd) { case FIONREAD: *(int *)data = sc->sc_inq.ifq_len; break; d511 3 a513 3 case PPPIOCGUNIT: *(int *)data = sc->sc_unit; break; d515 3 a517 3 case PPPIOCGFLAGS: *(u_int *)data = sc->sc_flags; break; d519 1 a519 1 case PPPIOCGRAWIN: d521 2 a522 2 struct ppp_rawin *rwin = (struct ppp_rawin *)data; u_char c, q = 0; d524 2 a525 2 for (c = sc->sc_rawin_start; c < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d527 2 a528 2 for (c = 0; c < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d530 1 a530 1 rwin->count = sc->sc_rawin.count; d534 3 a536 3 case PPPIOCSFLAGS: flags = *(int *)data & SC_MASK; s = splsoftnet(); d538 2 a539 2 if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN)) ppp_ccp_closed(sc); d541 4 a544 4 splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags = (sc->sc_flags & ~SC_MASK) | flags; splx(s); break; d546 5 a550 5 case PPPIOCSMRU: mru = *(int *)data; if (mru >= PPP_MINMRU && mru <= PPP_MAXMRU) sc->sc_mru = mru; break; d552 3 a554 3 case PPPIOCGMRU: *(int *)data = sc->sc_mru; break; d557 7 a563 7 case PPPIOCSMAXCID: if (sc->sc_comp) { s = splsoftnet(); sl_compress_setup(sc->sc_comp, *(int *)data); splx(s); } break; d566 3 a568 3 case PPPIOCXFERUNIT: sc->sc_xfer = l->l_proc->p_pid; break; d571 58 a628 59 case PPPIOCSCOMPRESS: odp = (struct ppp_option_data *) data; nb = odp->length; if (nb > sizeof(ccp_option)) nb = sizeof(ccp_option); if ((error = copyin(odp->ptr, ccp_option, nb)) != 0) return (error); /* preliminary check on the length byte */ if (ccp_option[1] < 2) return (EINVAL); cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); } sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); d631 22 a652 12 case PPPIOCGNPMODE: case PPPIOCSNPMODE: npi = (struct npioctl *) data; switch (npi->protocol) { case PPP_IP: npx = NP_IP; break; case PPP_IPV6: npx = NP_IPV6; break; default: return EINVAL; d654 4 a657 14 if (cmd == PPPIOCGNPMODE) { npi->mode = sc->sc_npmode[npx]; } else { if (npi->mode != sc->sc_npmode[npx]) { s = splnet(); sc->sc_npmode[npx] = npi->mode; if (npi->mode != NPMODE_QUEUE) { ppp_requeue(sc); ppp_restart(sc); } splx(s); } } break; d659 7 a665 7 case PPPIOCGIDLE: s = splsoftnet(); t = time_second; ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent; ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv; splx(s); break; d668 31 a698 4 case PPPIOCSPASS: case PPPIOCSACTIVE: /* These are no longer supported. */ return EOPNOTSUPP; a699 1 case PPPIOCSIPASS: d701 3 d705 3 d709 14 a722 46 nbp = (struct bpf_program *) data; if ((unsigned) nbp->bf_len > BPF_MAXINSNS) return EINVAL; newcodelen = nbp->bf_len * sizeof(struct bpf_insn); if (newcodelen != 0) { newcode = malloc(newcodelen, M_DEVBUF, M_WAITOK); /* WAITOK -- malloc() never fails. */ if ((error = copyin((void *)nbp->bf_insns, (void *)newcode, newcodelen)) != 0) { free(newcode, M_DEVBUF); return error; } if (!bpf_validate(newcode, nbp->bf_len)) { free(newcode, M_DEVBUF); return EINVAL; } } else newcode = 0; switch (cmd) { case PPPIOCSIPASS: bp = &sc->sc_pass_filt_in; break; case PPPIOCSOPASS: bp = &sc->sc_pass_filt_out; break; case PPPIOCSIACTIVE: bp = &sc->sc_active_filt_in; break; case PPPIOCSOACTIVE: bp = &sc->sc_active_filt_out; break; default: free(newcode, M_DEVBUF); return (EPASSTHROUGH); } oldcode = bp->bf_insns; s = splnet(); bp->bf_len = nbp->bf_len; bp->bf_insns = newcode; splx(s); if (oldcode != 0) free(oldcode, M_DEVBUF); break; d725 4 a728 4 default: return (EPASSTHROUGH); } return (0); d737 4 a740 4 struct ppp_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; d742 1 a742 1 struct ppp_comp_stats *pcp; d744 1 a744 1 int s = splnet(), error = 0; d746 3 a748 6 switch (cmd) { case SIOCSIFFLAGS: if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; if ((ifp->if_flags & IFF_RUNNING) == 0) ifp->if_flags &= ~IFF_UP; d750 3 d754 2 a755 2 case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { d757 2 a758 2 case AF_INET: break; d761 2 a762 2 case AF_INET6: break; d764 5 a768 5 default: error = EAFNOSUPPORT; break; } break; d770 7 a776 7 case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { error = EAFNOSUPPORT; break; } switch (ifreq_getaddr(cmd, ifr)->sa_family) { d778 2 a779 2 case AF_INET: break; d782 2 a783 2 case AF_INET6: break; d785 5 a789 5 default: error = EAFNOSUPPORT; break; } break; d791 4 a794 4 case SIOCGPPPSTATS: psp = &((struct ifpppstatsreq *) data)->stats; memset(psp, 0, sizeof(*psp)); psp->p = sc->sc_stats; d796 10 a805 10 if (sc->sc_comp) { psp->vj.vjs_packets = sc->sc_comp->sls_packets; psp->vj.vjs_compressed = sc->sc_comp->sls_compressed; psp->vj.vjs_searches = sc->sc_comp->sls_searches; psp->vj.vjs_misses = sc->sc_comp->sls_misses; psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin; psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin; psp->vj.vjs_errorin = sc->sc_comp->sls_errorin; psp->vj.vjs_tossed = sc->sc_comp->sls_tossed; } d807 1 a807 1 break; d810 8 a817 8 case SIOCGPPPCSTATS: pcp = &((struct ifpppcstatsreq *) data)->stats; memset(pcp, 0, sizeof(*pcp)); if (sc->sc_xc_state != NULL) (*sc->sc_xcomp->comp_stat)(sc->sc_xc_state, &pcp->c); if (sc->sc_rc_state != NULL) (*sc->sc_rcomp->decomp_stat)(sc->sc_rc_state, &pcp->d); break; d820 7 a826 7 default: if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; } splx(s); return (error); d837 4 a840 4 struct ppp_softc *sc = ifp->if_softc; int protocol, address, control; u_char *cp; int s, error; d842 1 a842 1 struct ip *ip; d844 24 a867 12 struct ifqueue *ifq; enum NPmode mode; int len; ALTQ_DECL(struct altq_pktattr pktattr;) if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { error = ENETDOWN; /* sort of */ goto bad; } IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); d870 2 a871 1 * Compute PPP header. d873 4 a876 17 m0->m_flags &= ~M_HIGHPRI; switch (dst->sa_family) { #ifdef INET case AF_INET: address = PPP_ALLSTATIONS; control = PPP_UI; protocol = PPP_IP; mode = sc->sc_npmode[NP_IP]; /* * If this packet has the "low delay" bit set in the IP header, * put it on the fastq instead. */ ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; break; d879 5 a883 5 case AF_INET6: address = PPP_ALLSTATIONS; /*XXX*/ control = PPP_UI; /*XXX*/ protocol = PPP_IPV6; mode = sc->sc_npmode[NP_IPV6]; d890 3 a892 3 ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; d894 1 a894 1 break; d896 45 a940 12 case AF_UNSPEC: address = PPP_ADDRESS(dst->sa_data); control = PPP_CONTROL(dst->sa_data); protocol = PPP_PROTOCOL(dst->sa_data); mode = NPMODE_PASS; break; default: printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); error = EAFNOSUPPORT; goto bad; } d942 2 d945 2 a946 1 * Drop this packet, or return an error, if necessary. d948 5 a952 7 if (mode == NPMODE_ERROR) { error = ENETDOWN; goto bad; } if (mode == NPMODE_DROP) { error = 0; goto bad; d956 1 a956 1 * Add PPP header. d958 4 a961 39 M_PREPEND(m0, PPP_HDRLEN, M_DONTWAIT); if (m0 == NULL) { error = ENOBUFS; goto bad; } cp = mtod(m0, u_char *); *cp++ = address; *cp++ = control; *cp++ = protocol >> 8; *cp++ = protocol & 0xff; len = m_length(m0); if (sc->sc_flags & SC_LOG_OUTPKT) { printf("%s output: ", ifp->if_xname); pppdumpm(m0); } if ((protocol & 0x8000) == 0) { #ifdef PPP_FILTER /* * Apply the pass and active filters to the packet, * but only if it is a data packet. */ if (sc->sc_pass_filt_out.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *)m0, len, 0) == 0) { error = 0; /* drop this packet */ goto bad; } /* * Update the time we sent the most recent packet. */ if (sc->sc_active_filt_out.bf_insns == 0 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *)m0, len, 0)) sc->sc_last_sent = time_second; a962 7 /* * Update the time we sent the most recent packet. */ sc->sc_last_sent = time_second; #endif /* PPP_FILTER */ } d964 1 a964 1 * See if bpf wants to look at the packet. d966 3 a968 1 bpf_mtap(&sc->sc_if, m0); d970 27 a996 22 /* * Put the packet on the appropriate queue. */ s = splnet(); if (mode == NPMODE_QUEUE) { /* XXX we should limit the number of packets on this queue */ *sc->sc_npqtail = m0; m0->m_nextpkt = NULL; sc->sc_npqtail = &m0->m_nextpkt; } else { ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { splx(s); sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; return (error); } ppp_restart(sc); } ifp->if_opackets++; ifp->if_obytes += len; d998 2 a999 2 splx(s); return (0); d1002 2 a1003 2 m_freem(m0); return (error); d1014 4 a1017 16 struct mbuf *m, **mpp; struct ifqueue *ifq; enum NPmode mode; int error; for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) { switch (PPP_PROTOCOL(mtod(m, u_char *))) { case PPP_IP: mode = sc->sc_npmode[NP_IP]; break; case PPP_IPV6: mode = sc->sc_npmode[NP_IPV6]; break; default: mode = NPMODE_PASS; } d1019 11 a1029 15 switch (mode) { case NPMODE_PASS: /* * This packet can now go on one of the queues to * be sent. */ *mpp = m->m_nextpkt; m->m_nextpkt = NULL; ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA ALTQ_DECL(NULL))) != 0) { sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; } break; d1031 14 a1044 5 case NPMODE_DROP: case NPMODE_ERROR: *mpp = m->m_nextpkt; m_freem(m); break; d1046 9 a1054 4 case NPMODE_QUEUE: mpp = &m->m_nextpkt; break; } d1056 2 a1057 1 sc->sc_npqtail = mpp; d1067 1 a1067 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1069 3 a1071 3 sc->sc_flags &= ~SC_TBUSY; softint_schedule(sc->sc_si); splx(s); d1083 26 a1108 4 struct mbuf *m, *mp; u_char *cp; int address, control, protocol; int s; d1110 2 a1111 21 /* * Grab a packet to send: first try the fast queue, then the * normal queue. */ s = splnet(); if (sc->sc_nfastq < sc->sc_maxfastq) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; else IFQ_DEQUEUE(&sc->sc_if.if_snd, m); } else { sc->sc_nfastq = 0; IFQ_DEQUEUE(&sc->sc_if.if_snd, m); if (m == NULL) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; } } splx(s); d1113 1 a1113 2 if (m == NULL) return NULL; d1115 8 a1122 1 ++sc->sc_stats.ppp_opackets; d1124 3 d1128 1 a1128 2 * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. d1130 27 a1156 45 cp = mtod(m, u_char *); address = PPP_ADDRESS(cp); control = PPP_CONTROL(cp); protocol = PPP_PROTOCOL(cp); switch (protocol) { case PPP_IP: #ifdef VJC /* * If the packet is a TCP/IP packet, see if we can compress it. */ if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) { struct ip *ip; int type; mp = m; ip = (struct ip *) (cp + PPP_HDRLEN); if (mp->m_len <= PPP_HDRLEN) { mp = mp->m_next; if (mp == NULL) break; ip = mtod(mp, struct ip *); } /* * This code assumes the IP/TCP header is in one * non-shared mbuf */ if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; cp = mtod(m, u_char *); cp[0] = address; /* Header has moved */ cp[1] = control; cp[2] = 0; break; } /* Update protocol in PPP header */ cp[3] = protocol; } d1158 3 d1162 1 a1162 1 break; d1165 3 a1167 3 case PPP_CCP: ppp_ccp(sc, m, 0); break; d1169 1 a1169 1 } d1172 21 a1192 28 if (protocol != PPP_LCP && protocol != PPP_CCP && sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) { struct mbuf *mcomp = NULL; int slen; slen = 0; for (mp = m; mp != NULL; mp = mp->m_next) slen += mp->m_len; (*sc->sc_xcomp->compress) (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN); if (mcomp != NULL) { if (sc->sc_flags & SC_CCP_UP) { /* * Send the compressed packet instead of the * original. */ m_freem(m); m = mcomp; cp = mtod(m, u_char *); protocol = cp[3]; } else { /* * Can't transmit compressed packets until CCP * is up. */ m_freem(mcomp); } } d1194 1 d1197 19 a1215 19 /* * Compress the address/control and protocol, if possible. */ if (sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS && control == PPP_UI && protocol != PPP_ALLSTATIONS && protocol != PPP_LCP) { /* can compress address/control */ m->m_data += 2; m->m_len -= 2; } if (sc->sc_flags & SC_COMP_PROT && protocol < 0xFF) { /* can compress protocol */ if (mtod(m, u_char *) == cp) { cp[2] = cp[1]; /* move address/control up */ cp[1] = cp[0]; } ++m->m_data; --m->m_len; } d1217 1 a1217 1 return m; d1252 1 a1252 1 * Handle a CCP packet. `rcvd' is 1 if the packet was received, d1258 16 a1273 3 u_char *dp, *ep; struct mbuf *mp; int slen, s; d1275 10 a1284 12 /* * Get a pointer to the data after the PPP header. */ if (m->m_len <= PPP_HDRLEN) { mp = m->m_next; if (mp == NULL) return; dp = mtod(mp, u_char *); } else { mp = m; dp = mtod(mp, u_char *) + PPP_HDRLEN; } d1286 9 a1294 9 ep = mtod(mp, u_char *) + mp->m_len; if (dp + CCP_HDRLEN > ep) return; slen = CCP_LENGTH(dp); if (dp + slen > ep) { if (sc->sc_flags & SC_DEBUG) printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n", dp, slen, mtod(mp, u_char *), mp->m_len); return; d1296 1 d1298 25 a1322 9 switch (CCP_CODE(dp)) { case CCP_CONFREQ: case CCP_TERMREQ: case CCP_TERMACK: /* CCP must be going down - disable compression */ if (sc->sc_flags & SC_CCP_UP) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~(SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN); splx(s); d1324 3 a1326 1 break; d1328 11 a1338 31 case CCP_CONFACK: if (sc->sc_flags & SC_CCP_OPEN && !(sc->sc_flags & SC_CCP_UP) && slen >= CCP_HDRLEN + CCP_OPT_MINLEN && slen >= CCP_OPT_LENGTH(dp + CCP_HDRLEN) + CCP_HDRLEN) { if (!rcvd) { /* We're agreeing to send compressed packets. */ if (sc->sc_xc_state != NULL && (*sc->sc_xcomp->comp_init) (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_COMP_RUN; splx(s); } } else { /* * Peer is agreeing to send compressed * packets. */ if (sc->sc_rc_state != NULL && (*sc->sc_rcomp->decomp_init) (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, sc->sc_unit, 0, sc->sc_mru, sc->sc_flags & SC_DEBUG)) { s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_DECOMP_RUN; sc->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR); splx(s); } } d1340 1 a1340 17 break; case CCP_RESETACK: if (sc->sc_flags & SC_CCP_UP) { if (!rcvd) { if (sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) (*sc->sc_xcomp->comp_reset)(sc->sc_xc_state); } else { if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) { (*sc->sc_rcomp->decomp_reset)(sc->sc_rc_state); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DC_ERROR; splx(s); } } } break; d1342 2 d1352 10 a1361 10 if (sc->sc_xc_state) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); sc->sc_xc_state = NULL; } if (sc->sc_rc_state) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); sc->sc_rc_state = NULL; } d1374 1 a1374 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1376 5 a1380 5 if (lost) m->m_flags |= M_ERRMARK; IF_ENQUEUE(&sc->sc_rawq, m); softint_schedule(sc->sc_si); splx(s); d1387 2 a1388 2 #define COMPTYPE(proto) ((proto) == PPP_VJC_COMP ? TYPE_COMPRESSED_TCP: \ TYPE_UNCOMPRESSED_TCP) d1393 5 a1397 6 struct ifnet *ifp = &sc->sc_if; pktqueue_t *pktq = NULL; struct ifqueue *inq = NULL; int s, ilen, proto, rv; u_char *cp, adrs, ctrl; struct mbuf *mp, *dmp = NULL; d1399 3 a1401 3 int xlen; u_char *iphdr; u_int hlen; d1404 1 a1404 1 sc->sc_stats.ppp_ipackets++; d1406 19 a1424 19 if (sc->sc_flags & SC_LOG_INPKT) { ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; printf("%s: got %d bytes\n", ifp->if_xname, ilen); pppdumpm(m); } cp = mtod(m, u_char *); adrs = PPP_ADDRESS(cp); ctrl = PPP_CONTROL(cp); proto = PPP_PROTOCOL(cp); if (m->m_flags & M_ERRMARK) { m->m_flags &= ~M_ERRMARK; s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; splx(s); } d1427 17 a1443 38 /* * Decompress this packet if necessary, update the receiver's * dictionary, or take appropriate action on a CCP packet. */ if (proto == PPP_COMP && sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN) && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) { /* Decompress this packet */ rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp); if (rv == DECOMP_OK) { m_freem(m); if (dmp == NULL) { /* * No error, but no decompressed packet * produced */ return; } m = dmp; cp = mtod(m, u_char *); proto = PPP_PROTOCOL(cp); } else { /* * An error has occurred in decompression. * Pass the compressed packet up to pppd, which may * take CCP down or issue a Reset-Req. */ if (sc->sc_flags & SC_DEBUG) printf("%s: decompress failed %d\n", ifp->if_xname, rv); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags |= SC_VJ_RESET; if (rv == DECOMP_ERROR) sc->sc_flags |= SC_DC_ERROR; else sc->sc_flags |= SC_DC_FERROR; splx(s); } d1446 29 a1474 10 if (sc->sc_rc_state && (sc->sc_flags & SC_DECOMP_RUN)) (*sc->sc_rcomp->incomp)(sc->sc_rc_state, m); if (proto == PPP_CCP) ppp_ccp(sc, m, 1); } #endif ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; d1477 1 a1477 12 if (sc->sc_flags & SC_VJ_RESET) { /* * If we've missed a packet, we must toss subsequent compressed * packets which don't have an explicit connection ID. */ if (sc->sc_comp) sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp); s = splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_VJ_RESET; splx(s); } d1479 2 a1480 1 * See if we have a VJ-compressed packet to uncompress. d1482 6 a1487 14 if (proto == PPP_VJC_COMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen <= 0) { if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type comp\n", ifp->if_xname); goto bad; } d1489 30 a1518 56 /* Copy the PPP and IP headers into a new mbuf. */ MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp == NULL) goto bad; mp->m_len = 0; mp->m_next = NULL; if (hlen + PPP_HDRLEN > MHLEN) { MCLGET(mp, M_DONTWAIT); if (M_TRAILINGSPACE(mp) < hlen + PPP_HDRLEN) { /* Lose if big headers and no clusters */ m_freem(mp); goto bad; } } cp = mtod(mp, u_char *); cp[0] = adrs; cp[1] = ctrl; cp[2] = 0; cp[3] = PPP_IP; proto = PPP_IP; bcopy(iphdr, cp + PPP_HDRLEN, hlen); mp->m_len = hlen + PPP_HDRLEN; /* * Trim the PPP and VJ headers off the old mbuf * and stick the new and old mbufs together. */ m->m_data += PPP_HDRLEN + xlen; m->m_len -= PPP_HDRLEN + xlen; if (m->m_len <= M_TRAILINGSPACE(mp)) { bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len); mp->m_len += m->m_len; MFREE(m, mp->m_next); } else mp->m_next = m; m = mp; ilen += hlen - xlen; } else if (proto == PPP_VJC_UNCOMP) { if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0) goto bad; xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN, ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP, sc->sc_comp, &iphdr, &hlen); if (xlen < 0) { if (sc->sc_flags & SC_DEBUG) printf("%s: VJ uncompress failed on type uncomp\n", ifp->if_xname); goto bad; } proto = PPP_IP; cp[3] = PPP_IP; d1520 8 a1527 1 #endif /* VJC */ d1530 2 a1531 2 * If the packet will fit in a header mbuf, don't waste a * whole cluster on it. d1533 46 a1578 11 if (ilen <= MHLEN && M_IS_CLUSTER(m)) { MGETHDR(mp, M_DONTWAIT, MT_DATA); if (mp != NULL) { m_copydata(m, 0, ilen, mtod(mp, void *)); m_freem(m); m = mp; m->m_len = ilen; } } m->m_pkthdr.len = ilen; m->m_pkthdr.rcvif = ifp; d1580 1 a1580 1 if ((proto & 0x8000) == 0) { d1582 15 a1596 15 /* * See whether we want to pass this packet, and * if it counts as link activity. */ if (sc->sc_pass_filt_in.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *)m, ilen, 0) == 0) { /* drop this packet */ m_freem(m); return; } if (sc->sc_active_filt_in.bf_insns == 0 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *)m, ilen, 0)) sc->sc_last_recv = time_second; d1598 4 a1601 4 /* * Record the time that we received this packet. */ sc->sc_last_recv = time_second; d1603 1 a1603 1 } d1605 2 a1606 2 /* See if bpf wants to look at the packet. */ bpf_mtap(&sc->sc_if, m); d1608 2 a1609 1 switch (proto) { d1611 13 a1623 13 case PPP_IP: /* * IP packet - take off the ppp header and pass it up to IP. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IP] != NPMODE_PASS) { /* Interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; d1625 2 a1626 2 if (ipflow_fastforward(m)) return; d1628 3 a1630 2 pktq = ip_pktq; break; d1634 16 a1649 17 case PPP_IPV6: /* * IPv6 packet - take off the ppp header and pass it up to * IPv6. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; #ifdef GATEWAY if (ip6flow_fastforward(&m)) return; d1651 3 a1653 2 pktq = ip6_pktq; break; d1656 1 a1656 9 default: /* * Some other protocol - place on input queue for read(). */ inq = &sc->sc_inq; pktq = NULL; break; } d1658 1 a1658 1 * Put the packet on the appropriate input queue. d1660 4 a1663 13 s = splnet(); /* pktq: inet or inet6 cases */ if (__predict_true(pktq)) { if (__predict_false(!pktq_enqueue(pktq, m, 0))) { ifp->if_iqdrops++; goto bad; } ifp->if_ipackets++; ifp->if_ibytes += ilen; splx(s); return; } d1665 6 a1670 13 /* ifq: other protocol cases */ if (!inq) { goto bad; } if (IF_QFULL(inq)) { IF_DROP(inq); splx(s); if (sc->sc_flags & SC_DEBUG) printf("%s: input queue full\n", ifp->if_xname); ifp->if_iqdrops++; goto bad; } IF_ENQUEUE(inq, m); d1672 9 a1680 2 ifp->if_ipackets++; ifp->if_ibytes += ilen; d1682 1 d1685 1 a1685 1 return; d1687 4 a1690 4 bad: m_freem(m); sc->sc_if.if_ierrors++; sc->sc_stats.ppp_ierrors++; d1698 22 a1719 23 char buf[3*MAX_DUMP_BYTES+4]; char *bp = buf; struct mbuf *m; for (m = m0; m; m = m->m_next) { int l = m->m_len; u_char *rptr = (u_char *)m->m_data; while (l--) { if (bp > buf + sizeof(buf) - 4) goto done; /* Convert byte to ascii hex */ *bp++ = hexdigits[*rptr >> 4]; *bp++ = hexdigits[*rptr++ & 0xf]; } if (m->m_next) { if (bp > buf + sizeof(buf) - 3) goto done; *bp++ = '|'; } else *bp++ = ' '; } d1721 4 a1724 4 if (m) *bp++ = '>'; *bp = 0; printf("%s\n", buf); d1729 1 a1729 1 * A wrapper to transmit a packet from if_start since ALTQ uses d1808 1 a1808 1 MODULE_CLASS_MISC) != 0) d1833 1 a1833 1 false) != NULL) d1856 1 a1856 1 false) != &pc[i]) @ 1.136.12.4 log @update from HEAD @ text @a106 1 #ifdef _KERNEL_OPT d108 1 a111 1 #endif a133 2 #include #include a167 2 #include "ioconf.h" a179 2 extern struct linesw ppp_disc; d213 1 a217 1 static int ppp_compressor_destroy(void); d227 1 a227 1 pppattach(int n __unused) d229 1 a229 12 /* * Nothing to do here, initialization is handled by the * module initialization code in pppinit() below). */ } static void pppinit(void) { /* Init the compressor sub-sub-system */ ppp_compressor_init(); d232 1 a232 1 panic("%s", __func__); d237 1 a237 20 } static int pppdetach(void) { int error = 0; if (!LIST_EMPTY(&ppp_softc_list)) error = EBUSY; if (error == 0) error = ttyldisc_detach(&ppp_disc); if (error == 0) { mutex_destroy(&ppp_list_lock); if_clone_detach(&ppp_cloner); ppp_compressor_destroy(); } return error; a766 2 printf("%s: af%d not supported\n", ifp->if_xname, ifa->ifa_addr->sa_family); a769 1 ifa->ifa_rtrequest = p2p_rtrequest; d837 1 a837 1 const struct rtentry *rtp) d849 1 d857 1 a857 1 IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family); d989 2 a990 1 if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) { d1043 2 a1044 1 if ((error = ifq_enqueue2(&sc->sc_if, ifq, m)) != 0) { d1561 1 a1561 1 mp->m_next = m_free(m); d1601 1 a1601 1 m_set_rcvif(m, ifp); a1798 8 static int ppp_compressor_destroy(void) { mutex_destroy(&ppp_compressors_mtx); return 0; } d1866 2 a1907 13 /* * Module infrastructure */ #include "if_module.h" #ifdef PPP_FILTER #define PPP_DEP "bpf_filter," #else #define PPP_DEP #endif IF_MODULE(MODULE_CLASS_DRIVER, ppp, PPP_DEP "slcompress") @ 1.136.8.1 log @Pull up following revision(s) (requested by christos in ticket #638): sys/net/if_ppp.c: revision 1.137 sys/netinet6/ip6_flow.c: revision 1.20 sys/net/if_fddisubr.c: revision 1.82 sys/net/if_ethersubr.c: revision 1.192 sys/netinet6/in6_var.h: revision 1.66 sys/net/if_atmsubr.c: revision 1.50 PR/47058: Antti Kantee: If the ipv6 flow code modifies the mbuf, pass the change up to the caller. @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d1648 1 a1648 1 if (ip6flow_fastforward(&m)) @ 1.136.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.136 2011/10/28 22:08:14 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.136 2011/10/28 22:08:14 dyoung Exp $"); d1648 1 a1648 1 if (ip6flow_fastforward(&m)) @ 1.136.2.2 log @sync with (a bit old) head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.136.2.1 2012/10/30 17:22:43 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.136.2.1 2012/10/30 17:22:43 yamt Exp $"); d1269 1 a1269 1 dp = mtod(mp, u_char *); @ 1.136.2.3 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.136.2.2 2013/01/16 05:33:48 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.136.2.2 2013/01/16 05:33:48 yamt Exp $"); d949 2 a950 2 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *)m0, len, 0) == 0) { d959 2 a960 2 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *)m0, len, 0)) d1587 2 a1588 2 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *)m, ilen, 0) == 0) { d1594 2 a1595 2 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *)m, ilen, 0)) @ 1.135 log @Don't kauth-orize SIOCSIFMTU in pppsioctl() and stf_ioctl(), ifioctl() has already done that for us. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.134 2011/08/07 13:51:37 rmind Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.134 2011/08/07 13:51:37 rmind Exp $"); a769 16 case SIOCSIFDSTADDR: switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: error = EAFNOSUPPORT; break; } break; @ 1.134 log @Convert ppp_list_lock to mutex(9). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.133 2011/04/02 08:11:32 mbalmer Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.133 2011/04/02 08:11:32 mbalmer Exp $"); a736 1 struct lwp *l = curlwp; /* XXX */ a835 6 case SIOCSIFMTU: if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL)) != 0) break; /*FALLTHROUGH*/ @ 1.133 log @Fix misplaced parenthesis. From henning.petersen@@t-online.de, thanks. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.132 2010/08/21 13:19:40 pgoyette Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.132 2010/08/21 13:19:40 pgoyette Exp $"); a132 1 #include d207 1 a211 2 static struct simplelock ppp_list_mutex = SIMPLELOCK_INITIALIZER; d233 2 d247 1 a247 1 simple_lock(&ppp_list_mutex); d283 1 a283 1 simple_unlock(&ppp_list_mutex); d325 1 a325 1 simple_lock(&ppp_list_mutex); d327 1 a327 1 simple_unlock(&ppp_list_mutex); d345 2 a346 3 simple_lock(&ppp_list_mutex); for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL; scf = LIST_NEXT(scf, sc_iflist)) { d349 1 a349 1 simple_unlock(&ppp_list_mutex); d355 1 a355 1 simple_unlock(&ppp_list_mutex); @ 1.132 log @Update the rest of the kernel to conform to the module subsystem's new locking protocol. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.131 2010/04/05 07:22:23 joerg Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.131 2010/04/05 07:22:23 joerg Exp $"); d841 1 a841 1 ifp, (void *)cmd, NULL) != 0)) @ 1.132.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.133 2011/04/02 08:11:32 mbalmer Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.133 2011/04/02 08:11:32 mbalmer Exp $"); d841 1 a841 1 ifp, (void *)cmd, NULL)) != 0) @ 1.131 log @Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf check into the inline functions as well the fourth argument for bpf_attach. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.130 2010/01/19 22:08:01 pooka Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.130 2010/01/19 22:08:01 pooka Exp $"); d1823 1 a1823 1 mutex_enter(&module_lock); d1841 1 a1841 1 mutex_exit(&module_lock); @ 1.130 log @Redefine bpf linkage through an always present op vector, i.e. #if NBPFILTER is no longer required in the client. This change doesn't yet add support for loading bpf as a module, since drivers can register before bpf is attached. However, callers of bpf can now be modularized. Dynamically loadable bpf could probably be done fairly easily with coordination from the stub driver and the real driver by registering attachments in the stub before the real driver is loaded and doing a handoff. ... and I'm not going to ponder the depths of unload here. Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.129 2009/04/15 20:44:25 elad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.129 2009/04/15 20:44:25 elad Exp $"); d307 1 a307 1 bpf_ops->bpf_attach(&sc->sc_if, DLT_NULL, 0, &sc->sc_if.if_bpf); d329 1 a329 1 bpf_ops->bpf_detach(ifp); d997 1 a997 2 if (sc->sc_if.if_bpf) bpf_ops->bpf_mtap(sc->sc_if.if_bpf, m0); d1630 1 a1630 2 if (sc->sc_if.if_bpf) bpf_ops->bpf_mtap(sc->sc_if.if_bpf, m); @ 1.130.4.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.130 2010/01/19 22:08:01 pooka Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.130 2010/01/19 22:08:01 pooka Exp $"); d307 1 a307 1 bpf_attach(&sc->sc_if, DLT_NULL, 0); d329 1 a329 1 bpf_detach(ifp); d997 2 a998 1 bpf_mtap(&sc->sc_if, m0); d1631 2 a1632 1 bpf_mtap(&sc->sc_if, m); @ 1.130.4.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d1823 1 a1823 1 kernconfig_lock(); d1841 1 a1841 1 kernconfig_unlock(); @ 1.130.4.3 log @sync with head @ text @d841 1 a841 1 ifp, (void *)cmd, NULL)) != 0) @ 1.130.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d307 1 a307 1 bpf_attach(&sc->sc_if, DLT_NULL, 0); d329 1 a329 1 bpf_detach(ifp); d997 2 a998 1 bpf_mtap(&sc->sc_if, m0); d1631 2 a1632 1 bpf_mtap(&sc->sc_if, m); @ 1.130.2.2 log @Sync with HEAD (-D20101022). @ text @d1823 1 a1823 1 kernconfig_lock(); d1841 1 a1841 1 kernconfig_unlock(); @ 1.129 log @Remove a few KAUTH_GENERIC_ISSUSER in favor of more descriptive alternatives. Discussed on tech-kern: http://mail-index.netbsd.org/tech-kern/2009/04/11/msg004798.html Input from ad@@, christos@@, dyoung@@, tsutsui@@. Okay ad@@. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.128 2009/01/19 15:16:34 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.128 2009/01/19 15:16:34 yamt Exp $"); a150 2 #include "bpfilter.h" #if NBPFILTER > 0 a151 1 #endif a152 1 #if defined(PPP_FILTER) || NBPFILTER > 0 a153 1 #endif d307 1 a307 3 #if NBPFILTER > 0 bpfattach(&sc->sc_if, DLT_NULL, 0); #endif d329 1 a329 3 #if NBPFILTER > 0 bpfdetach(ifp); #endif a993 1 #if NBPFILTER > 0 d998 1 a998 2 bpf_mtap(sc->sc_if.if_bpf, m0); #endif a1629 1 #if NBPFILTER > 0 d1632 1 a1632 2 bpf_mtap(sc->sc_if.if_bpf, m); #endif @ 1.128 log @ppp_get_compressor: take module_lock when trying to load a module. PR/40428 @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.127 2008/12/17 20:51:36 cegger Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.127 2008/12/17 20:51:36 cegger Exp $"); d501 1 a501 1 KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, (void *)cmd, d508 1 a508 1 KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, (void *)cmd, @ 1.128.2.1 log @Sync with HEAD. Commit is split, to avoid a "too many arguments" protocol error. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.129 2009/04/15 20:44:25 elad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.129 2009/04/15 20:44:25 elad Exp $"); d501 1 a501 1 KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), d508 1 a508 1 KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), @ 1.127 log @kill MALLOC and FREE macros. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.126 2008/11/29 23:15:20 cube Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.126 2008/11/29 23:15:20 cube Exp $"); d1835 7 d1856 1 @ 1.126 log @Fix handling of ppp compressor modules, from Andrew Doran's input. - ref count each compressor - allow {un,}registration of several modules at once - une RUN_ONCE to make sure the mutex is initialised, because unfortunately built-in (and bootloader-loaded) modules init functions are run before pseudo-devices attach (reported by Nick Hudson). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.125 2008/11/25 02:40:36 cube Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.125 2008/11/25 02:40:36 cube Exp $"); d250 1 a250 1 MALLOC(sc, struct ppp_softc *, sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d275 1 a275 1 FREE(sc, M_DEVBUF); d341 1 a341 1 FREE(sc, M_DEVBUF); d380 1 a380 2 MALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); d443 1 a443 1 FREE(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); d448 1 a448 1 FREE(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); d453 1 a453 1 FREE(sc->sc_active_filt_in.bf_insns, M_DEVBUF); d458 1 a458 1 FREE(sc->sc_active_filt_out.bf_insns, M_DEVBUF); d465 1 a465 1 FREE(sc->sc_comp, M_DEVBUF); @ 1.125 log @Rework the way PPP compmressors are handled and allow them to be automatically loaded when needed. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.124 2008/11/07 00:20:13 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.124 2008/11/07 00:20:13 dyoung Exp $"); d129 1 d220 1 d224 1 d226 1 d242 1 a242 1 mutex_init(&ppp_compressors_mtx, MUTEX_DEFAULT, IPL_NONE); d608 1 a608 1 module_rele(sc->sc_xcomp->comp_name); d625 1 a625 1 module_rele(sc->sc_rcomp->comp_name); d1391 1 a1391 1 module_rele(sc->sc_xcomp->comp_name); d1396 1 a1396 1 module_rele(sc->sc_rcomp->comp_name); d1793 17 d1815 1 a1815 1 mutex_enter(&ppp_compressors_mtx); d1818 2 a1819 3 mutex_exit(&ppp_compressors_mtx); if (hold && module_hold(cp->comp_name) != 0) return NULL; a1822 1 mutex_exit(&ppp_compressors_mtx); d1830 1 a1830 1 struct compressor *cp; d1833 13 a1845 7 if ((cp = ppp_get_compressor_noload(ci, true)) != NULL) return cp; /* Not found, so try to autoload a module */ for (pkc = ppp_known_compressors; pkc->module != NULL; pkc++) { if (pkc->code == ci) { if (module_autoload(pkc->module, MODULE_CLASS_MISC)) d1847 1 a1847 1 return ppp_get_compressor_noload(ci, true); d1851 1 a1851 1 return NULL; d1855 1 a1855 1 ppp_register_compressor(struct compressor *pc) d1857 2 d1860 1 a1860 2 if (ppp_get_compressor_noload(pc->compress_proto, false) != NULL) return EEXIST; d1863 11 a1873 1 LIST_INSERT_HEAD(&ppp_compressors, pc, comp_list); d1876 1 a1876 1 return 0; d1880 1 a1880 1 ppp_unregister_compressor(struct compressor *pc) d1882 2 a1883 3 if (ppp_get_compressor_noload(pc->compress_proto, false) != pc) return ENOENT; d1886 12 a1897 1 LIST_REMOVE(pc, comp_list); d1900 1 a1900 1 return 0; @ 1.124 log @*** Summary *** When a link-layer address changes (e.g., ifconfig ex0 link 02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor Advertisement to update the network-/link-layer address bindings on our LAN peers. Refuse a change of ethernet address to the address 00:00:00:00:00:00 or to any multicast/broadcast address. (Thanks matt@@.) Reorder ifnet ioctl operations so that driver ioctls may inherit the functions of their "class"---ether_ioctl(), fddi_ioctl(), et cetera---and the class ioctls may inherit from the generic ioctl, ifioctl_common(), but both driver- and class-ioctls may override the generic behavior. Make network drivers share more code. Distinguish a "factory" link-layer address from others for the purposes of both protecting that address from deletion and computing EUI64. Return consistent, appropriate error codes from network drivers. Improve readability. KNF. *** Details *** In if_attach(), always initialize the interface ioctl routine, ifnet->if_ioctl, if the driver has not already initialized it. Delete if_ioctl == NULL tests everywhere else, because it cannot happen. In the ioctl routines of network interfaces, inherit common ioctl behaviors by calling either ifioctl_common() or whichever ioctl routine is appropriate for the class of interface---e.g., ether_ioctl() for ethernets. Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In the user->kernel interface, SIOCSIFADDR's argument was an ifreq, but on the protocol->ifnet interface, SIOCSIFADDR's argument was an ifaddr. That was confusing, and it would work against me as I make it possible for a network interface to overload most ioctls. On the protocol->ifnet interface, replace SIOCSIFADDR with SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to invoke SIOCINITIFADDR. In ifioctl(), give the interface the first shot at handling most interface ioctls, and give the protocol the second shot, instead of the other way around. Finally, let compatibility code (COMPAT_OSOCK) take a shot. Pull device initialization out of switch statements under SIOCINITIFADDR. For example, pull ..._init() out of any switch statement that looks like this: switch (...->sa_family) { case ...: ..._init(); ... break; ... default: ..._init(); ... break; } Rewrite many if-else clauses that handle all permutations of IFF_UP and IFF_RUNNING to use a switch statement, switch (x & (IFF_UP|IFF_RUNNING)) { case 0: ... break; case IFF_RUNNING: ... break; case IFF_UP: ... break; case IFF_UP|IFF_RUNNING: ... break; } unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and #ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4). In ipw(4), remove an if_set_sadl() call that is out of place. In nfe(4), reuse the jumbo MTU logic in ether_ioctl(). Let ethernets register a callback for setting h/w state such as promiscuous mode and the multicast filter in accord with a change in the if_flags: ether_set_ifflags_cb() registers a callback that returns ENETRESET if the caller should reset the ethernet by calling if_init(), 0 on success, != 0 on failure. Pull common code from ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(), and register if_flags callbacks for those drivers. Return ENOTTY instead of EINVAL for inappropriate ioctls. In zyd(4), use ENXIO instead of ENOTTY to indicate that the device is not any longer attached. Add to if_set_sadl() a boolean 'factory' argument that indicates whether a link-layer address was assigned by the factory or some other source. In a comment, recommend using the factory address for generating an EUI64, and update in6_get_hw_ifid() to prefer a factory address to any other link-layer address. Add a routing message, RTM_LLINFO_UPD, that tells protocols to update the binding of network-layer addresses to link-layer addresses. Implement this message in IPv4 and IPv6 by sending a gratuitous ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD messages on a change of an interface's link-layer address. In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address that is broadcast/multicast or equal to 00:00:00:00:00:00. Make ether_ioctl() call ifioctl_common() to handle ioctls that it does not understand. In gif(4), initialize if_softc and use it, instead of assuming that the gif_softc and ifp overlap. Let ifioctl_common() handle SIOCGIFADDR. Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels that certain invariants on a struct route are satisfied. In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit about the ioctls that we do not allow on an agr(4) member interface. bzero -> memset. Delete unnecessary casts to void *. Use sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with NULL instead of "testing truth". Replace some instances of (type *)0 with NULL. Change some K&R prototypes to ANSI C, and join lines. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.123 2008/06/15 16:37:21 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.123 2008/06/15 16:37:21 christos Exp $"); d127 2 d219 2 a220 4 /* * List of compressors we know about. * We leave some space so maybe we can modload compressors. */ d222 1 a222 13 extern struct compressor ppp_bsd_compress; extern struct compressor ppp_deflate, ppp_deflate_draft; struct compressor *ppp_compressors[PPP_COMPRESSORS_MAX] = { #if DO_BSD_COMPRESS && defined(PPP_BSDCOMP) &ppp_bsd_compress, #endif #if DO_DEFLATE && defined(PPP_DEFLATE) &ppp_deflate, &ppp_deflate_draft, #endif NULL }; d238 1 d479 1 a479 1 struct compressor **cp; d587 43 a629 39 for (cp = ppp_compressors; *cp != NULL; ++cp) if ((*cp)->compress_proto == ccp_option[0]) { /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); sc->sc_xcomp = *cp; sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); sc->sc_rcomp = *cp; sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); d631 5 a635 5 if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ d1387 1 d1392 1 d1777 79 @ 1.123 log @- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD) - kill memsets where M_ZERO can be used. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.122 2008/04/24 11:38:37 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.122 2008/04/24 11:38:37 ad Exp $"); d763 2 d769 1 a769 1 case SIOCSIFADDR: a800 11 case SIOCSIFMTU: if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) break; /*FALLTHROUGH*/ case SIOCGIFMTU: if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; d851 6 d858 3 a860 1 error = EINVAL; @ 1.123.4.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.127 2008/12/17 20:51:36 cegger Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.127 2008/12/17 20:51:36 cegger Exp $"); a126 3 #include #include #include d217 18 a234 7 ONCE_DECL(ppp_compressor_mtx_init); static LIST_HEAD(, compressor) ppp_compressors = { NULL }; static kmutex_t ppp_compressors_mtx; static int ppp_compressor_init(void); static struct compressor *ppp_get_compressor(uint8_t); static void ppp_compressor_rele(struct compressor *); a249 1 RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d257 1 a257 1 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d282 1 a282 1 free(sc, M_DEVBUF); d348 1 a348 1 free(sc, M_DEVBUF); d387 2 a388 1 sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); d451 1 a451 1 free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); d456 1 a456 1 free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); d461 1 a461 1 free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); d466 1 a466 1 free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); d473 1 a473 1 free(sc->sc_comp, M_DEVBUF); d490 1 a490 1 struct compressor *cp; d598 39 a636 18 cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); d638 5 a642 30 sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); a762 2 if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; d767 1 a767 1 case SIOCINITIFADDR: d799 11 a859 6 case SIOCSIFMTU: if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) break; /*FALLTHROUGH*/ d861 1 a861 3 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; a1394 1 ppp_compressor_rele(sc->sc_xcomp); a1398 1 ppp_compressor_rele(sc->sc_rcomp); a1782 121 static const struct ppp_known_compressor { uint8_t code; const char *module; } ppp_known_compressors[] = { { CI_DEFLATE, "ppp_deflate" }, { CI_DEFLATE_DRAFT, "ppp_deflate" }, { CI_BSD_COMPRESS, "ppp_bsdcomp" }, { CI_MPPE, "ppp_mppe" }, { 0, NULL } }; static int ppp_compressor_init(void) { mutex_init(&ppp_compressors_mtx, MUTEX_DEFAULT, IPL_NONE); return 0; } static void ppp_compressor_rele(struct compressor *cp) { mutex_enter(&ppp_compressors_mtx); --cp->comp_refcnt; mutex_exit(&ppp_compressors_mtx); } static struct compressor * ppp_get_compressor_noload(uint8_t ci, bool hold) { struct compressor *cp; KASSERT(mutex_owned(&ppp_compressors_mtx)); LIST_FOREACH(cp, &ppp_compressors, comp_list) { if (cp->compress_proto == ci) { if (hold) ++cp->comp_refcnt; return cp; } } return NULL; } static struct compressor * ppp_get_compressor(uint8_t ci) { struct compressor *cp = NULL; const struct ppp_known_compressor *pkc; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp == NULL) { /* Not found, so try to autoload a module */ for (pkc = ppp_known_compressors; pkc->module != NULL; pkc++) { if (pkc->code == ci) { if (module_autoload(pkc->module, MODULE_CLASS_MISC) != 0) break; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); break; } } } return cp; } int ppp_register_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != NULL) error = EEXIST; } if (!error) { for (i = 0; i < ncomp; i++) { pc[i].comp_refcnt = 0; LIST_INSERT_HEAD(&ppp_compressors, &pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } int ppp_unregister_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != &pc[i]) error = ENOENT; else if (pc[i].comp_refcnt != 0) error = EBUSY; } if (!error) { for (i = 0; i < ncomp; i++) { LIST_REMOVE(&pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } @ 1.123.4.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.123.4.1 2009/01/19 13:20:11 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.123.4.1 2009/01/19 13:20:11 skrll Exp $"); a1834 7 if (cp != NULL) return cp; mutex_enter(&module_lock); mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); a1848 1 mutex_exit(&module_lock); @ 1.123.4.3 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.123.4.2 2009/03/03 18:33:38 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.123.4.2 2009/03/03 18:33:38 skrll Exp $"); d501 1 a501 1 KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), d508 1 a508 1 KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), @ 1.123.2.1 log @Update haad-dm branch to haad-dm-base2. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.126 2008/11/29 23:15:20 cube Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.126 2008/11/29 23:15:20 cube Exp $"); a126 3 #include #include #include d217 18 a234 7 ONCE_DECL(ppp_compressor_mtx_init); static LIST_HEAD(, compressor) ppp_compressors = { NULL }; static kmutex_t ppp_compressors_mtx; static int ppp_compressor_init(void); static struct compressor *ppp_get_compressor(uint8_t); static void ppp_compressor_rele(struct compressor *); a249 1 RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d490 1 a490 1 struct compressor *cp; d598 39 a636 18 cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); d638 5 a642 30 sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); a762 2 if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; d767 1 a767 1 case SIOCINITIFADDR: d799 11 a859 6 case SIOCSIFMTU: if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) break; /*FALLTHROUGH*/ d861 1 a861 3 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; a1394 1 ppp_compressor_rele(sc->sc_xcomp); a1398 1 ppp_compressor_rele(sc->sc_rcomp); a1782 121 static const struct ppp_known_compressor { uint8_t code; const char *module; } ppp_known_compressors[] = { { CI_DEFLATE, "ppp_deflate" }, { CI_DEFLATE_DRAFT, "ppp_deflate" }, { CI_BSD_COMPRESS, "ppp_bsdcomp" }, { CI_MPPE, "ppp_mppe" }, { 0, NULL } }; static int ppp_compressor_init(void) { mutex_init(&ppp_compressors_mtx, MUTEX_DEFAULT, IPL_NONE); return 0; } static void ppp_compressor_rele(struct compressor *cp) { mutex_enter(&ppp_compressors_mtx); --cp->comp_refcnt; mutex_exit(&ppp_compressors_mtx); } static struct compressor * ppp_get_compressor_noload(uint8_t ci, bool hold) { struct compressor *cp; KASSERT(mutex_owned(&ppp_compressors_mtx)); LIST_FOREACH(cp, &ppp_compressors, comp_list) { if (cp->compress_proto == ci) { if (hold) ++cp->comp_refcnt; return cp; } } return NULL; } static struct compressor * ppp_get_compressor(uint8_t ci) { struct compressor *cp = NULL; const struct ppp_known_compressor *pkc; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp == NULL) { /* Not found, so try to autoload a module */ for (pkc = ppp_known_compressors; pkc->module != NULL; pkc++) { if (pkc->code == ci) { if (module_autoload(pkc->module, MODULE_CLASS_MISC) != 0) break; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); break; } } } return cp; } int ppp_register_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != NULL) error = EEXIST; } if (!error) { for (i = 0; i < ncomp; i++) { pc[i].comp_refcnt = 0; LIST_INSERT_HEAD(&ppp_compressors, &pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } int ppp_unregister_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != &pc[i]) error = ENOENT; else if (pc[i].comp_refcnt != 0) error = EBUSY; } if (!error) { for (i = 0; i < ncomp; i++) { LIST_REMOVE(&pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } @ 1.122 log @Merge the socket locking patch: - Socket layer becomes MP safe. - Unix protocols become MP safe. - Allows protocol processing interrupts to safely block on locks. - Fixes a number of race conditions. With much feedback from matt@@ and plunky@@. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.121 2008/02/07 01:22:01 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.121 2008/02/07 01:22:01 dyoung Exp $"); d297 1 a297 2 (void)snprintf(sc->sc_if.if_xname, sizeof(sc->sc_if.if_xname), "%s%d", name, sc->sc_unit = unit); @ 1.122.2.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.122 2008/04/24 11:38:37 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.122 2008/04/24 11:38:37 ad Exp $"); a126 3 #include #include #include d217 18 a234 7 ONCE_DECL(ppp_compressor_mtx_init); static LIST_HEAD(, compressor) ppp_compressors = { NULL }; static kmutex_t ppp_compressors_mtx; static int ppp_compressor_init(void); static struct compressor *ppp_get_compressor(uint8_t); static void ppp_compressor_rele(struct compressor *); a249 1 RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d257 1 a257 1 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d282 1 a282 1 free(sc, M_DEVBUF); d297 2 a298 1 if_initname(&sc->sc_if, name, sc->sc_unit = unit); d349 1 a349 1 free(sc, M_DEVBUF); d388 2 a389 1 sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); d452 1 a452 1 free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); d457 1 a457 1 free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); d462 1 a462 1 free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); d467 1 a467 1 free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); d474 1 a474 1 free(sc->sc_comp, M_DEVBUF); d491 1 a491 1 struct compressor *cp; d510 1 a510 1 KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, KAUTH_ARG(cmd), d517 1 a517 1 KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, KAUTH_ARG(cmd), d599 39 a637 18 cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); d639 5 a643 30 sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); a763 2 if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; d768 1 a768 1 case SIOCINITIFADDR: d800 11 a860 6 case SIOCSIFMTU: if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) break; /*FALLTHROUGH*/ d862 1 a862 3 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; a1395 1 ppp_compressor_rele(sc->sc_xcomp); a1399 1 ppp_compressor_rele(sc->sc_rcomp); a1783 129 static const struct ppp_known_compressor { uint8_t code; const char *module; } ppp_known_compressors[] = { { CI_DEFLATE, "ppp_deflate" }, { CI_DEFLATE_DRAFT, "ppp_deflate" }, { CI_BSD_COMPRESS, "ppp_bsdcomp" }, { CI_MPPE, "ppp_mppe" }, { 0, NULL } }; static int ppp_compressor_init(void) { mutex_init(&ppp_compressors_mtx, MUTEX_DEFAULT, IPL_NONE); return 0; } static void ppp_compressor_rele(struct compressor *cp) { mutex_enter(&ppp_compressors_mtx); --cp->comp_refcnt; mutex_exit(&ppp_compressors_mtx); } static struct compressor * ppp_get_compressor_noload(uint8_t ci, bool hold) { struct compressor *cp; KASSERT(mutex_owned(&ppp_compressors_mtx)); LIST_FOREACH(cp, &ppp_compressors, comp_list) { if (cp->compress_proto == ci) { if (hold) ++cp->comp_refcnt; return cp; } } return NULL; } static struct compressor * ppp_get_compressor(uint8_t ci) { struct compressor *cp = NULL; const struct ppp_known_compressor *pkc; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp != NULL) return cp; mutex_enter(&module_lock); mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp == NULL) { /* Not found, so try to autoload a module */ for (pkc = ppp_known_compressors; pkc->module != NULL; pkc++) { if (pkc->code == ci) { if (module_autoload(pkc->module, MODULE_CLASS_MISC) != 0) break; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); break; } } } mutex_exit(&module_lock); return cp; } int ppp_register_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != NULL) error = EEXIST; } if (!error) { for (i = 0; i < ncomp; i++) { pc[i].comp_refcnt = 0; LIST_INSERT_HEAD(&ppp_compressors, &pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } int ppp_unregister_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != &pc[i]) error = ENOENT; else if (pc[i].comp_refcnt != 0) error = EBUSY; } if (!error) { for (i = 0; i < ncomp; i++) { LIST_REMOVE(&pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } @ 1.122.2.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.122.2.1 2009/05/04 08:14:15 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.122.2.1 2009/05/04 08:14:15 yamt Exp $"); d151 2 d154 1 d156 1 d158 1 d312 3 a314 1 bpf_ops->bpf_attach(&sc->sc_if, DLT_NULL, 0, &sc->sc_if.if_bpf); d336 3 a338 1 bpf_ops->bpf_detach(ifp); d1003 1 d1008 2 a1009 1 bpf_ops->bpf_mtap(sc->sc_if.if_bpf, m0); d1641 1 d1644 2 a1645 1 bpf_ops->bpf_mtap(sc->sc_if.if_bpf, m); @ 1.122.2.3 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.122.2.2 2010/03/11 15:04:27 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.122.2.2 2010/03/11 15:04:27 yamt Exp $"); d307 1 a307 1 bpf_attach(&sc->sc_if, DLT_NULL, 0); d329 1 a329 1 bpf_detach(ifp); d997 2 a998 1 bpf_mtap(&sc->sc_if, m0); d1631 2 a1632 1 bpf_mtap(&sc->sc_if, m); @ 1.122.2.4 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.122.2.3 2010/08/11 22:54:54 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.122.2.3 2010/08/11 22:54:54 yamt Exp $"); d1823 1 a1823 1 kernconfig_lock(); d1841 1 a1841 1 kernconfig_unlock(); @ 1.122.4.1 log @Sync w/ -current. 34 merge conflicts to follow. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.122 2008/04/24 11:38:37 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.122 2008/04/24 11:38:37 ad Exp $"); d297 2 a298 1 if_initname(&sc->sc_if, name, sc->sc_unit = unit); @ 1.122.6.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.123 2008/06/15 16:37:21 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.123 2008/06/15 16:37:21 christos Exp $"); d297 2 a298 1 if_initname(&sc->sc_if, name, sc->sc_unit = unit); @ 1.121 log @Start patching up the kernel so that a network driver always has the opportunity to handle an ioctl before generic ifioctl handling occurs. This will ease extending the kernel and sharing of code between drivers. First steps: Make the signature of ifioctl_common() match struct ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new ifioctl() regime, throughout the kernel. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.120 2008/01/04 21:18:15 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.120 2008/01/04 21:18:15 ad Exp $"); d131 1 d1272 1 d1289 1 @ 1.121.6.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); a130 1 #include a1270 1 mutex_enter(softnet_lock); a1286 1 mutex_exit(softnet_lock); @ 1.121.6.2 log @Sync with HEAD. @ text @d297 2 a298 1 if_initname(&sc->sc_if, name, sc->sc_unit = unit); @ 1.121.6.3 log @Sync with HEAD. @ text @a126 3 #include #include #include d217 18 a234 7 ONCE_DECL(ppp_compressor_mtx_init); static LIST_HEAD(, compressor) ppp_compressors = { NULL }; static kmutex_t ppp_compressors_mtx; static int ppp_compressor_init(void); static struct compressor *ppp_get_compressor(uint8_t); static void ppp_compressor_rele(struct compressor *); a249 1 RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); d257 1 a257 1 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); d282 1 a282 1 free(sc, M_DEVBUF); d348 1 a348 1 free(sc, M_DEVBUF); d387 2 a388 1 sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT); d451 1 a451 1 free(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); d456 1 a456 1 free(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); d461 1 a461 1 free(sc->sc_active_filt_in.bf_insns, M_DEVBUF); d466 1 a466 1 free(sc->sc_active_filt_out.bf_insns, M_DEVBUF); d473 1 a473 1 free(sc->sc_comp, M_DEVBUF); d490 1 a490 1 struct compressor *cp; d598 39 a636 18 cp = ppp_get_compressor(ccp_option[0]); if (cp == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ } /* * Found a handler for the protocol - try to allocate * a compressor or decompressor. */ error = 0; if (odp->transmit) { s = splsoftnet(); if (sc->sc_xc_state != NULL) { (*sc->sc_xcomp->comp_free)(sc->sc_xc_state); ppp_compressor_rele(sc->sc_xcomp); d638 5 a642 30 sc->sc_xcomp = cp; sc->sc_xc_state = cp->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_COMP_RUN; splx(s); } else { s = splsoftnet(); if (sc->sc_rc_state != NULL) { (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state); ppp_compressor_rele(sc->sc_rcomp); } sc->sc_rcomp = cp; sc->sc_rc_state = cp->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); /* XXX IMP ME HARDER */ sc->sc_flags &= ~SC_DECOMP_RUN; splx(s); } return (error); a762 2 if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; d767 1 a767 1 case SIOCINITIFADDR: d799 11 a859 6 case SIOCSIFMTU: if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) break; /*FALLTHROUGH*/ d861 1 a861 3 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; break; a1394 1 ppp_compressor_rele(sc->sc_xcomp); a1398 1 ppp_compressor_rele(sc->sc_rcomp); a1782 121 static const struct ppp_known_compressor { uint8_t code; const char *module; } ppp_known_compressors[] = { { CI_DEFLATE, "ppp_deflate" }, { CI_DEFLATE_DRAFT, "ppp_deflate" }, { CI_BSD_COMPRESS, "ppp_bsdcomp" }, { CI_MPPE, "ppp_mppe" }, { 0, NULL } }; static int ppp_compressor_init(void) { mutex_init(&ppp_compressors_mtx, MUTEX_DEFAULT, IPL_NONE); return 0; } static void ppp_compressor_rele(struct compressor *cp) { mutex_enter(&ppp_compressors_mtx); --cp->comp_refcnt; mutex_exit(&ppp_compressors_mtx); } static struct compressor * ppp_get_compressor_noload(uint8_t ci, bool hold) { struct compressor *cp; KASSERT(mutex_owned(&ppp_compressors_mtx)); LIST_FOREACH(cp, &ppp_compressors, comp_list) { if (cp->compress_proto == ci) { if (hold) ++cp->comp_refcnt; return cp; } } return NULL; } static struct compressor * ppp_get_compressor(uint8_t ci) { struct compressor *cp = NULL; const struct ppp_known_compressor *pkc; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); if (cp == NULL) { /* Not found, so try to autoload a module */ for (pkc = ppp_known_compressors; pkc->module != NULL; pkc++) { if (pkc->code == ci) { if (module_autoload(pkc->module, MODULE_CLASS_MISC) != 0) break; mutex_enter(&ppp_compressors_mtx); cp = ppp_get_compressor_noload(ci, true); mutex_exit(&ppp_compressors_mtx); break; } } } return cp; } int ppp_register_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init); mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != NULL) error = EEXIST; } if (!error) { for (i = 0; i < ncomp; i++) { pc[i].comp_refcnt = 0; LIST_INSERT_HEAD(&ppp_compressors, &pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } int ppp_unregister_compressor(struct compressor *pc, size_t ncomp) { int error = 0; size_t i; mutex_enter(&ppp_compressors_mtx); for (i = 0; i < ncomp; i++) { if (ppp_get_compressor_noload(pc[i].compress_proto, false) != &pc[i]) error = ENOENT; else if (pc[i].comp_refcnt != 0) error = EBUSY; } if (!error) { for (i = 0; i < ncomp; i++) { LIST_REMOVE(&pc[i], comp_list); } } mutex_exit(&ppp_compressors_mtx); return error; } @ 1.121.8.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.121 2008/02/07 01:22:01 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.121 2008/02/07 01:22:01 dyoung Exp $"); a130 1 #include a1270 1 mutex_enter(softnet_lock); a1286 1 mutex_exit(softnet_lock); @ 1.121.8.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.121.8.1 2008/05/18 12:35:27 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.121.8.1 2008/05/18 12:35:27 yamt Exp $"); d297 2 a298 1 if_initname(&sc->sc_if, name, sc->sc_unit = unit); @ 1.120 log @Start detangling lock.h from intr.h. This is likely to cause short term breakage, but the mess of dependencies has been regularly breaking the build recently anyhow. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.119 2007/10/19 12:16:44 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.119 2007/10/19 12:16:44 ad Exp $"); d804 1 a804 3 sc->sc_if.if_mtu = ifr->ifr_mtu; break; d806 2 a807 1 ifr->ifr_mtu = sc->sc_if.if_mtu; @ 1.119 log @machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.118 2007/10/08 16:18:05 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.118 2007/10/08 16:18:05 ad Exp $"); d130 1 @ 1.119.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.121 2008/02/07 01:22:01 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.121 2008/02/07 01:22:01 dyoung Exp $"); a129 1 #include d803 3 a805 1 /*FALLTHROUGH*/ d807 1 a807 2 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; @ 1.119.8.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); a129 1 #include @ 1.118 log @Use the softint API. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $"); d162 1 a162 1 #include @ 1.118.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); d162 1 a162 1 #include @ 1.117 log @Use ifreq_setaddr(), ifreq_getaddr(), sockaddr_in_init(), and sockaddr_copy(). Constify. Compare pointers with NULL, not 0. Don't "test truth" of pointers, but compare with NULL. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.116 2007/07/14 21:02:40 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.116 2007/07/14 21:02:40 ad Exp $"); d129 1 a138 2 #include d376 1 a376 1 sc->sc_si = softintr_establish(IPL_SOFTNET, pppintr, sc); d412 1 a412 1 softintr_disestablish(sc->sc_si); d1111 1 a1111 1 softintr_schedule(sc->sc_si); d1416 1 a1416 1 softintr_schedule(sc->sc_si); @ 1.117.2.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $"); a128 1 #include d138 2 d377 1 a377 1 sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); d413 1 a413 1 softint_disestablish(sc->sc_si); d1112 1 a1112 1 softint_schedule(sc->sc_si); d1417 1 a1417 1 softint_schedule(sc->sc_si); @ 1.116 log @Generic soft interrupts are mandatory. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.115 2007/07/09 21:11:00 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.115 2007/07/09 21:11:00 ad Exp $"); d813 1 a813 1 if (ifr == 0) { d817 1 a817 1 switch (ifr->ifr_addr.sa_family) { @ 1.116.8.1 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.119 2007/10/19 12:16:44 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.119 2007/10/19 12:16:44 ad Exp $"); a128 1 #include d138 2 d163 1 a163 1 #include d377 1 a377 1 sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); d413 1 a413 1 softint_disestablish(sc->sc_si); d813 1 a813 1 if (ifr == NULL) { d817 1 a817 1 switch (ifreq_getaddr(cmd, ifr)->sa_family) { d1112 1 a1112 1 softint_schedule(sc->sc_si); d1417 1 a1417 1 softint_schedule(sc->sc_si); @ 1.116.8.2 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.116.8.1 2007/11/06 23:33:32 matt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.116.8.1 2007/11/06 23:33:32 matt Exp $"); a129 1 #include @ 1.116.8.3 log @sync with HEAD @ text @d1 1 a1 1 /* if_ppp.c,v 1.116.8.2 2008/01/09 01:57:12 matt Exp */ d105 1 a105 1 __KERNEL_RCSID(0, "if_ppp.c,v 1.116.8.2 2008/01/09 01:57:12 matt Exp"); d804 3 a806 1 /*FALLTHROUGH*/ d808 1 a808 2 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; @ 1.116.6.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $"); d813 1 a813 1 if (ifr == NULL) { d817 1 a817 1 switch (ifreq_getaddr(cmd, ifr)->sa_family) { @ 1.116.6.2 log @Sync with HEAD. Follow the merge of pmap.c on i386 and amd64 and move pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup code to restore CR4 before jumping back into kernel space as the large page option might cover that. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.116.6.1 2007/09/03 16:48:56 jmcneill Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.116.6.1 2007/09/03 16:48:56 jmcneill Exp $"); a128 1 #include d138 2 d163 1 a163 1 #include d377 1 a377 1 sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); d413 1 a413 1 softint_disestablish(sc->sc_si); d1112 1 a1112 1 softint_schedule(sc->sc_si); d1417 1 a1417 1 softint_schedule(sc->sc_si); @ 1.116.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $"); d813 1 a813 1 if (ifr == NULL) { d817 1 a817 1 switch (ifreq_getaddr(cmd, ifr)->sa_family) { @ 1.115 log @Merge some of the less invasive changes from the vmlocking branch: - kthread, callout, devsw API changes - select()/poll() improvements - miscellaneous MT safety improvements @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114 2007/03/07 22:20:05 liamjfoy Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114 2007/03/07 22:20:05 liamjfoy Exp $"); a179 3 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS void pppnetisr(void); #endif a376 1 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS a381 1 #endif a412 1 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS a413 1 #endif a1111 1 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS a1112 3 #else schednetisr(NETISR_PPP); #endif a1261 12 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS void pppnetisr(void) { struct ppp_softc *sc; for (sc = LIST_FIRST(&ppp_softc_list); sc != NULL; sc = LIST_NEXT(sc, sc_iflist)) pppintr(sc); } #endif a1416 1 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS a1417 3 #else schednetisr(NETISR_PPP); #endif @ 1.114 log @Add IPv6 Fast Forward - the IPv4 counterpart: If ip6_forward successfully forwards a packet, a cache, in this case a ip6flow struct entry, will be created. ether_input and friends will then be able to call ip6flow_fastforward with the packet which will then be passed to if_output (unless an issue is found - in that case the packet is passed back to ip6_input). ok matt@@ christos@@ dyoung@@ and joerg@@ @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.113 2007/03/04 06:03:16 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.113 2007/03/04 06:03:16 christos Exp $"); d301 1 a301 1 callout_init(&sc->sc_timo_ch); @ 1.114.4.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.115 2007/07/09 21:11:00 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.115 2007/07/09 21:11:00 ad Exp $"); d301 1 a301 1 callout_init(&sc->sc_timo_ch, 0); @ 1.114.2.1 log @- Increase the number of thread priorities from 128 to 256. How the space is set up is to be revisited. - Implement soft interrupts as kernel threads. A generic implementation is provided, with hooks for fast-path MD code that can run the interrupt threads over the top of other threads executing in the kernel. - Split vnode::v_flag into three fields, depending on how the flag is locked (by the interlock, by the vnode lock, by the file system). - Miscellaneous locking fixes and improvements. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114 2007/03/07 22:20:05 liamjfoy Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114 2007/03/07 22:20:05 liamjfoy Exp $"); a128 1 #include d138 2 d381 1 a381 1 sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); d419 1 a419 1 softint_disestablish(sc->sc_si); d1120 1 a1120 1 softint_schedule(sc->sc_si); d1441 1 a1441 1 softint_schedule(sc->sc_si); @ 1.114.2.2 log @Adapt to callout API change. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114.2.1 2007/06/17 21:31:50 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114.2.1 2007/06/17 21:31:50 ad Exp $"); d300 1 a300 1 callout_init(&sc->sc_timo_ch, 0); @ 1.114.2.3 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114.2.2 2007/07/01 21:50:44 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114.2.2 2007/07/01 21:50:44 ad Exp $"); d179 3 d1272 12 @ 1.114.2.4 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114.2.3 2007/07/15 13:27:53 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114.2.3 2007/07/15 13:27:53 ad Exp $"); d376 1 d382 1 d414 1 d416 1 d1115 1 d1117 3 d1424 1 d1426 3 @ 1.114.2.5 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114.2.4 2007/07/15 15:52:59 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114.2.4 2007/07/15 15:52:59 ad Exp $"); d812 1 a812 1 if (ifr == NULL) { d816 1 a816 1 switch (ifreq_getaddr(cmd, ifr)->sa_family) { @ 1.114.2.6 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.114.2.5 2007/10/09 15:22:26 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.114.2.5 2007/10/09 15:22:26 ad Exp $"); d162 1 a162 1 #include @ 1.113 log @Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.112 2007/02/17 22:34:08 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.112 2007/02/17 22:34:08 dyoung Exp $"); d1715 4 @ 1.112 log @KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous parentheses in return statements. Cosmetic: don't open-code TAILQ_FOREACH(). Cosmetic: change types of variables to avoid oodles of casts: in in6_src.c, avoid casts by changing several route_in6 pointers to struct route pointers. Remove unnecessary casts to caddr_t elsewhere. Pave the way for eliminating address family-specific route caches: soon, struct route will not embed a sockaddr, but it will hold a reference to an external sockaddr, instead. We will set the destination sockaddr using rtcache_setdst(). (I created a stub for it, but it isn't used anywhere, yet.) rtcache_free() will free the sockaddr. I have extracted from rtcache_free() a helper subroutine, rtcache_clear(). rtcache_clear() will "forget" a cached route, but it will not forget the destination by releasing the sockaddr. I use rtcache_clear() instead of rtcache_free() in rtcache_update(), because rtcache_update() is not supposed to forget the destination. Constify: 1 Introduce const accessor for route->ro_dst, rtcache_getdst(). 2 Constify the 'dst' argument to ifnet->if_output(). This led me to constify a lot of code called by output routines. 3 Constify the sockaddr argument to protosw->pr_ctlinput. This led me to constify a lot of code called by ctlinput routines. 4 Introduce const macros for converting from a generic sockaddr to family-specific sockaddrs, e.g., sockaddr_in: satocsin6, satocsin, et cetera. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.111 2006/11/16 01:33:40 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.111 2006/11/16 01:33:40 christos Exp $"); d170 1 a170 1 static int pppsioctl(struct ifnet *, u_long, caddr_t); d491 1 a491 1 pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag, d705 1 a705 1 if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode, d756 1 a756 1 pppsioctl(struct ifnet *ifp, u_long cmd, caddr_t data) d1636 1 a1636 1 m_copydata(m, 0, ilen, mtod(mp, caddr_t)); @ 1.111 log @__unused removal on arguments; approved by core. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.110 2006/10/25 20:28:45 elad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.110 2006/10/25 20:28:45 elad Exp $"); d880 1 a880 1 pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, @ 1.111.4.1 log @- sync with head. - move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.111 2006/11/16 01:33:40 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.111 2006/11/16 01:33:40 christos Exp $"); d880 1 a880 1 pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, @ 1.111.4.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.111.4.1 2007/02/27 16:54:43 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.111.4.1 2007/02/27 16:54:43 yamt Exp $"); d170 1 a170 1 static int pppsioctl(struct ifnet *, u_long, void *); d491 1 a491 1 pppioctl(struct ppp_softc *sc, u_long cmd, void *data, int flag, d705 1 a705 1 if ((error = copyin((void *)nbp->bf_insns, (void *)newcode, d756 1 a756 1 pppsioctl(struct ifnet *ifp, u_long cmd, void *data) d1636 1 a1636 1 m_copydata(m, 0, ilen, mtod(mp, void *)); a1714 4 #ifdef GATEWAY if (ip6flow_fastforward(m)) return; #endif @ 1.110 log @Kill some KAUTH_GENERIC_ISSUSER uses. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.109 2006/10/12 01:32:28 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.109 2006/10/12 01:32:28 christos Exp $"); d491 1 a491 1 pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag __unused, d881 1 a881 1 struct rtentry *rtp __unused) @ 1.109 log @- sprinkle __unused on function decls. - fix a couple of unused bugs - no more -Wno-unused for i386 @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.108 2006/07/23 22:06:12 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.108 2006/07/23 22:06:12 ad Exp $"); a512 1 case PPPIOCXFERUNIT: d515 12 a526 4 if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0) return (error); /* FALLTHROUGH */ d807 3 a809 2 if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0) @ 1.108 log @Use the LWP cached credentials where sane. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.107 2006/06/07 22:33:42 kardel Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.107 2006/06/07 22:33:42 kardel Exp $"); d491 2 a492 2 pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag, struct lwp *l) d873 1 a873 1 struct rtentry *rtp) @ 1.108.4.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.111 2006/11/16 01:33:40 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.111 2006/11/16 01:33:40 christos Exp $"); d492 1 a492 1 struct lwp *l) d513 1 d516 4 a519 12 if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, (void *)cmd, NULL) != 0) return (EPERM); break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, (void *)cmd, NULL) != 0) return (EPERM); break; d800 2 a801 3 if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) d873 1 a873 1 struct rtentry *rtp) @ 1.108.6.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.108 2006/07/23 22:06:12 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.108 2006/07/23 22:06:12 ad Exp $"); d491 2 a492 2 pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag __unused, struct lwp *l) d873 1 a873 1 struct rtentry *rtp __unused) @ 1.108.6.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.108.6.1 2006/10/22 06:07:24 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.108.6.1 2006/10/22 06:07:24 yamt Exp $"); d491 1 a491 1 pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag, d513 1 d516 4 a519 12 if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, (void *)cmd, NULL) != 0) return (EPERM); break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, (void *)cmd, NULL) != 0) return (EPERM); break; d800 2 a801 3 if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) d873 1 a873 1 struct rtentry *rtp) @ 1.107 log @merge FreeBSD timecounters from branch simonb-timecounters - struct timeval time is gone time.tv_sec -> time_second - struct timeval mono_time is gone mono_time.tv_sec -> time_uptime - access to time via {get,}{micro,nano,bin}time() get* versions are fast but less precise - support NTP nanokernel implementation (NTP API 4) - further reading: Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.106 2006/05/14 21:19:33 elad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.106 2006/05/14 21:19:33 elad Exp $"); d492 1 a492 1 struct proc *p) d510 15 a552 2 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) return (error); a564 2 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) return (error); a575 2 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) return (error); d585 1 a585 3 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) return (error); sc->sc_xfer = p->p_pid; a589 2 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) return (error); a660 2 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) return (error); d751 1 a751 1 struct proc *p = curproc; /* XXX */ d800 2 a801 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) @ 1.106 log @integrate kauth. @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD$"); a148 1 #include d405 1 a405 1 sc->sc_last_sent = sc->sc_last_recv = time.tv_sec; d672 1 a672 1 t = time.tv_sec; d995 1 a995 1 sc->sc_last_sent = time.tv_sec; d1000 1 a1000 1 sc->sc_last_sent = time.tv_sec; d1649 1 a1649 1 sc->sc_last_recv = time.tv_sec; d1654 1 a1654 1 sc->sc_last_recv = time.tv_sec; @ 1.106.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.107 2006/06/07 22:33:42 kardel Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.107 2006/06/07 22:33:42 kardel Exp $"); d149 1 d406 1 a406 1 sc->sc_last_sent = sc->sc_last_recv = time_second; d673 1 a673 1 t = time_second; d996 1 a996 1 sc->sc_last_sent = time_second; d1001 1 a1001 1 sc->sc_last_sent = time_second; d1650 1 a1650 1 sc->sc_last_recv = time_second; d1655 1 a1655 1 sc->sc_last_recv = time_second; @ 1.105 log @ppp_dequeue: fix a mbuf leak/packet loss introduced by rev.1.104. @ text @d128 1 d539 1 a539 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) d553 1 a553 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) d566 1 a566 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) d577 1 a577 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) d584 1 a584 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) d657 1 a657 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) d798 1 a798 1 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) @ 1.105.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.108 2006/07/23 22:06:12 ad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.108 2006/07/23 22:06:12 ad Exp $"); a127 1 #include d148 1 d405 1 a405 1 sc->sc_last_sent = sc->sc_last_recv = time_second; d492 1 a492 1 struct lwp *l) a509 15 case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCXFERUNIT: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0) return (error); /* FALLTHROUGH */ default: break; } switch (cmd) { d538 2 d552 2 d565 2 d576 3 a578 1 sc->sc_xfer = l->l_proc->p_pid; d583 2 d656 2 d672 1 a672 1 t = time_second; d748 1 a748 1 struct lwp *l = curlwp; /* XXX */ d797 1 a797 2 if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0) d995 1 a995 1 sc->sc_last_sent = time_second; d1000 1 a1000 1 sc->sc_last_sent = time_second; d1649 1 a1649 1 sc->sc_last_recv = time_second; d1654 1 a1654 1 sc->sc_last_recv = time_second; @ 1.105.10.1 log @Merge 2006-05-24 NetBSD-current into the "peter-altq" branch. @ text @a127 1 #include d538 1 a538 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d552 1 a552 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d565 1 a565 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d576 1 a576 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d583 1 a583 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d656 1 a656 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d797 1 a797 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) @ 1.105.6.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105 2006/01/02 01:42:36 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105 2006/01/02 01:42:36 yamt Exp $"); a127 1 #include d538 1 a538 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d552 1 a552 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d565 1 a565 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d576 1 a576 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d583 1 a583 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d656 1 a656 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d797 1 a797 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) @ 1.105.6.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105.6.1 2006/05/24 10:58:56 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105.6.1 2006/05/24 10:58:56 yamt Exp $"); d149 1 d406 1 a406 1 sc->sc_last_sent = sc->sc_last_recv = time_second; d673 1 a673 1 t = time_second; d996 1 a996 1 sc->sc_last_sent = time_second; d1001 1 a1001 1 sc->sc_last_sent = time_second; d1650 1 a1650 1 sc->sc_last_recv = time_second; d1655 1 a1655 1 sc->sc_last_recv = time_second; @ 1.105.6.3 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105.6.2 2006/06/26 12:53:39 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105.6.2 2006/06/26 12:53:39 yamt Exp $"); d492 1 a492 1 struct lwp *l) a509 15 case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCXFERUNIT: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0) return (error); /* FALLTHROUGH */ default: break; } switch (cmd) { d538 2 d552 2 d565 2 d576 3 a578 1 sc->sc_xfer = l->l_proc->p_pid; d583 2 d656 2 d748 1 a748 1 struct lwp *l = curlwp; /* XXX */ d797 1 a797 2 if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0) @ 1.105.8.1 log @Adapt to kernel authorization KPI. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105 2006/01/02 01:42:36 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105 2006/01/02 01:42:36 yamt Exp $"); d538 1 a538 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d552 1 a552 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d565 1 a565 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d576 1 a576 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d583 1 a583 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d656 1 a656 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d797 1 a797 1 if ((error = generic_authorize(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) @ 1.105.8.2 log @generic_authorize() -> kauth_authorize_generic(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105.8.1 2006/03/08 01:11:55 elad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105.8.1 2006/03/08 01:11:55 elad Exp $"); d538 1 a538 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d552 1 a552 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d565 1 a565 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d576 1 a576 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d583 1 a583 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d656 1 a656 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d797 1 a797 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) @ 1.105.8.3 log @- Move kauth_cred_t declaration to - Cleanup struct ucred; forward declarations that are unused. - Don't include in any header, but include it in the c files that need it. Approved by core. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105.8.2 2006/03/10 15:05:22 elad Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105.8.2 2006/03/10 15:05:22 elad Exp $"); a127 1 #include @ 1.105.4.1 log @Adapt for timecounters: mostly use get*time(), use bintime's for timeout calculations and use "time_second" instead of "time.tv_sec". @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105 2006/01/02 01:42:36 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105 2006/01/02 01:42:36 yamt Exp $"); d148 1 d405 1 a405 1 sc->sc_last_sent = sc->sc_last_recv = time_second; d672 1 a672 1 t = time_second; d995 1 a995 1 sc->sc_last_sent = time_second; d1000 1 a1000 1 sc->sc_last_sent = time_second; d1649 1 a1649 1 sc->sc_last_recv = time_second; d1654 1 a1654 1 sc->sc_last_recv = time_second; @ 1.105.4.2 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.105.4.1 2006/02/04 14:18:52 simonb Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.105.4.1 2006/02/04 14:18:52 simonb Exp $"); a127 1 #include d537 1 a537 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d551 1 a551 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d564 1 a564 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d575 1 a575 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d582 1 a582 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d655 1 a655 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d796 1 a796 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) @ 1.104 log @PR/5901: Felix A. Croes: PPP fast queue blocks traffic at normal priority. Applied fix, similar to the one suggested in the PR. We use a counter to limit the number of consecutive packets accepted from the fast queue. This number can be set via ioctl, but this has not been implemented. Since there are only 2 queues other proposed solutions such as ALTQ are overkill and they have not been implemented in the past 7 years. Now LCP echos can be used to detect that the line is up. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.103 2005/12/11 23:05:25 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.103 2005/12/11 23:05:25 thorpej Exp $"); d1143 1 a1143 1 if (m != NULL) { @ 1.104.2.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.104 2005/12/28 08:13:24 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.104 2005/12/28 08:13:24 christos Exp $"); d1143 1 a1143 1 if (m == NULL) { @ 1.103 log @ANSI function decls and application of static. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.102 2005/11/27 05:35:52 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.102 2005/11/27 05:35:52 thorpej Exp $"); d317 2 d1134 8 a1141 2 IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) d1143 6 @ 1.102 log @Overhaul how TTY line disciplines are handled: - Replace references to linesw[0] with a ttyldisc_default() function that returns the default ("termios") line discipline. - The linesw[] array is gone, replaced by a linked list. - ttyldisc_add() and ttyldisc_remove() have been replaced by ttyldisc_attach() and ttyldisc_detach(). - Things that provide line disciplines are now responsible for registering those disciplines with the system. The linesw structures are no longer declared in tty_conf.c - Line disciplines are now refcounted; a lookup causes a reference to be held. ttyldisc_release() releases the reference. Attempts to detach an in-use line discipline result in EBUSY. - Fix function signature lossage in if_sl.c, if_strip.c, and tty_tb.c that was masked by the old tty_conf.c - tty_init() is no longer necessary; delete it and its call from main(). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101 2005/05/29 21:22:52 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101 2005/05/29 21:22:52 christos Exp $"); d170 6 a175 6 static int pppsioctl __P((struct ifnet *, u_long, caddr_t)); static void ppp_requeue __P((struct ppp_softc *)); static void ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd)); static void ppp_ccp_closed __P((struct ppp_softc *)); static void ppp_inproc __P((struct ppp_softc *, struct mbuf *)); static void pppdumpm __P((struct mbuf *m0)); d177 1 a177 1 static void ppp_ifstart __P((struct ifnet *ifp)); d183 1 a183 1 void pppintr(void *); d357 1 a357 2 pppalloc(pid) pid_t pid; d412 1 a412 2 pppdealloc(sc) struct ppp_softc *sc; d489 2 a490 6 pppioctl(sc, cmd, data, flag, p) struct ppp_softc *sc; u_long cmd; caddr_t data; int flag; struct proc *p; d744 1 a744 4 pppsioctl(ifp, cmd, data) struct ifnet *ifp; u_long cmd; caddr_t data; d866 2 a867 5 pppoutput(ifp, m0, dst, rtp) struct ifnet *ifp; struct mbuf *m0; struct sockaddr *dst; struct rtentry *rtp; d1047 1 a1047 2 ppp_requeue(sc) struct ppp_softc *sc; d1100 1 a1100 2 ppp_restart(sc) struct ppp_softc *sc; d1120 1 a1120 2 ppp_dequeue(sc) struct ppp_softc *sc; d1262 1 a1262 1 void d1293 1 a1293 4 ppp_ccp(sc, m, rcvd) struct ppp_softc *sc; struct mbuf *m; int rcvd; d1387 1 a1387 2 ppp_ccp_closed(sc) struct ppp_softc *sc; d1407 1 a1407 4 ppppktin(sc, m, lost) struct ppp_softc *sc; struct mbuf *m; int lost; d1430 1 a1430 3 ppp_inproc(sc, m) struct ppp_softc *sc; struct mbuf *m; d1734 1 a1734 2 pppdumpm(m0) struct mbuf *m0; d1771 1 a1771 2 ppp_ifstart(ifp) struct ifnet *ifp; @ 1.101 log @- sprinkle const - remove unneeded casts - use more mem*() instead of b*() funcs. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.100 2005/05/17 04:14:58 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.100 2005/05/17 04:14:58 christos Exp $"); d127 1 d246 4 @ 1.101.2.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101 2005/05/29 21:22:52 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101 2005/05/29 21:22:52 christos Exp $"); a126 2 #include #include d147 1 d169 6 a174 6 static int pppsioctl(struct ifnet *, u_long, caddr_t); static void ppp_requeue(struct ppp_softc *); static void ppp_ccp(struct ppp_softc *, struct mbuf *m, int rcvd); static void ppp_ccp_closed(struct ppp_softc *); static void ppp_inproc(struct ppp_softc *, struct mbuf *); static void pppdumpm(struct mbuf *m0); d176 1 a176 1 static void ppp_ifstart(struct ifnet *ifp); d182 1 a182 1 static void pppintr(void *); a244 4 extern struct linesw ppp_disc; if (ttyldisc_attach(&ppp_disc) != 0) panic("pppattach"); a311 2 /* Ratio of 1:2 packets between the regular and the fast queue */ sc->sc_maxfastq = 2; d352 2 a353 1 pppalloc(pid_t pid) d399 1 a399 1 sc->sc_last_sent = sc->sc_last_recv = time_second; d408 2 a409 1 pppdealloc(struct ppp_softc *sc) d486 6 a491 2 pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag, struct proc *p) d537 1 a537 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d551 1 a551 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d564 1 a564 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d575 1 a575 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d582 1 a582 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d655 1 a655 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d671 1 a671 1 t = time_second; d745 4 a748 1 pppsioctl(struct ifnet *ifp, u_long cmd, caddr_t data) d799 1 a799 1 if ((error = kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER, &p->p_acflag)) != 0) d870 5 a874 2 pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, struct rtentry *rtp) d1000 1 a1000 1 sc->sc_last_sent = time_second; d1005 1 a1005 1 sc->sc_last_sent = time_second; d1054 2 a1055 1 ppp_requeue(struct ppp_softc *sc) d1108 2 a1109 1 ppp_restart(struct ppp_softc *sc) d1129 2 a1130 1 ppp_dequeue(struct ppp_softc *sc) d1142 2 a1143 8 if (sc->sc_nfastq < sc->sc_maxfastq) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; else IFQ_DEQUEUE(&sc->sc_if.if_snd, m); } else { sc->sc_nfastq = 0; a1144 6 if (m == NULL) { IF_DEQUEUE(&sc->sc_fastq, m); if (m != NULL) sc->sc_nfastq++; } } d1272 1 a1272 1 static void d1303 4 a1306 1 ppp_ccp(struct ppp_softc *sc, struct mbuf *m, int rcvd) d1400 2 a1401 1 ppp_ccp_closed(struct ppp_softc *sc) d1421 4 a1424 1 ppppktin(struct ppp_softc *sc, struct mbuf *m, int lost) d1447 3 a1449 1 ppp_inproc(struct ppp_softc *sc, struct mbuf *m) d1654 1 a1654 1 sc->sc_last_recv = time_second; d1659 1 a1659 1 sc->sc_last_recv = time_second; d1753 2 a1754 1 pppdumpm(struct mbuf *m0) d1791 2 a1792 1 ppp_ifstart(struct ifnet *ifp) @ 1.101.2.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101.2.1 2006/06/21 15:10:27 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101.2.1 2006/06/21 15:10:27 yamt Exp $"); d492 1 a492 1 struct lwp *l) a509 22 case PPPIOCSFLAGS: case PPPIOCSMRU: case PPPIOCSMAXCID: case PPPIOCSCOMPRESS: case PPPIOCSNPMODE: if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, &sc->sc_if, (void *)cmd, NULL) != 0) return (EPERM); break; case PPPIOCXFERUNIT: /* XXX: Why is this privileged?! */ if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, &sc->sc_if, (void *)cmd, NULL) != 0) return (EPERM); break; default: break; } switch (cmd) { d538 2 d552 2 d565 2 d576 3 a578 1 sc->sc_xfer = l->l_proc->p_pid; d583 2 d656 2 d748 1 a748 1 struct lwp *l = curlwp; /* XXX */ d797 1 a797 3 if ((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL) != 0)) d869 1 a869 1 struct rtentry *rtp) @ 1.101.2.3 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101.2.2 2006/12/30 20:50:20 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101.2.2 2006/12/30 20:50:20 yamt Exp $"); d880 1 a880 1 pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, @ 1.101.2.4 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101.2.3 2007/02/26 09:11:35 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101.2.3 2007/02/26 09:11:35 yamt Exp $"); d170 1 a170 1 static int pppsioctl(struct ifnet *, u_long, void *); d180 3 d301 1 a301 1 callout_init(&sc->sc_timo_ch, 0); d380 1 d386 1 d418 1 d420 1 d491 1 a491 1 pppioctl(struct ppp_softc *sc, u_long cmd, void *data, int flag, d705 1 a705 1 if ((error = copyin((void *)nbp->bf_insns, (void *)newcode, d756 1 a756 1 pppsioctl(struct ifnet *ifp, u_long cmd, void *data) d820 1 a820 1 if (ifr == NULL) { d824 1 a824 1 switch (ifreq_getaddr(cmd, ifr)->sa_family) { d1119 1 d1121 3 d1273 12 d1440 1 d1442 3 d1636 1 a1636 1 m_copydata(m, 0, ilen, mtod(mp, void *)); a1714 4 #ifdef GATEWAY if (ip6flow_fastforward(m)) return; #endif @ 1.101.2.5 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101.2.4 2007/09/03 14:42:09 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101.2.4 2007/09/03 14:42:09 yamt Exp $"); a128 1 #include d138 2 d163 1 a163 1 #include d377 1 a377 1 sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc); d413 1 a413 1 softint_disestablish(sc->sc_si); d1112 1 a1112 1 softint_schedule(sc->sc_si); d1417 1 a1417 1 softint_schedule(sc->sc_si); @ 1.101.2.6 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101.2.5 2007/10/27 11:36:02 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101.2.5 2007/10/27 11:36:02 yamt Exp $"); a129 1 #include @ 1.101.2.7 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101.2.6 2008/01/21 09:47:05 yamt Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101.2.6 2008/01/21 09:47:05 yamt Exp $"); d804 3 a806 1 /*FALLTHROUGH*/ d808 1 a808 2 if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) error = 0; @ 1.101.8.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.101 2005/05/29 21:22:52 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.101 2005/05/29 21:22:52 christos Exp $"); a126 1 #include a244 4 extern struct linesw ppp_disc; if (ttyldisc_attach(&ppp_disc) != 0) panic("pppattach"); @ 1.100 log @Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to implement, xtoa(), but I think defining the samestring 50 times is a bit too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it... @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.99 2005/03/31 21:19:35 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.99 2005/03/31 21:19:35 christos Exp $"); d524 1 a524 1 u_char p, q = 0; d526 2 a527 2 for (p = sc->sc_rawin_start; p < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[p++]; d529 2 a530 2 for (p = 0; p < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[p++]; @ 1.99 log @no point in assigning to ifq twice. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.98 2005/03/31 17:07:39 explorer Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.98 2005/03/31 17:07:39 explorer Exp $"); a1758 1 static char digits[] = "0123456789abcdef"; d1767 2 a1768 2 *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */ *bp++ = digits[*rptr++ & 0xf]; @ 1.98 log @Fix error with ifq not being set before use. Explicitly set it to NULL just before it may be set to the fastq, since if this becomes a loop (and in one case already is) this will always work. ifq_enqueue2() is designed to handle this case. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.97 2005/03/31 15:48:13 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.97 2005/03/31 15:48:13 christos Exp $"); d1027 1 a1027 3 ifq = NULL; if (m0->m_flags & M_HIGHPRI) ifq = &sc->sc_fastq; d1081 1 a1081 3 ifq = NULL; if (m->m_flags & M_HIGHPRI) ifq = &sc->sc_fastq; @ 1.97 log @factor out the interface queueing code into two functions. One used by the non point-to-point interfaces that has one queue, and one used by the point to point interfaces that has two queues. No functional changes. XXX: The ALTQ stuff makes the code ugly. XXX: More cleanup to come @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.96 2005/02/26 22:45:09 perry Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.96 2005/02/26 22:45:09 perry Exp $"); d1027 1 d1083 1 @ 1.96 log @nuke trailing whitespace @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.95 2004/12/05 15:03:13 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.95 2004/12/05 15:03:13 christos Exp $"); d1027 4 a1030 18 if ((m0->m_flags & M_HIGHPRI) #ifdef ALTQ && ALTQ_IS_ENABLED(&sc->sc_if.if_snd) == 0 #endif ) { ifq = &sc->sc_fastq; if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) { IF_DROP(ifq); splx(s); error = ENOBUFS; goto bad; } else { IF_ENQUEUE(ifq, m0); error = 0; } } else IFQ_ENQUEUE(&sc->sc_if.if_snd, m0, &pktattr, error); if (error) { d1082 1 a1082 5 if ((m->m_flags & M_HIGHPRI) #ifdef ALTQ && ALTQ_IS_ENABLED(&sc->sc_if.if_snd) == 0 #endif ) { d1084 2 a1085 11 if (IF_QFULL(ifq)) { IF_DROP(ifq); m_freem(m); error = ENOBUFS; } else { IF_ENQUEUE(ifq, m); error = 0; } } else IFQ_ENQUEUE(&sc->sc_if.if_snd, m, NULL, error); if (error) { @ 1.95 log @pasto: simple_lock -> simple_unlock. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.94 2004/12/05 15:00:47 peter Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.94 2004/12/05 15:00:47 peter Exp $"); d359 1 a359 1 for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL; d1170 1 a1170 1 s = splnet(); d1175 1 a1175 1 d1292 1 a1292 1 for (sc = LIST_FIRST(&ppp_softc_list); sc != NULL; @ 1.95.4.1 log @sync with -current @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.99 2005/03/31 21:19:35 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.99 2005/03/31 21:19:35 christos Exp $"); d359 1 a359 1 for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL; d1027 18 a1044 3 ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { d1096 17 a1112 3 ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA ALTQ_DECL(NULL))) != 0) { d1170 1 a1170 1 s = splnet(); d1175 1 a1175 1 d1292 1 a1292 1 for (sc = LIST_FIRST(&ppp_softc_list); sc != NULL; @ 1.95.6.1 log @sync with head. xen and whitespace. xen part is not finished. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.95 2004/12/05 15:03:13 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.95 2004/12/05 15:03:13 christos Exp $"); d359 1 a359 1 for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL; d1170 1 a1170 1 s = splnet(); d1175 1 a1175 1 d1292 1 a1292 1 for (sc = LIST_FIRST(&ppp_softc_list); sc != NULL; @ 1.94 log @Don't forget to call bpfdetach in the clone destroy function. While here, add a missing static and change some spaces to tabs. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.93 2004/12/05 13:32:03 he Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.93 2004/12/05 13:32:03 he Exp $"); d369 1 a369 1 simple_lock(&ppp_list_mutex); @ 1.93 log @Fix an obvious typo: scf -> sc. Discovered while compiling for x68k. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.92 2004/12/05 05:42:19 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.92 2004/12/05 05:42:19 christos Exp $"); d339 3 @ 1.92 log @void in arg prototype. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.91 2004/12/05 04:15:16 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.91 2004/12/05 04:15:16 christos Exp $"); d1289 1 a1289 1 for (sc = LIST_FIRST(&ppp_softc_list); scf != NULL; @ 1.91 log @Make ppp a cloning device. Based on the work of Quentin Garnier. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.90 2004/07/03 18:11:33 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.90 2004/07/03 18:11:33 dyoung Exp $"); d243 1 a243 1 pppattach() @ 1.90 log @I changed pppoutput to use M_PREPEND. pppoutput was duplicating the functionality of M_PREPEND, but with a bug: m_pkthdr.len was not updated in pppoutput as it is in M_PREPEND. Also, replace the loop that measures the length of the mbuf chain with a call to m_length. This fixes a PR from an anonymous bug reporter. Thank you, anonymous bug reporter. Thanks, Itojun, for bringing the anonymous bug report to my attention. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.89 2004/04/21 18:40:39 itojun Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.89 2004/04/21 18:40:39 itojun Exp $"); d205 11 a215 1 struct ppp_softc ppp_softc[NPPP]; d245 39 a283 2 struct ppp_softc *sc; int i = 0; d285 20 a304 12 for (sc = ppp_softc; i < NPPP; sc++) { sc->sc_unit = i; /* XXX */ snprintf(sc->sc_if.if_xname, sizeof(sc->sc_if.if_xname), "ppp%d", i++); callout_init(&sc->sc_timo_ch); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; d306 1 a306 1 sc->sc_if.if_start = ppp_ifstart; d308 7 a314 7 IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); d316 1 a316 1 bpfattach(&sc->sc_if, DLT_NULL, 0); d318 25 a342 1 } d352 2 a353 2 int nppp, i; struct ppp_softc *sc; d355 7 a361 4 for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) if (sc->sc_xfer == pid) { sc->sc_xfer = 0; return sc; d363 7 a369 5 for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) if (sc->sc_devp == NULL) break; if (nppp >= NPPP) return NULL; d374 1 a374 1 printf("ppp%d: unable to establish softintr\n", sc->sc_unit); a377 1 d381 1 a381 1 memset((char *)&sc->sc_stats, 0, sizeof(sc->sc_stats)); d476 1 a496 1 /*###413 [cc] warning: `bp' might be used uninitialized in this function%%%*/ d511 1 a511 1 *(int *)data = sc->sc_unit; /* XXX */ a1287 1 int i; d1289 2 a1290 2 for (i = 0; i < NPPP; i++) { sc = &ppp_softc[i]; a1291 1 } @ 1.89 log @kill sprintf, use snprintf @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.88 2003/10/28 20:16:28 mycroft Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.88 2003/10/28 20:16:28 mycroft Exp $"); a799 1 struct mbuf *m; d874 1 a874 2 * Add PPP header. If no space in first mbuf, allocate another. * (This assumes M_LEADINGSPACE is always 0 for a cluster mbuf.) d876 5 a880 9 if (M_LEADINGSPACE(m0) < PPP_HDRLEN) { m0 = m_prepend(m0, PPP_HDRLEN, M_DONTWAIT); if (m0 == 0) { error = ENOBUFS; goto bad; } m0->m_len = 0; } else m0->m_data -= PPP_HDRLEN; a886 1 m0->m_len += PPP_HDRLEN; d888 1 a888 3 len = 0; for (m = m0; m != 0; m = m->m_next) len += m->m_len; @ 1.88 log @Also, if we're going to bail, we should free the memory we just allocated... @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.87 2003/10/28 20:15:19 mycroft Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.87 2003/10/28 20:15:19 mycroft Exp $"); d240 1 a240 1 sprintf(sc->sc_if.if_xname, "ppp%d", i++); @ 1.87 log @Previous patch created a dead break. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.86 2003/10/25 18:29:12 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.86 2003/10/25 18:29:12 christos Exp $"); d636 1 @ 1.86 log @Fix uninitialized variable warnings @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.85 2003/09/01 16:51:25 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.85 2003/09/01 16:51:25 christos Exp $"); d636 1 a636 2 return EINVAL; break; @ 1.85 log @Add a new ioctl PPPIOCGRAWIN to get the last characters we got from the remote site. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.84 2003/05/02 03:15:24 itojun Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84 2003/05/02 03:15:24 itojun Exp $"); d413 1 d634 3 @ 1.84 log @KNF @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.83 2003/03/27 17:50:28 christos Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.83 2003/03/27 17:50:28 christos Exp $"); d432 15 @ 1.84.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.90 2004/07/03 18:11:33 dyoung Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.90 2004/07/03 18:11:33 dyoung Exp $"); d240 1 a240 1 snprintf(sc->sc_if.if_xname, sizeof(sc->sc_if.if_xname), "ppp%d", i++); a412 1 /*###413 [cc] warning: `bp' might be used uninitialized in this function%%%*/ a433 15 case PPPIOCGRAWIN: { struct ppp_rawin *rwin = (struct ppp_rawin *)data; u_char p, q = 0; for (p = sc->sc_rawin_start; p < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[p++]; for (p = 0; p < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[p++]; rwin->count = sc->sc_rawin.count; } break; a618 3 default: free(newcode, M_DEVBUF); return (EPASSTHROUGH); d781 1 d856 2 a857 1 * Add PPP header. d859 9 a867 5 M_PREPEND(m0, PPP_HDRLEN, M_DONTWAIT); if (m0 == NULL) { error = ENOBUFS; goto bad; } d874 1 d876 3 a878 1 len = m_length(m0); @ 1.84.2.2 log @Sync with HEAD. @ text @@ 1.84.2.3 log @Fix the sync with head I botched. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.84.2.1 2004/08/03 10:54:15 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84.2.1 2004/08/03 10:54:15 skrll Exp $"); @ 1.84.2.4 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.84.2.3 2004/09/21 13:36:38 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84.2.3 2004/09/21 13:36:38 skrll Exp $"); d205 1 a205 11 static int ppp_clone_create(struct if_clone *, int); static int ppp_clone_destroy(struct ifnet *); static struct ppp_softc *ppp_create(const char *, int); static LIST_HEAD(, ppp_softc) ppp_softc_list; struct if_clone ppp_cloner = IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy); static struct simplelock ppp_list_mutex = SIMPLELOCK_INITIALIZER; d233 1 a233 1 pppattach(void) d235 2 a236 3 LIST_INIT(&ppp_softc_list); if_clone_attach(&ppp_cloner); } d238 12 a249 56 static struct ppp_softc * ppp_create(const char *name, int unit) { struct ppp_softc *sc, *sci, *scl = NULL; MALLOC(sc, struct ppp_softc *, sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO); simple_lock(&ppp_list_mutex); if (unit == -1) { int i = 0; LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (i < sci->sc_unit) { unit = i; break; } else { #ifdef DIAGNOSTIC KASSERT(i == sci->sc_unit); #endif i++; } } if (unit == -1) unit = i; } else { LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) { scl = sci; if (unit < sci->sc_unit) break; else if (unit == sci->sc_unit) { FREE(sc, M_DEVBUF); return NULL; } } } if (sci != NULL) LIST_INSERT_BEFORE(sci, sc, sc_iflist); else if (scl != NULL) LIST_INSERT_AFTER(scl, sc, sc_iflist); else LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist); simple_unlock(&ppp_list_mutex); (void)snprintf(sc->sc_if.if_xname, sizeof(sc->sc_if.if_xname), "%s%d", name, sc->sc_unit = unit); callout_init(&sc->sc_timo_ch); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; d251 1 a251 1 sc->sc_if.if_start = ppp_ifstart; d253 7 a259 7 IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); d261 1 a261 1 bpfattach(&sc->sc_if, DLT_NULL, 0); d263 1 a263 28 return sc; } static int ppp_clone_create(struct if_clone *ifc, int unit) { return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0; } static int ppp_clone_destroy(struct ifnet *ifp) { struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc; if (sc->sc_devp != NULL) return EBUSY; /* Not removing it */ simple_lock(&ppp_list_mutex); LIST_REMOVE(sc, sc_iflist); simple_unlock(&ppp_list_mutex); #if NBPFILTER > 0 bpfdetach(ifp); #endif if_detach(ifp); FREE(sc, M_DEVBUF); return 0; d273 2 a274 2 struct ppp_softc *sc = NULL, *scf; int i; d276 4 a279 7 simple_lock(&ppp_list_mutex); for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL; scf = LIST_NEXT(scf, sc_iflist)) { if (scf->sc_xfer == pid) { scf->sc_xfer = 0; simple_unlock(&ppp_list_mutex); return scf; d281 5 a285 7 if (scf->sc_devp == NULL && sc == NULL) sc = scf; } simple_unlock(&ppp_list_mutex); if (sc == NULL) sc = ppp_create(ppp_cloner.ifc_name, -1); d290 1 a290 1 printf("%s: unable to establish softintr\n", sc->sc_if.if_xname); d294 1 d298 1 a298 1 (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats)); a392 1 (void)ppp_clone_destroy(&sc->sc_if); d413 1 d428 1 a428 1 *(int *)data = sc->sc_unit; d1205 1 d1207 2 a1208 2 for (sc = LIST_FIRST(&ppp_softc_list); sc != NULL; sc = LIST_NEXT(sc, sc_iflist)) d1210 1 @ 1.84.2.5 log @Sync with HEAD. Hi Perry! @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.84.2.4 2004/12/18 09:32:50 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84.2.4 2004/12/18 09:32:50 skrll Exp $"); d359 1 a359 1 for (scf = LIST_FIRST(&ppp_softc_list); scf != NULL; d1170 1 a1170 1 s = splnet(); d1175 1 a1175 1 d1292 1 a1292 1 for (sc = LIST_FIRST(&ppp_softc_list); sc != NULL; @ 1.84.2.6 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.84.2.5 2005/03/04 16:52:58 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84.2.5 2005/03/04 16:52:58 skrll Exp $"); d1027 18 a1044 3 ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { d1096 17 a1112 3 ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA ALTQ_DECL(NULL))) != 0) { @ 1.84.2.7 log @Sync with HEAD. Here we go again... @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.84.2.6 2005/04/01 14:31:34 skrll Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84.2.6 2005/04/01 14:31:34 skrll Exp $"); d524 1 a524 1 u_char c, q = 0; d526 2 a527 2 for (c = sc->sc_rawin_start; c < sizeof(sc->sc_rawin.buf);) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d529 2 a530 2 for (c = 0; c < sc->sc_rawin_start;) rwin->buf[q++] = sc->sc_rawin.buf[c++]; d1759 1 d1768 2 a1769 2 *bp++ = hexdigits[*rptr >> 4]; /* convert byte to ascii hex */ *bp++ = hexdigits[*rptr++ & 0xf]; @ 1.84.2.8 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.102 2005/11/27 05:35:52 thorpej Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.102 2005/11/27 05:35:52 thorpej Exp $"); a126 1 #include a244 4 extern struct linesw ppp_disc; if (ttyldisc_attach(&ppp_disc) != 0) panic("pppattach"); @ 1.83 log @PR/20844: Iain Hibbert: PPP Compressors cannot be loaded as LKM @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.82 2003/01/19 23:44:03 simonb Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.82 2003/01/19 23:44:03 simonb Exp $"); d709 1 a709 1 switch(ifr->ifr_addr.sa_family) { @ 1.82 log @Remove variable that is only assigned too but not referenced. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.81 2002/10/02 02:27:54 itojun Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.81 2002/10/02 02:27:54 itojun Exp $"); d216 1 a216 1 struct compressor *ppp_compressors[8] = { @ 1.81 log @backout previous two - if you use ppp* interface, kernel panics instantly. it is apparent that the change was untested, and severety is high. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.80 2002/09/25 23:24:37 augustss Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.80 2002/09/25 23:24:37 augustss Exp $"); d1145 1 a1145 1 int slen, clen; d1150 1 a1150 1 clen = (*sc->sc_xcomp->compress) @ 1.80 log @Remove unused variable so the file compiles again. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.79 2002/09/25 16:10:15 darrenr Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.79 2002/09/25 16:10:15 darrenr Exp $"); d781 1 d875 4 a878 2 m0->m_pkthdr.len += PPP_HDRLEN; len = m0->m_pkthdr.len; d1147 3 a1149 1 slen = m->m_pkthdr.len; a1175 1 m->m_pkthdr.len -= 2; d1183 2 a1184 3 m->m_data++; m->m_len--; m->m_pkthdr.len--; d1400 3 a1402 1 ilen = m->m_pkthdr.len; d1465 3 a1467 1 ilen = m->m_pkthdr.len; d1505 1 a1505 1 mp->m_pkthdr.len = 0; a1520 1 mp->m_pkthdr.len = mp->m_len; a1527 1 m->m_pkthdr.len -= PPP_HDRLEN + xlen; a1530 1 mp->m_pkthdr.len += m->m_len; @ 1.79 log @Keep m_pkthdr.len updated correctly and use it rather than a loop to find out the total length of the packet. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.78 2002/07/01 22:09:31 itojun Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.78 2002/07/01 22:09:31 itojun Exp $"); a780 1 struct mbuf *m; @ 1.78 log @new copyright boilerplate from CMU. from openbsd @ text @d1 1 a1 1 /* $NetBSD$ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.77 2002/05/12 20:38:15 matt Exp $"); d875 2 a876 4 len = 0; for (m = m0; m != 0; m = m->m_next) len += m->m_len; d1145 1 a1145 3 slen = 0; for (mp = m; mp != NULL; mp = mp->m_next) slen += mp->m_len; d1172 1 d1180 3 a1182 2 ++m->m_data; --m->m_len; d1398 1 a1398 3 ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; d1461 1 a1461 3 ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; d1499 1 a1499 1 mp->m_next = NULL; d1515 1 d1523 1 d1527 1 @ 1.77 log @Make ppp_softc[] extern and declare in if_ppp.c @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.76 2002/03/17 19:41:10 atatat Exp $ */ d7 1 a7 14 * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. d9 35 a43 6 * Drew D. Perkins * Carnegie Mellon University * 4910 Forbes Ave. * Pittsburgh, PA 15213 * (412) 268-8576 * ddp@@andrew.cmu.edu d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.76 2002/03/17 19:41:10 atatat Exp $"); @ 1.77.2.1 log @catch up with -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.78 2002/07/01 22:09:31 itojun Exp $ */ d7 14 a20 1 * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. d22 6 a27 35 * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "Carnegie Mellon University" must not be used to * endorse or promote products derived from this software without * prior written permission. For permission or any legal * details, please contact * Office of Technology Transfer * Carnegie Mellon University * 5000 Forbes Avenue * Pittsburgh, PA 15213-3890 * (412) 268-4387, fax: (412) 268-7395 * tech-transfer@@andrew.cmu.edu * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by Computing Services * at Carnegie Mellon University (http://www.cmu.edu/computing/)." * * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.78 2002/07/01 22:09:31 itojun Exp $"); @ 1.76 log @Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for indicating an unhandled "command". ERESTART is -1, which can lead to confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been placed at -4. No ioctl code should now return -1 anywhere. The ioctl() system call is now properly restartable. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.75 2002/03/05 04:13:01 itojun Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.75 2002/03/05 04:13:01 itojun Exp $"); d188 2 @ 1.75 log @bring in latest ALTQ from kjc. ALTQify some of the drivers. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.74 2002/01/14 18:19:15 kleink Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.74 2002/01/14 18:19:15 kleink Exp $"); d613 1 a613 1 return (-1); @ 1.74 log @Include unconditionally, instead of only doing so if __HAVE_GENERIC_SOFT_INTERRUPTS and relying on to provide it otherwise; pointed out by Aymeric Vincent. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.73 2001/11/13 00:49:35 lukem Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.73 2001/11/13 00:49:35 lukem Exp $"); d159 3 d232 3 d1702 16 @ 1.73 log @remove unnecessary #if NFOO > 0 .... #endif wrappers @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.72 2001/11/12 23:49:41 lukem Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.72 2001/11/12 23:49:41 lukem Exp $"); a119 1 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS a120 1 #endif @ 1.72 log @add RCSIDs @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.71 2001/08/05 18:07:55 jdolecek Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD$"); a92 2 #if NPPP > 0 a1697 2 #endif /* NPPP > 0 */ @ 1.71 log @use unsigned variable types as appropriate @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.70 2001/07/18 16:43:09 thorpej Exp $ */ d87 3 @ 1.70 log @bzero -> memset @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69 2001/06/14 05:44:24 itojun Exp $ */ d383 2 a384 1 int s, error, flags, mru, nb, npx; @ 1.69 log @change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange. follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific interfaces only). was: if_lastchange get updated on every packet transmission/receipt. now: if_lastchange get updated when IFF_UP is changed. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.68 2001/04/13 23:30:14 thorpej Exp $ */ d275 1 a275 1 bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats)); d702 1 a702 1 bzero(psp, sizeof(*psp)); d721 1 a721 1 bzero(pcp, sizeof(*pcp)); @ 1.69.2.1 log @update to -current @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.70 2001/07/18 16:43:09 thorpej Exp $ */ d275 1 a275 1 memset((char *)&sc->sc_stats, 0, sizeof(sc->sc_stats)); d702 1 a702 1 memset(psp, 0, sizeof(*psp)); d721 1 a721 1 memset(pcp, 0, sizeof(*pcp)); @ 1.69.2.2 log @Merge Aug 24 -current into the kqueue branch. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.1 2001/08/03 04:13:50 lukem Exp $ */ d383 1 a383 2 int s, error, flags, mru, npx; u_int nb; @ 1.69.2.3 log @Sync kqueue branch with -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.2 2001/08/25 06:16:57 thorpej Exp $ */ d88 1 a88 2 #include __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.73 2001/11/13 00:49:35 lukem Exp $"); d90 1 a90 1 #include "ppp.h" d1697 2 @ 1.69.2.4 log @Sync w/ -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.3 2002/01/10 20:02:08 thorpej Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.69.2.3 2002/01/10 20:02:08 thorpej Exp $"); d120 1 d122 1 @ 1.69.2.5 log @Catch up with -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.4 2002/02/11 20:10:28 jdolecek Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.69.2.4 2002/02/11 20:10:28 jdolecek Exp $"); a158 3 #ifdef ALTQ static void ppp_ifstart __P((struct ifnet *ifp)); #endif a228 3 #ifdef ALTQ sc->sc_if.if_start = ppp_ifstart; #endif a1695 16 #ifdef ALTQ /* * a wrapper to transmit a packet from if_start since ALTQ uses * if_start to send a packet. */ static void ppp_ifstart(ifp) struct ifnet *ifp; { struct ppp_softc *sc; sc = ifp->if_softc; (*sc->sc_start)(sc); } #endif @ 1.69.2.6 log @catch up with -current on kqueue branch @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.5 2002/03/16 16:02:06 jdolecek Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.69.2.5 2002/03/16 16:02:06 jdolecek Exp $"); a188 2 struct ppp_softc ppp_softc[NPPP]; d613 1 a613 1 return (EPASSTHROUGH); @ 1.69.2.7 log @sync kqueue branch with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.6 2002/06/23 17:50:25 jdolecek Exp $ */ d7 14 a20 1 * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. d22 6 a27 35 * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "Carnegie Mellon University" must not be used to * endorse or promote products derived from this software without * prior written permission. For permission or any legal * details, please contact * Office of Technology Transfer * Carnegie Mellon University * 5000 Forbes Avenue * Pittsburgh, PA 15213-3890 * (412) 268-4387, fax: (412) 268-7395 * tech-transfer@@andrew.cmu.edu * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by Computing Services * at Carnegie Mellon University (http://www.cmu.edu/computing/)." * * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.69.2.6 2002/06/23 17:50:25 jdolecek Exp $"); @ 1.69.2.8 log @sync kqueue with -current; this includes merge of gehenna-devsw branch, merge of i386 MP branch, and part of autoconf rototil work @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.69.2.7 2002/09/06 08:48:55 jdolecek Exp $ */ d105 1 a105 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.69.2.7 2002/09/06 08:48:55 jdolecek Exp $"); @ 1.68 log @Remove the use of splimp() from the NetBSD kernel. splnet() and only splnet() is allowed for the protection of data structures used by network devices. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67 2001/01/17 00:30:51 thorpej Exp $ */ a931 1 ifp->if_lastchange = time; a1648 1 ifp->if_lastchange = time; @ 1.67 log @Fix a rather annoying problem where the sockaddr_dl which holds the link level name for the interface (ifp->if_sadl) is allocated before ifp->if_addrlen is initialized, which could lead to allocating too little space for the link level address. Do this by splitting allocation of the link level name out of if_attach() and into if_alloc_sadl(), which is normally called by functions like ether_ifattach(). Network interfaces which don't have a link-specific attach routine must call if_alloc_sadl() themselves (example: gif). Link level names are freed by if_free_sadl(), which can be called from e.g. ether_ifdetach(). Drivers never need call if_free_sadl() themselves as if_detach() will do it if it is not already done. While here, add the ability to pass an AF_LINK address to SIOCSIFADDR in ether_ioctl() (this is what caused me to notice the problem that the above fixes). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.66 2001/01/15 16:33:30 thorpej Exp $ */ d78 10 d419 1 a419 1 splimp(); d485 1 a485 1 splimp(); d500 1 a500 1 splimp(); d532 1 a532 1 s = splimp(); d597 1 a597 1 s = splimp(); d629 1 a629 1 int s = splimp(), error = 0; d900 1 a900 1 s = splimp(); d947 1 a947 1 * Should be called at splimp, since we muck with the queues. d1021 1 a1021 1 int s = splimp(); d1051 1 a1051 1 s = splimp(); d1194 1 a1194 1 s = splimp(); d1200 1 a1200 1 s = splimp(); d1254 1 a1254 1 s = splimp(); d1270 1 a1270 1 s = splimp(); d1281 1 a1281 1 s = splimp(); d1298 1 a1298 1 s = splimp(); d1338 1 a1338 1 int s = splimp(); d1391 1 a1391 1 s = splimp(); d1423 1 a1423 1 s = splimp(); d1454 1 a1454 1 s = splimp(); d1637 1 a1637 1 s = splimp(); @ 1.67.2.1 log @Initial commit of scheduler activations and lightweight process support. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67 2001/01/17 00:30:51 thorpej Exp $ */ a91 1 #include d611 1 a611 1 struct proc *p = curproc->l_proc; /* XXX */ @ 1.67.2.2 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.1 2001/03/05 22:49:54 nathanw Exp $ */ a77 10 /* * XXX IMP ME HARDER * * This is an explanation of that comment. This code used to use * splimp() to block both network and tty interrupts. However, * that call is deprecated. So, we have replaced the uses of * splimp() with splhigh() in order to applomplish what it needs * to accomplish, and added that happy little comment. */ d410 1 a410 1 splhigh(); /* XXX IMP ME HARDER */ d476 1 a476 1 splhigh(); /* XXX IMP ME HARDER */ d491 1 a491 1 splhigh(); /* XXX IMP ME HARDER */ d523 1 a523 1 s = splnet(); d588 1 a588 1 s = splnet(); d620 1 a620 1 int s = splnet(), error = 0; d891 1 a891 1 s = splnet(); d923 1 d938 1 a938 1 * Should be called at splnet, since we muck with the queues. d1012 1 a1012 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1042 1 a1042 1 s = splnet(); d1185 1 a1185 1 s = splhigh(); /* XXX IMP ME HARDER */ d1191 1 a1191 1 s = splnet(); d1245 1 a1245 1 s = splhigh(); /* XXX IMP ME HARDER */ d1261 1 a1261 1 s = splhigh(); /* XXX IMP ME HARDER */ d1272 1 a1272 1 s = splhigh(); /* XXX IMP ME HARDER */ d1289 1 a1289 1 s = splhigh(); /* XXX IMP ME HARDER */ d1329 1 a1329 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1382 1 a1382 1 s = splhigh(); /* XXX IMP ME HARDER */ d1414 1 a1414 1 s = splhigh(); /* XXX IMP ME HARDER */ d1445 1 a1445 1 s = splhigh(); /* XXX IMP ME HARDER */ d1628 1 a1628 1 s = splnet(); d1641 1 @ 1.67.2.3 log @Catch up with -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.2 2001/06/21 20:08:09 nathanw Exp $ */ d276 1 a276 1 memset((char *)&sc->sc_stats, 0, sizeof(sc->sc_stats)); d384 1 a384 2 int s, error, flags, mru, npx; u_int nb; d703 1 a703 1 memset(psp, 0, sizeof(*psp)); d722 1 a722 1 memset(pcp, 0, sizeof(*pcp)); @ 1.67.2.4 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.3 2001/08/24 00:12:12 nathanw Exp $ */ d88 1 a88 2 #include __KERNEL_RCSID(0, "$NetBSD$"); d90 1 a90 1 #include "ppp.h" d1698 2 @ 1.67.2.5 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.4 2001/11/14 19:17:23 nathanw Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.67.2.4 2001/11/14 19:17:23 nathanw Exp $"); d121 1 d123 1 @ 1.67.2.6 log @Catch up to -current. (CVS: It's not just a program. It's an adventure!) @ text @d1 1 a1 1 /* $NetBSD$ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD$"); a159 3 #ifdef ALTQ static void ppp_ifstart __P((struct ifnet *ifp)); #endif a229 3 #ifdef ALTQ sc->sc_if.if_start = ppp_ifstart; #endif d608 1 a608 1 return (EPASSTHROUGH); a1696 16 #ifdef ALTQ /* * a wrapper to transmit a packet from if_start since ALTQ uses * if_start to send a packet. */ static void ppp_ifstart(ifp) struct ifnet *ifp; { struct ppp_softc *sc; sc = ifp->if_softc; (*sc->sc_start)(sc); } #endif @ 1.67.2.7 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.6 2002/04/01 07:48:21 nathanw Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.67.2.6 2002/04/01 07:48:21 nathanw Exp $"); a188 2 struct ppp_softc ppp_softc[NPPP]; @ 1.67.2.8 log @Curproc->curlwp renaming. Change uses of "curproc->l_proc" back to "curproc", which is more like the original use. Bare uses of "curproc" are now "curlwp". "curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL) so that it is always safe to reference curproc (*de*referencing curproc is another story, but that's always been true). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.7 2002/06/20 03:48:15 nathanw Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.67.2.7 2002/06/20 03:48:15 nathanw Exp $"); d630 1 a630 1 struct proc *p = curproc; /* XXX */ @ 1.67.2.9 log @No longer need to pull in lwp.h; proc.h pulls it in for us. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.67.2.8 2002/06/24 22:11:32 nathanw Exp $ */ d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.67.2.8 2002/06/24 22:11:32 nathanw Exp $"); d103 1 @ 1.67.2.10 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD$ */ d7 14 a20 1 * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. d22 6 a27 35 * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "Carnegie Mellon University" must not be used to * endorse or promote products derived from this software without * prior written permission. For permission or any legal * details, please contact * Office of Technology Transfer * Carnegie Mellon University * 5000 Forbes Avenue * Pittsburgh, PA 15213-3890 * (412) 268-4387, fax: (412) 268-7395 * tech-transfer@@andrew.cmu.edu * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by Computing Services * at Carnegie Mellon University (http://www.cmu.edu/computing/)." * * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. d89 1 a89 1 __KERNEL_RCSID(0, "$NetBSD$"); @ 1.66 log @For SLIP/STRIP/PPP, use generic soft interrupts, if available. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.65 2000/12/18 19:50:44 thorpej Exp $ */ d226 1 @ 1.65 log @Fill in if_dlt. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.64 2000/12/18 18:57:21 thorpej Exp $ */ d109 4 d151 5 d253 8 d293 3 d1013 3 d1017 1 d1156 14 d1174 1 a1174 1 pppintr() d1176 3 a1178 3 struct ppp_softc *sc; int i, s, s2; struct mbuf *m; a1179 3 sc = ppp_softc; s = splsoftnet(); for (i = 0; i < NPPP; ++i, ++sc) { d1183 4 a1186 4 s2 = splimp(); sc->sc_flags |= SC_TBUSY; splx(s2); (*sc->sc_start)(sc); d1189 6 a1194 6 s2 = splimp(); IF_DEQUEUE(&sc->sc_rawq, m); splx(s2); if (m == NULL) break; ppp_inproc(sc, m); a1195 2 } splx(s); d1332 3 d1336 1 @ 1.64 log @Add ALTQ support. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.63 2000/12/12 18:00:27 thorpej Exp $ */ d208 1 @ 1.63 log @Adapt to bpfattach() changes, and further centralize the bpfattach() and bpfdetach() calls into link-type subroutines where possible. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.62 2000/10/26 01:26:15 wiz Exp $ */ d210 1 a210 1 sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN; d214 1 d726 1 d734 2 d875 18 a892 3 ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd; if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) { IF_DROP(ifq); d896 1 a896 2 error = ENOBUFS; goto bad; a897 1 IF_ENQUEUE(ifq, m0); d924 1 d945 17 a961 3 ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd; if (IF_QFULL(ifq)) { IF_DROP(ifq); d964 1 a964 2 } else IF_ENQUEUE(ifq, m); d1018 1 a1018 1 IF_DEQUEUE(&sc->sc_if.if_snd, m); d1145 1 a1145 1 && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head @ 1.62 log @Fix typo (thinko?), which didn't allow MRU to be set below the default value (instead of the minimum value). Patch supplied by Stephen Degler in PR #9945, and reviewed by Ignatios Souvatzis. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.61 2000/10/06 04:49:53 onoe Exp $ */ d216 1 a216 1 bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_NULL, 0); d857 2 a858 2 if (sc->sc_bpf) bpf_mtap(sc->sc_bpf, m0); d1497 2 a1498 2 if (sc->sc_bpf) bpf_mtap(sc->sc_bpf, m); @ 1.61 log @unique #include opt_inet.h @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.60 2000/10/04 02:51:18 itojun Exp $ */ d395 1 a395 1 if (mru >= PPP_MRU && mru <= PPP_MAXMRU) @ 1.60 log @need opt_inet.h for #ifdef INET @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.59 2000/10/02 03:54:10 itojun Exp $ */ a78 1 #include "opt_inet.h" d82 4 a89 4 #include "opt_inet.h" #include "opt_gateway.h" #include "opt_ppp.h" @ 1.59 log @enable VJC only with INET @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.58 2000/03/30 09:45:36 augustss Exp $ */ d79 2 @ 1.58 log @Kill some more register declarations. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.57 2000/03/23 07:03:25 thorpej Exp $ */ d81 1 d83 1 a107 1 #ifdef INET d111 1 a112 6 #else #ifdef _KERNEL #ifdef VJC #error ppp device with VJC assumes INET #endif #endif d717 1 d719 1 d1284 1 a1284 1 int s, ilen, xlen, proto, rv; d1287 2 d1291 1 @ 1.58.4.1 log @Pullup [jdolecek]: sys/arch/amiga/dev/grf_cl.c 1.26 sys/arch/amiga/dev/grfioctl.h 1.14 sys/arch/hpcmips/dev/plumvideo.c 1.20 sys/arch/macppc/dev/ofb.c 1.25 sys/arch/sparc/dev/cgtwo.c 1.35 sys/arch/sparc/include/fbio.h patch sys/arch/sparc64/include/fbio.h patch sys/arch/sun3/dev/cg2.c 1.14 sys/arch/sun3/include/fbio.h patch sys/dev/pci/tga.c 1.35 sys/dev/tc/cfb.c 1.28 sys/dev/tc/mfb.c 1.27 sys/dev/tc/sfb.c 1.46 sys/dev/tc/sfbplus.c 1.10 via patch sys/dev/tc/tfb.c 1.30 sys/dev/tc/xcfb.c 1.23 sys/net/if_ppp.c 1.71 Use unsigned variable types to make bounds checking more correct. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.58 2000/03/30 09:45:36 augustss Exp $ */ d353 1 a353 2 int s, error, flags, mru, npx; u_int nb; @ 1.57 log @New callout mechanism with two major improvements over the old timeout()/untimeout() API: - Clients supply callout handle storage, thus eliminating problems of resource allocation. - Insertion and removal of callouts is constant time, important as this facility is used quite a lot in the kernel. The old timeout()/untimeout() API has been removed from the kernel. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.56 1999/11/27 18:45:08 hannken Exp $ */ d199 2 a200 2 register struct ppp_softc *sc; register int i = 0; d587 1 a587 1 register struct ifnet *ifp; d591 4 a594 4 register struct proc *p = curproc; /* XXX */ register struct ppp_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; register struct ifreq *ifr = (struct ifreq *)data; d717 1 a717 1 register struct ppp_softc *sc = ifp->if_softc; @ 1.56 log @Fix typo introduced in rev. 1.55. It caused IP6 packets to be sent as AF_UNSPEC instead of AF_INET6. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.55 1999/07/30 10:35:38 itojun Exp $ */ d205 1 @ 1.55 log @remove reference to in6_systm.h (file itself will be removed afterwords) @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.54 1999/07/01 08:12:48 itojun Exp $ */ d768 1 a769 1 #endif @ 1.55.2.1 log @Update thorpej_scsipi to -current as of a month ago @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.61 2000/10/06 04:49:53 onoe Exp $ */ d79 1 d81 2 a82 1 #if NPPP > 0 a87 5 #ifdef INET #define VJC #endif #define PPP_COMPRESS d106 1 a109 1 #ifdef INET d111 6 d199 2 a200 2 struct ppp_softc *sc; int i = 0; a204 1 callout_init(&sc->sc_timo_ch); d586 1 a586 1 struct ifnet *ifp; d590 4 a593 4 struct proc *p = curproc; /* XXX */ struct ppp_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; d716 1 a716 1 struct ppp_softc *sc = ifp->if_softc; a719 1 #ifdef INET a720 1 #endif d768 1 a769 1 break; d1285 1 a1285 1 int s, ilen, proto, rv; a1287 2 #ifdef VJC int xlen; a1289 1 #endif @ 1.55.2.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d395 1 a395 1 if (mru >= PPP_MINMRU && mru <= PPP_MAXMRU) @ 1.55.2.3 log @Sync with HEAD (for UBC fixes). @ text @d216 1 a216 1 bpfattach(&sc->sc_if, DLT_NULL, 0); d857 2 a858 2 if (sc->sc_if.if_bpf) bpf_mtap(sc->sc_if.if_bpf, m0); d1497 2 a1498 2 if (sc->sc_if.if_bpf) bpf_mtap(sc->sc_if.if_bpf, m); @ 1.55.2.4 log @Sync with HEAD @ text @a207 1 sc->sc_if.if_dlt = DLT_NULL; d210 1 a210 1 IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); a213 1 IFQ_SET_READY(&sc->sc_if.if_snd); a724 1 ALTQ_DECL(struct altq_pktattr pktattr;) a731 2 IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); d871 3 a873 18 if ((m0->m_flags & M_HIGHPRI) #ifdef ALTQ && ALTQ_IS_ENABLED(&sc->sc_if.if_snd) == 0 #endif ) { ifq = &sc->sc_fastq; if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) { IF_DROP(ifq); splx(s); error = ENOBUFS; goto bad; } else { IF_ENQUEUE(ifq, m0); error = 0; } } else IFQ_ENQUEUE(&sc->sc_if.if_snd, m0, &pktattr, error); if (error) { d877 2 a878 1 return (error); d880 1 a906 1 int error; d927 3 a929 17 if ((m->m_flags & M_HIGHPRI) #ifdef ALTQ && ALTQ_IS_ENABLED(&sc->sc_if.if_snd) == 0 #endif ) { ifq = &sc->sc_fastq; if (IF_QFULL(ifq)) { IF_DROP(ifq); m_freem(m); error = ENOBUFS; } else { IF_ENQUEUE(ifq, m); error = 0; } } else IFQ_ENQUEUE(&sc->sc_if.if_snd, m, NULL, error); if (error) { d932 2 a933 1 } d987 1 a987 1 IFQ_DEQUEUE(&sc->sc_if.if_snd, m); d1114 1 a1114 1 && (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0 || sc->sc_fastq.ifq_head @ 1.55.2.5 log @Sync with head (for UBC+NFS fixes, mostly). @ text @a108 4 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS #include #endif a146 5 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS void pppnetisr(void); #endif void pppintr(void *); a216 1 if_alloc_sadl(&sc->sc_if); a243 8 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS sc->sc_si = softintr_establish(IPL_SOFTNET, pppintr, sc); if (sc->sc_si == NULL) { printf("ppp%d: unable to establish softintr\n", sc->sc_unit); return (NULL); } #endif a275 3 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS softintr_disestablish(sc->sc_si); #endif a992 3 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS softintr_schedule(sc->sc_si); #else a993 1 #endif a1131 14 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS void pppnetisr(void) { struct ppp_softc *sc; int i; for (i = 0; i < NPPP; i++) { sc = &ppp_softc[i]; pppintr(sc); } } #endif d1136 1 a1136 1 pppintr(void *arg) d1138 3 a1140 3 struct ppp_softc *sc = arg; struct mbuf *m; int s; d1142 3 d1148 4 a1151 4 s = splimp(); sc->sc_flags |= SC_TBUSY; splx(s); (*sc->sc_start)(sc); d1154 6 a1159 6 s = splimp(); IF_DEQUEUE(&sc->sc_rawq, m); splx(s); if (m == NULL) break; ppp_inproc(sc, m); d1161 2 a1298 3 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS softintr_schedule(sc->sc_si); #else a1299 1 #endif @ 1.55.2.6 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.55.2.5 2001/01/18 09:23:51 bouyer Exp $ */ a77 10 /* * XXX IMP ME HARDER * * This is an explanation of that comment. This code used to use * splimp() to block both network and tty interrupts. However, * that call is deprecated. So, we have replaced the uses of * splimp() with splhigh() in order to applomplish what it needs * to accomplish, and added that happy little comment. */ d409 1 a409 1 splhigh(); /* XXX IMP ME HARDER */ d475 1 a475 1 splhigh(); /* XXX IMP ME HARDER */ d490 1 a490 1 splhigh(); /* XXX IMP ME HARDER */ d522 1 a522 1 s = splnet(); d587 1 a587 1 s = splnet(); d619 1 a619 1 int s = splnet(), error = 0; d890 1 a890 1 s = splnet(); d937 1 a937 1 * Should be called at splnet, since we muck with the queues. d1011 1 a1011 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1041 1 a1041 1 s = splnet(); d1184 1 a1184 1 s = splhigh(); /* XXX IMP ME HARDER */ d1190 1 a1190 1 s = splnet(); d1244 1 a1244 1 s = splhigh(); /* XXX IMP ME HARDER */ d1260 1 a1260 1 s = splhigh(); /* XXX IMP ME HARDER */ d1271 1 a1271 1 s = splhigh(); /* XXX IMP ME HARDER */ d1288 1 a1288 1 s = splhigh(); /* XXX IMP ME HARDER */ d1328 1 a1328 1 int s = splhigh(); /* XXX IMP ME HARDER */ d1381 1 a1381 1 s = splhigh(); /* XXX IMP ME HARDER */ d1413 1 a1413 1 s = splhigh(); /* XXX IMP ME HARDER */ d1444 1 a1444 1 s = splhigh(); /* XXX IMP ME HARDER */ d1627 1 a1627 1 s = splnet(); @ 1.55.8.1 log @Pull up to last week's -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.56 1999/11/27 18:45:08 hannken Exp $ */ d768 1 a769 1 break; @ 1.54 log @IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628. (Sorry for a big commit, I can't separate this into several pieces...) Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details. - sys/kern: do not assume single mbuf, accept chained mbuf on passing data from userland to kernel (or other way round). - "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ package (ftp://ftp.csl.sony.co.jp/pub/kjc/). - sys/netinet/tcp*: IPv4/v6 dual stack tcp support. - sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those file to be there so we patch it up. - sys/netinet: IPsec additions are here and there. - sys/netinet6/*: most of IPv6 code sits here. - sys/netkey: IPsec key management code - dev/pci/pcidevs: regen In my understanding no code here is subject to export control so it should be safe. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.53 1999/05/14 21:33:41 tron Exp $ */ d489 3 d607 10 a616 1 if (ifa->ifa_addr->sa_family != AF_INET) d618 2 d623 10 a632 1 if (ifa->ifa_addr->sa_family != AF_INET) d634 2 d659 4 d753 18 d913 3 d1520 19 @ 1.53 log @Fix compilation problem caused by recent changes to filtering code. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.52 1999/05/12 18:50:51 thorpej Exp $ */ d111 6 @ 1.52 log @Decouple inbound and outbound filters. Now instead of using "active-filter" and "pass-filter" and "inbound" and "outbound" qualifiers in the filter expression, use new "active-filter-in", "active-filter-out", "pass-filter-in", and "pass-filter-out" without these qualifiers. This is necessary due to the horrible, awful way "inbound" and "outbound" were specified for the filter programs when a packet was passed through them. Basically, the "address" byte in the serial PPP header was overwritten with a value to indicate the direction. However, the "address" byte doesn't even exist on PPP headers for all other PPP encaps! So, this old method worked only for serial encaps, and corrupted packets for all others (PPPoE, ATM, etc.) @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.51 1999/05/11 02:18:52 thorpej Exp $ */ d306 4 a309 4 if (sc->sc_pass_filt.bf_insns != 0) { FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF); sc->sc_pass_filt.bf_insns = 0; sc->sc_pass_filt.bf_len = 0; d311 14 a324 4 if (sc->sc_active_filt.bf_insns != 0) { FREE(sc->sc_active_filt.bf_insns, M_DEVBUF); sc->sc_active_filt.bf_insns = 0; sc->sc_active_filt.bf_len = 0; @ 1.51 log @* Start out with a data link type of DLT_NULL. When we change an interface to serial encap, change its data link type to DLT_PPP_SERIAL. * Work around some serious bogosity in the filtering code which utterly breaks proper functioning of BPF. The PPP code and pppd(8) WILL be changed to fix this. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.50 1999/01/09 21:47:09 thorpej Exp $ */ d504 7 d516 2 a517 4 MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK); if (newcode == 0) { return EINVAL; /* or sumpin */ } d520 1 a520 1 FREE(newcode, M_DEVBUF); d524 1 a524 1 FREE(newcode, M_DEVBUF); d529 17 a545 1 bp = (cmd == PPPIOCSPASS)? &sc->sc_pass_filt: &sc->sc_active_filt; d552 1 a552 1 FREE(oldcode, M_DEVBUF); d554 1 a554 1 #endif a761 4 #if defined(PPP_FILTER) || NBPFILTER > 0 *mtod(m0, u_char *) = SLIPDIR_OUT; #endif d768 2 a769 2 if (sc->sc_pass_filt.bf_insns != 0 && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m0, d778 3 a780 2 if (sc->sc_active_filt.bf_insns == 0 || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0)) a781 1 a789 4 #if defined(PPP_FILTER) || NBPFILTER > 0 *mtod(m0, u_char *) = address; #endif a1400 4 #if defined(PPP_FILTER) || NBPFILTER > 0 *mtod(m, u_char *) = SLIPDIR_IN; #endif d1407 2 a1408 3 adrs = *mtod(m, u_char *); /* save address field */ if (sc->sc_pass_filt.bf_insns != 0 && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m, d1414 3 a1416 2 if (sc->sc_active_filt.bf_insns == 0 || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0)) a1417 1 a1424 4 #if defined(PPP_FILTER) || NBPFILTER > 0 *mtod(m, u_char *) = adrs; #endif @ 1.50 log @Use M_LINK{0,1} for our own mbuf flags, rather than arbitrarily picking 2 bits. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.49 1998/12/10 17:48:40 christos Exp $ */ d212 1 a212 1 bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN); d773 4 a784 4 #if defined(PPP_FILTER) || NBPFILTER > 0 *mtod(m0, u_char *) = address; #endif d1418 4 a1425 4 #endif #if defined(PPP_FILTER) || NBPFILTER > 0 *mtod(m, u_char *) = adrs; @ 1.50.6.1 log @KAME/NetBSD 1.4 SNAP kit, dated 19990628. NOTE: this branch (kame) is used just for refernce. this may not compile due to multiple reasons. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.50 1999/01/09 21:47:09 thorpej Exp $ */ a110 6 #else #ifdef _KERNEL #ifdef VJC #error ppp device with VJC assumes INET #endif #endif @ 1.50.6.2 log @bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch just for reference purposes. This commit includes 1.4 -> 1.4.1 sync for kame branch. The branch does not compile at all (due to the lack of ALTQ and some other source code). Please do not try to modify the branch, this is just for referenre purposes. synchronization to latest KAME will take place on HEAD branch soon. @ text @@ 1.50.4.1 log @Sync w/ -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.53 1999/05/14 21:33:41 tron Exp $ */ d212 1 a212 1 bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_NULL, 0); d306 9 a314 19 if (sc->sc_pass_filt_in.bf_insns != 0) { FREE(sc->sc_pass_filt_in.bf_insns, M_DEVBUF); sc->sc_pass_filt_in.bf_insns = 0; sc->sc_pass_filt_in.bf_len = 0; } if (sc->sc_pass_filt_out.bf_insns != 0) { FREE(sc->sc_pass_filt_out.bf_insns, M_DEVBUF); sc->sc_pass_filt_out.bf_insns = 0; sc->sc_pass_filt_out.bf_len = 0; } if (sc->sc_active_filt_in.bf_insns != 0) { FREE(sc->sc_active_filt_in.bf_insns, M_DEVBUF); sc->sc_active_filt_in.bf_insns = 0; sc->sc_active_filt_in.bf_len = 0; } if (sc->sc_active_filt_out.bf_insns != 0) { FREE(sc->sc_active_filt_out.bf_insns, M_DEVBUF); sc->sc_active_filt_out.bf_insns = 0; sc->sc_active_filt_out.bf_len = 0; a503 7 /* These are no longer supported. */ return EOPNOTSUPP; case PPPIOCSIPASS: case PPPIOCSOPASS: case PPPIOCSIACTIVE: case PPPIOCSOACTIVE: d509 4 a512 2 newcode = malloc(newcodelen, M_DEVBUF, M_WAITOK); /* WAITOK -- malloc() never fails. */ d515 1 a515 1 free(newcode, M_DEVBUF); d519 1 a519 1 free(newcode, M_DEVBUF); d524 1 a524 17 switch (cmd) { case PPPIOCSIPASS: bp = &sc->sc_pass_filt_in; break; case PPPIOCSOPASS: bp = &sc->sc_pass_filt_out; break; case PPPIOCSIACTIVE: bp = &sc->sc_active_filt_in; break; case PPPIOCSOACTIVE: bp = &sc->sc_active_filt_out; break; } d531 1 a531 1 free(oldcode, M_DEVBUF); d533 1 a533 1 #endif /* PPP_FILTER */ d741 4 d751 2 a752 2 if (sc->sc_pass_filt_out.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_out.bf_insns, (u_char *) m0, d761 2 a762 3 if (sc->sc_active_filt_out.bf_insns == 0 || bpf_filter(sc->sc_active_filt_out.bf_insns, (u_char *) m0, len, 0)) d764 1 d781 4 d1388 4 d1398 3 a1400 2 if (sc->sc_pass_filt_in.bf_insns != 0 && bpf_filter(sc->sc_pass_filt_in.bf_insns, (u_char *) m, d1406 2 a1407 3 if (sc->sc_active_filt_in.bf_insns == 0 || bpf_filter(sc->sc_active_filt_in.bf_insns, (u_char *) m, ilen, 0)) d1409 1 d1422 4 @ 1.50.4.2 log @Sync w/ -current. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.50.4.1 1999/06/21 01:27:34 thorpej Exp $ */ a110 6 #else #ifdef _KERNEL #ifdef VJC #error ppp device with VJC assumes INET #endif #endif @ 1.50.4.3 log @Update from trunk. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.50.4.2 1999/07/01 23:45:20 thorpej Exp $ */ a488 3 case PPP_IPV6: npx = NP_IPV6; break; d604 1 a604 10 switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: a605 2 break; } d609 1 a609 10 switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: a610 2 break; } a633 4 #ifdef INET6 case AF_INET6: break; #endif a723 18 #ifdef INET6 case AF_INET6: address = PPP_ALLSTATIONS; /*XXX*/ control = PPP_UI; /*XXX*/ protocol = PPP_IPV6; mode = sc->sc_npmode[NP_IPV6]; #if 0 /* XXX flowinfo/traffic class, maybe? */ /* * If this packet has the "low delay" bit set in the IP header, * put it on the fastq instead. */ ip = mtod(m0, struct ip *); if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; break; #endif #endif a865 3 case PPP_IPV6: mode = sc->sc_npmode[NP_IPV6]; break; a1469 19 break; #endif #ifdef INET6 case PPP_IPV6: /* * IPv6 packet - take off the ppp header and pass it up to IPv6. */ if ((ifp->if_flags & IFF_UP) == 0 || sc->sc_npmode[NP_IPV6] != NPMODE_PASS) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; schednetisr(NETISR_IPV6); inq = &ip6intrq; @ 1.49 log @Revert IPX changes that I committed accidentally. @ text @d1 1 a1 1 /* $NetBSD$ */ d158 3 a160 2 * We steal two bits in the mbuf m_flags, to mark high-priority packets * for output, and received packets following lost/corrupted packets. d162 2 a163 3 #define M_HIGHPRI 0x2000 /* output packet for sc_fastq */ #define M_ERRMARK 0x4000 /* steal a bit in mbuf m_flags */ @ 1.48 log @defopt @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.47 1998/09/03 14:12:36 christos Exp $ */ a112 5 #if IPX #include #include #endif d567 4 d572 1 a572 10 switch(ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef IPX case AF_IPX: break; #endif default: a573 2 break; } a686 13 #ifdef IPX case AF_IPX: /* * This is pretty bogus.. We dont have an ipxcp module in pppd * yet to configure the link parameters. Sigh. I guess a * manual ifconfig would do.... -Peter */ address = PPP_ALLSTATIONS; control = PPP_UI; protocol = PPP_IPX; mode = NPMODE_PASS; break; #endif a1449 19 break; #endif #ifdef IPX case PPP_IPX: /* * IPX packet - take off the ppp header and pass it up to IPX. */ if ((sc->sc_if.if_flags & IFF_UP) == 0 /* XXX: || sc->sc_npmode[NP_IPX] != NPMODE_PASS*/) { /* interface is down - drop the packet. */ m_freem(m); return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; schednetisr(NETISR_IPX); inq = &ipxintrq; @ 1.47 log @PR/5414: Ronald Khoo: tcpdump ppp does not respect inbound/outbound qualifiers. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.46 1998/08/02 15:09:50 sommerfe Exp $ */ d86 1 d113 5 a571 4 if (ifa->ifa_addr->sa_family != AF_INET) error = EAFNOSUPPORT; break; d573 10 a582 1 if (ifa->ifa_addr->sa_family != AF_INET) d584 2 d699 13 d1475 19 @ 1.47.4.1 log @The beginnings of interface detach support. Still some bugs, but mostly works for me. This work was originally by Bill Studenmund, and cleaned up by me. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.47 1998/09/03 14:12:36 christos Exp $ */ a193 1 register struct ifnet *ifp; d197 9 a205 15 #ifdef _HAS_IF_ALLOC ifp = if_alloc(); sc->sc_if = ifp; #else ifp = &sc->sc_if; #endif sprintf(ifp->if_xname, "ppp%d", i++); ifp->if_softc = sc; ifp->if_mtu = PPP_MTU; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_type = IFT_PPP; ifp->if_hdrlen = PPP_HDRLEN; ifp->if_ioctl = pppsioctl; ifp->if_output = pppoutput; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; d209 1 a209 1 if_attach(ifp); d211 1 a211 1 bpfattach(&sc->sc_bpf, ifp, DLT_PPP, PPP_HDRLEN); a268 4 #ifdef _HAS_IF_ALLOC if_down(sc->sc_if); sc->sc_if->if_flags &= ~(IFF_UP|IFF_RUNNING); #else a270 1 #endif a338 1 struct ifnet *ifp; a347 5 #ifdef _HAS_IF_ALLOC ifp = sc->sc_if; #else ifp = &sc->sc_if; #endif d434 1 a434 1 ifp->if_xname); d449 1 a449 1 ifp->if_xname); d460 1 a460 1 ifp->if_xname, ccp_option[0], ccp_option[1], d578 1 a578 1 ifp->if_mtu = ifr->ifr_mtu; d582 1 a582 1 ifr->ifr_mtu = ifp->if_mtu; d798 1 a798 1 ifp->if_oerrors++; a828 1 struct ifnet *ifp; a830 6 #ifdef _HAS_IF_ALLOC ifp = sc->sc_if; #else ifp = &sc->sc_if; #endif d847 1 a847 1 ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd; d850 1 a850 1 ifp->if_oerrors++; a895 1 struct ifnet *ifp; a899 6 #ifdef _HAS_IF_ALLOC ifp = sc->sc_if; #else ifp = &sc->sc_if; #endif d907 1 a907 1 IF_DEQUEUE(&ifp->if_snd, m); d981 1 a981 1 (sc->sc_xc_state, &mcomp, m, slen, ifp->if_mtu + PPP_HDRLEN); d1034 1 a1034 1 && (sc->sc_if->if_snd.ifq_head || sc->sc_fastq.ifq_head a1202 3 #ifdef _HAS_IF_ALLOC struct ifnet *ifp = sc->sc_if; #else a1203 1 #endif a1385 1 if_addref(ifp); d1486 1 a1486 1 ifp->if_ierrors++; @ 1.46 log @Fix PR5898: ppp delays last packet. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.45 1998/07/09 22:30:01 thorpej Exp $ */ d118 4 d740 4 a749 1 *mtod(m0, u_char *) = 1; /* indicates outbound */ a763 1 *mtod(m0, u_char *) = address; d780 4 d1387 4 a1397 1 *mtod(m, u_char *) = 0; /* indicate inbound */ a1408 1 *mtod(m, u_char *) = adrs; d1421 4 @ 1.45 log @Glue in fast forwarding. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.44 1998/07/08 18:05:48 sommerfe Exp $ */ d1024 2 a1025 1 && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) { @ 1.44 log @Only run pppasyncstart (sc->sc_start) from the netisr handler. This allows pppoutput to be called from splimp (e.g., when ipflow is in use.) without requiring pppasyncstart to run at splimp. This is believed to fix PR5624. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.43 1998/07/06 13:51:32 jtk Exp $ */ d85 1 d1426 4 @ 1.43 log @use #ifdef INET so this compiles again @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.42 1998/07/05 00:51:26 jonathan Exp $ */ d476 1 a476 1 s = splsoftnet(); d480 1 a480 1 (*sc->sc_start)(sc); d776 1 a776 1 s = splsoftnet(); d793 1 a793 1 (*sc->sc_start)(sc); d810 1 a810 1 * Should be called at splsoftnet. d887 1 d893 1 d897 2 @ 1.42 log @defopt INET, NETATALK. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.41 1998/05/02 14:34:24 christos Exp $ */ d104 1 a104 1 #if INET @ 1.41 log @Merge changes from pppd-2.3.4; adds ppp-deflate-draft stuff and updates zlib. Maybe we can merge our other copy of zlib with this one now and avoid having two copies? @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.40 1997/06/16 17:01:36 christos Exp $ */ d83 2 @ 1.40 log @From Paul Mackerras: use sl_compress_setup, not sl_compress_init @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ d164 1 a164 1 extern struct compressor ppp_deflate; d172 1 @ 1.39 log @Update to ppp-2.3b5 @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.38 1997/04/16 12:54:42 is Exp $ */ d386 1 a386 1 sl_compress_init(sc->sc_comp); @ 1.38 log @Made pppoutput() public again on behalf of Martin Husemann (PR 3455). Apparently, the BISDN package uses this function. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.37 1997/03/12 20:26:50 christos Exp $ */ d237 1 a237 1 sl_compress_init(sc->sc_comp, -1); d386 1 a386 1 sl_compress_init(sc->sc_comp, *(int *)data); @ 1.37 log @Update to ppp-2.3b4; from Paul Mackerras @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.36 1997/03/04 21:40:07 mycroft Exp $ */ a129 2 static int pppoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *)); @ 1.36 log @Use splimp() to block interrupts, not splhigh(). @ text @d1 2 a2 1 /* $NetBSD: if_ppp.c,v 1.35 1996/10/13 02:11:03 christos Exp $ */ d98 1 d100 1 d129 3 a132 1 static void ppp_outpkt __P((struct ppp_softc *)); d179 1 d298 1 d309 1 d334 1 d338 1 d494 1 d526 1 d537 1 a537 1 int d543 1 d570 2 d575 4 d650 1 a650 1 int active, len; a733 5 /* * Apply the pass and active filters to the packet, * but only if it is a data packet. */ active = 0; d735 5 d756 6 d859 2 a860 5 * Get a packet to send. This procedure is intended to be called at * spltty or splimp, so it takes little time. If there isn't a packet * waiting to go out, it schedules a software interrupt to prepare a * new packet; the device start routine gets called again when a * packet is ready. d862 2 a863 2 struct mbuf * ppp_dequeue(sc) a865 1 struct mbuf *m; a867 13 m = sc->sc_togo; if (m) { /* * Had a packet waiting - send it. */ sc->sc_togo = NULL; sc->sc_flags |= SC_TBUSY; splx(s); return m; } /* * Remember we wanted a packet and schedule a software interrupt. */ a870 1 return NULL; d874 4 a877 1 * Software interrupt routine, called at splsoftnet. d879 2 a880 30 void pppintr() { struct ppp_softc *sc; int i, s; struct mbuf *m; sc = ppp_softc; for (i = 0; i < NPPP; ++i, ++sc) { if (!(sc->sc_flags & SC_TBUSY) && sc->sc_togo == NULL && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) ppp_outpkt(sc); for (;;) { s = splimp(); IF_DEQUEUE(&sc->sc_rawq, m); splx(s); if (m == NULL) break; ppp_inproc(sc, m); } } } /* * Grab another packet off a queue and apply VJ compression, * packet compression, address/control and/or protocol compression * if enabled. Should be called at splsoftnet. */ static void ppp_outpkt(sc) d895 1 a895 1 return; d965 1 a965 2 (sc->sc_xc_state, &mcomp, m, slen, (sc->sc_flags & SC_CCP_UP? sc->sc_if.if_mtu: 0)); d967 10 a976 4 m_freem(m); m = mcomp; cp = mtod(m, u_char *); protocol = cp[3]; d1001 33 a1033 2 sc->sc_togo = m; (*sc->sc_start)(sc); a1369 4 /* * See whether we want to pass this packet, and * if it counts as link activity. */ d1371 5 d1390 6 @ 1.35 log @backout previous kprintf change @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.34 1996/10/10 22:59:48 christos Exp $ */ d355 1 a355 1 splhigh(); d421 1 a421 1 splhigh(); d436 1 a436 1 splhigh(); d845 1 a845 1 int s = splhigh(); d882 1 a882 1 s = splhigh(); d1063 1 a1063 1 s = splhigh(); d1079 1 a1079 1 s = splhigh(); d1090 1 a1090 1 s = splhigh(); d1107 1 a1107 1 s = splhigh(); d1147 1 a1147 1 int s = splhigh(); d1193 1 a1193 1 s = splhigh(); d1225 1 a1225 1 s = splhigh(); d1256 1 a1256 1 s = splhigh(); d1412 1 a1412 1 s = splhigh(); @ 1.35.4.1 log @Merge in changes from The Trunk @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.36 1997/03/04 21:40:07 mycroft Exp $ */ d355 1 a355 1 splimp(); d421 1 a421 1 splimp(); d436 1 a436 1 splimp(); d845 1 a845 1 int s = splimp(); d882 1 a882 1 s = splimp(); d1063 1 a1063 1 s = splimp(); d1079 1 a1079 1 s = splimp(); d1090 1 a1090 1 s = splimp(); d1107 1 a1107 1 s = splimp(); d1147 1 a1147 1 int s = splimp(); d1193 1 a1193 1 s = splimp(); d1225 1 a1225 1 s = splimp(); d1256 1 a1256 1 s = splimp(); d1412 1 a1412 1 s = splimp(); @ 1.34 log @- printf -> kprintf, sprintf -> ksprintf @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.33 1996/06/13 21:50:32 cgd Exp $ */ d185 1 a185 1 ksprintf(sc->sc_if.if_xname, "ppp%d", i++); d417 1 a417 1 kprintf("%s: comp_alloc failed\n", d432 1 a432 1 kprintf("%s: decomp_alloc failed\n", d443 1 a443 1 kprintf("%s: no compressor for [%x %x %x], %x\n", d668 1 a668 1 kprintf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); d711 1 a711 1 kprintf("%s output: ", ifp->if_xname); d1052 1 a1052 1 kprintf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n", d1182 1 a1182 1 kprintf("%s: got %d bytes\n", ifp->if_xname, ilen); d1224 1 a1224 1 kprintf("%s: decompress failed %d\n", ifp->if_xname, rv); d1274 1 a1274 1 kprintf("%s: VJ uncompress failed on type comp\n", d1326 1 a1326 1 kprintf("%s: VJ uncompress failed on type uncomp\n", d1417 1 a1417 1 kprintf("%s: input queue full\n", ifp->if_xname); d1471 1 a1471 1 kprintf("%s\n", buf); @ 1.33 log @no need for a local implementation of SIOCGIFMTU; delete it. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.32 1996/05/22 13:55:10 mycroft Exp $ */ d185 1 a185 1 sprintf(sc->sc_if.if_xname, "ppp%d", i++); d417 2 a418 2 printf("%s: comp_alloc failed\n", sc->sc_if.if_xname); d432 2 a433 2 printf("%s: decomp_alloc failed\n", sc->sc_if.if_xname); d443 3 a445 3 printf("%s: no compressor for [%x %x %x], %x\n", sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); d668 1 a668 1 printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); d711 1 a711 1 printf("%s output: ", ifp->if_xname); d1052 2 a1053 2 printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n", dp, slen, mtod(mp, u_char *), mp->m_len); d1182 1 a1182 1 printf("%s: got %d bytes\n", ifp->if_xname, ilen); d1224 1 a1224 1 printf("%s: decompress failed %d\n", ifp->if_xname, rv); d1274 2 a1275 2 printf("%s: VJ uncompress failed on type comp\n", ifp->if_xname); d1326 2 a1327 2 printf("%s: VJ uncompress failed on type uncomp\n", ifp->if_xname); d1417 1 a1417 1 printf("%s: input queue full\n", ifp->if_xname); d1471 1 a1471 1 printf("%s\n", buf); @ 1.32 log @Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait. Remove SS_PRIV completely. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.31 1996/05/07 02:40:36 thorpej Exp $ */ a557 4 break; case SIOCGIFMTU: ifr->ifr_mtu = sc->sc_if.if_mtu; @ 1.31 log @Changed struct ifnet to have a pointer to the softc of the underlying device and a printable "external name" (name + unit number), thus eliminating if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)() to take a struct ifnet *, rather than a unit number. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.30 1996/03/19 01:00:49 paulus Exp $ */ a530 1 struct proc *p = curproc; /* XXX */ a556 2 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) break; @ 1.31.4.1 log @From trunk: Eliminate SS_PRIV; instead, pass down a proc pointer to the usrreq methods that need it. Fix numerous memory leaks and bogus return values. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.32 1996/05/22 13:55:10 mycroft Exp $ */ d531 1 d558 2 @ 1.30 log @Make inclusion of the PPP BSD-Compress and Deflate compressors dependent on the PPP_BSDCOMP and PPP_DEFLATE kernel configuration options, respectively. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.29 1996/03/15 02:28:03 paulus Exp $ */ d184 3 a186 2 sc->sc_if.if_name = "ppp"; sc->sc_if.if_unit = i++; d339 1 a339 1 *(int *)data = sc->sc_if.if_unit; d417 2 a418 2 printf("ppp%d: comp_alloc failed\n", sc->sc_if.if_unit); d432 2 a433 2 printf("ppp%d: decomp_alloc failed\n", sc->sc_if.if_unit); d443 2 a444 2 printf("ppp%d: no compressor for [%x %x %x], %x\n", sc->sc_if.if_unit, ccp_option[0], ccp_option[1], d532 1 a532 1 register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; d631 1 a631 1 register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; d675 1 a675 1 printf("ppp%d: af%d not supported\n", ifp->if_unit, dst->sa_family); d718 1 a718 1 printf("ppp%d output: ", ifp->if_unit); d1085 1 a1085 1 sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) { d1095 1 a1095 1 sc->sc_if.if_unit, 0, sc->sc_mru, d1189 1 a1189 1 printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen); d1231 1 a1231 1 printf("ppp%d: decompress failed %d\n", ifp->if_unit, rv); d1281 2 a1282 2 printf("ppp%d: VJ uncompress failed on type comp\n", ifp->if_unit); d1333 2 a1334 2 printf("ppp%d: VJ uncompress failed on type uncomp\n", ifp->if_unit); d1424 1 a1424 1 printf("ppp%d: input queue full\n", ifp->if_unit); @ 1.29 log @Added packet filtering, support for "PPP Deflate" packet compression, trivial multicast support, and support for xon/xoff output flow control to the PPP subsystem. Fixed several bugs, including making the accumulation and resetting of statistics more consistent. State for the VJ compressor is now dynamically allocated. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.28 1996/02/13 22:00:18 christos Exp $ */ d164 1 a164 1 #if DO_BSD_COMPRESS d167 1 a167 1 #if DO_DEFLATE @ 1.28 log @Net prototypes @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.27 1996/02/07 12:43:41 pk Exp $ */ d90 2 d97 1 d161 1 d167 3 d187 1 a187 1 sc->sc_if.if_flags = IFF_POINTOPOINT; d227 1 d229 4 a232 1 sl_compress_init(&sc->sc_comp, -1); d291 16 d325 3 d375 5 a379 3 s = splsoftnet(); sl_compress_init(&sc->sc_comp, *(int *)data); splx(s); d483 32 d566 17 d586 12 a597 15 psp->p.ppp_ibytes = sc->sc_bytesrcvd; psp->p.ppp_ipackets = ifp->if_ipackets; psp->p.ppp_ierrors = ifp->if_ierrors; psp->p.ppp_obytes = sc->sc_bytessent; psp->p.ppp_opackets = ifp->if_opackets; psp->p.ppp_oerrors = ifp->if_oerrors; #ifdef VJC psp->vj.vjs_packets = sc->sc_comp.sls_packets; psp->vj.vjs_compressed = sc->sc_comp.sls_compressed; psp->vj.vjs_searches = sc->sc_comp.sls_searches; psp->vj.vjs_misses = sc->sc_comp.sls_misses; psp->vj.vjs_uncompressedin = sc->sc_comp.sls_uncompressedin; psp->vj.vjs_compressedin = sc->sc_comp.sls_compressedin; psp->vj.vjs_errorin = sc->sc_comp.sls_errorin; psp->vj.vjs_tossed = sc->sc_comp.sls_tossed; d637 2 d712 4 d721 24 d764 1 a764 1 if (IF_QFULL(ifq)) { d768 1 d776 2 d820 1 d921 2 a933 5 /* * Update the time we sent the most recent packet. */ sc->sc_last_sent = time.tv_sec; d938 1 a938 1 if (sc->sc_flags & SC_COMP_TCP) { d952 1 a952 1 type = sl_compress_tcp(mp, ip, &sc->sc_comp, d982 1 a982 1 struct mbuf *mcomp; d1176 1 a1176 1 int s, ilen = 0, xlen, proto, rv; d1178 1 a1178 1 struct mbuf *mp, *dmp; d1182 1 a1182 2 ifp->if_ipackets++; ifp->if_lastchange = time; d1185 1 a1185 1 register int len = 0; d1187 2 a1188 2 len += mp->m_len; printf("ppp%d: got %d bytes\n", ifp->if_unit, len); d1260 2 a1261 1 sl_uncompress_tcp(NULL, 0, TYPE_ERROR, &sc->sc_comp); d1271 1 a1271 1 if (sc->sc_flags & SC_REJ_COMP_TCP) d1276 1 a1276 1 &sc->sc_comp, &iphdr, &hlen); d1323 1 a1323 1 if (sc->sc_flags & SC_REJ_COMP_TCP) d1328 1 a1328 1 &sc->sc_comp, &iphdr, &hlen); d1358 21 a1402 1 sc->sc_last_recv = time.tv_sec; /* update time of last pkt rcvd */ d1429 3 d1441 1 @ 1.27 log @wrt. previous change: can't compute `ilen' that early; just do computation separately when logging. Notes: consider using mbuf pkthdr length field in PPP code. condider doing packet log after de-compression. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.26 1996/02/07 10:25:58 pk Exp $ */ d89 1 a122 8 void pppattach __P((void)); int pppioctl __P((struct ppp_softc *sc, u_long cmd, caddr_t data, int flag, struct proc *)); int pppoutput __P((struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, struct rtentry *rtp)); int pppsioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data)); void pppintr __P((void)); d125 1 a125 1 static int ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd)); d316 1 a316 1 if (error = suser(p->p_ucred, &p->p_acflag)) d330 1 a330 1 if (error = suser(p->p_ucred, &p->p_acflag)) d343 1 a343 1 if (error = suser(p->p_ucred, &p->p_acflag)) d352 1 a352 1 if (error = suser(p->p_ucred, &p->p_acflag)) d359 1 a359 1 if (error = suser(p->p_ucred, &p->p_acflag)) d365 1 a365 1 if (error = copyin(odp->ptr, ccp_option, nb)) d429 1 a429 1 if (error = suser(p->p_ucred, &p->p_acflag)) d493 1 a493 1 if (error = suser(p->p_ucred, &p->p_acflag)) a552 1 struct ppp_header *ph; d561 1 a561 1 || (ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC) { a794 1 int s; a797 1 enum NPmode mode; d920 1 a920 1 static int d949 1 a949 1 printf("if_ppp/ccp: not enough data in mbuf (%x+%x > %x+%x)\n", d1067 1 a1067 1 int s, ilen, xlen, proto, rv; @ 1.26 log @Init variable before use (PRs 1646 & 2042). @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.25 1995/12/27 06:30:38 mycroft Exp $ */ a1085 4 ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; d1087 4 a1090 1 printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen); d1151 4 @ 1.25 log @Remove old workaround for a bug. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.24 1995/10/05 05:55:09 mycroft Exp $ */ d1086 4 a1151 4 ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; @ 1.24 log @Add some missing statistics. From Thorsten Lockert. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.23 1995/08/12 23:59:21 mycroft Exp $ */ a89 4 #ifdef i386 #include #endif a200 12 #ifdef i386 /* * XXX kludge to fix the bug in the i386 interrupt handling code, * where software interrupts could be taken while hardware * interrupts were blocked. */ if ((imask[IPL_TTY] & SIR_NETMASK) == 0) { imask[IPL_TTY] |= SIR_NETMASK; intr_calculatemasks(); } #endif @ 1.23 log @splnet --> splsoftnet @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.22 1995/07/04 06:28:20 paulus Exp $ */ d690 1 d1091 1 d1099 2 a1100 1 sc->sc_if.if_ipackets++; d1103 1 a1103 1 printf("ppp%d: got %d bytes\n", sc->sc_if.if_unit, ilen); d1145 1 a1145 1 printf("ppp%d: decompress failed %d\n", sc->sc_if.if_unit, rv); d1195 1 a1195 1 sc->sc_if.if_unit); d1247 1 a1247 1 sc->sc_if.if_unit); d1270 1 a1270 1 m->m_pkthdr.rcvif = &sc->sc_if; d1285 1 a1285 1 if ((sc->sc_if.if_flags & IFF_UP) == 0 d1317 2 a1318 2 printf("ppp%d: input queue full\n", sc->sc_if.if_unit); sc->sc_if.if_iqdrops++; @ 1.22 log @Latest version of PPP stuff, with packet compression and other improvements. The PPP kernel code is now split into if_ppp.c, containing generic PPP support, and ppp_tty.c, which specifically supports PPP on async tty devices (as a line discipline). This is so that other devices can be supported without making them look like ttys. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.14 1995/07/04 03:46:00 paulus Exp $ */ a176 5 #ifndef splsoftnet #define splsoftnet splnet /* some ports may not have this */ #endif @ 1.21 log @fixed sized types, where appropriate. when casting pointers to integers to do math on them, cast to long. ioctl commands are u_longs. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.20 1994/10/30 21:48:52 cgd Exp $ */ d75 1 d81 1 a85 2 #include #include a87 2 #include #include d89 4 a92 2 #include #include a113 6 #define HDROFF MAX_HDR /* HDROFF should really be 128, but other parts of the system will panic on TCP+IP headers bigger than MAX_HDR = MHLEN (100). */ #else #define HDROFF (0) d116 1 d118 1 d121 4 a124 6 /* This is a NetBSD-current kernel. */ #define CCOUNT(q) ((q)->c_cc) #define PPP_HIWAT 400 /* Don't start a new packet if HIWAT on que */ struct ppp_softc ppp_softc[NPPP]; d127 2 a128 6 int pppopen __P((dev_t dev, struct tty *tp)); void pppclose __P((struct tty *tp, int flag)); int pppread __P((struct tty *tp, struct uio *uio, int flag)); int pppwrite __P((struct tty *tp, struct uio *uio, int flag)); int ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *)); d131 9 a139 10 void pppinput __P((int c, struct tty *tp)); int pppioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data)); void pppstart __P((struct tty *tp)); static int pppasyncstart __P((struct ppp_softc *)); static u_int16_t pppfcs __P((u_int fcs, u_char *cp, int len)); static int pppgetm __P((struct ppp_softc *sc)); static void pppdumpm __P((struct mbuf *m0, int pktlen)); static void pppdumpb __P((u_char *b, int l)); static void ppplogchar __P((struct ppp_softc *, int)); d144 2 d147 1 a147 1 ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf : \ d151 1 a151 1 ((m)->m_flags & M_EXT ? (m)->m_ext.ext_size : \ d155 2 a156 4 * The following disgusting hack gets around the problem that IP TOS * can't be set yet. We want to put "interactive" traffic on a high * priority queue. To decide if traffic is interactive, we check that * a) it is TCP and b) one of its ports is telnet, rlogin or ftp control. d158 3 a160 5 static u_int16_t interactive_ports[8] = { 0, 513, 0, 0, 0, 21, 0, 23, }; #define INTERACTIVE(p) (interactive_ports[(p) & 7] == (p)) d162 1 d164 2 a165 1 * Does c need to be escaped? d167 15 a181 1 #define ESCAPE_P(c) (sc->sc_asyncmap[(c) >> 5] & (1 << ((c) & 0x1F))) d199 1 a199 1 sc->sc_if.if_ioctl = pppioctl; d204 1 d210 12 d231 1 a231 1 int nppp; d237 4 a241 5 } if (nppp >= NPPP) for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) if (sc->sc_devp == NULL) break; d247 1 d251 9 a259 1 sc->sc_if.if_flags |= IFF_RUNNING; d265 1 a265 1 * Deallocate a ppp unit. d267 1 d274 1 d278 6 d295 3 a297 77 sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); } /* * Line specific open routine for async tty devices. * Attach the given tty to the first available ppp unit. */ /* ARGSUSED */ int pppopen(dev, tp) dev_t dev; register struct tty *tp; { struct proc *p = curproc; /* XXX */ register struct ppp_softc *sc; int error, s, i; if (error = suser(p->p_ucred, &p->p_acflag)) return (error); if (tp->t_line == PPPDISC) { sc = (struct ppp_softc *) tp->t_sc; if (sc != NULL && sc->sc_devp == (void *) tp) return (0); } if ((sc = pppalloc(p->p_pid)) == NULL) return ENXIO; if (sc->sc_outm != NULL) { m_freem(sc->sc_outm); sc->sc_outm = NULL; } pppgetm(sc); sc->sc_ilen = 0; bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap)); sc->sc_asyncmap[0] = 0xffffffff; sc->sc_asyncmap[3] = 0x60000000; sc->sc_rasyncmap = 0; sc->sc_devp = (void *) tp; sc->sc_start = pppasyncstart; tp->t_sc = (caddr_t) sc; ttyflush(tp, FREAD | FWRITE); return (0); } /* * Line specific close routine. * Detach the tty from the ppp unit. * Mimics part of ttyclose(). */ void pppclose(tp, flag) struct tty *tp; int flag; { register struct ppp_softc *sc; struct mbuf *m; int s; ttywflush(tp); s = splimp(); /* paranoid; splnet probably ok */ tp->t_line = 0; sc = (struct ppp_softc *)tp->t_sc; if (sc != NULL) { tp->t_sc = NULL; if (tp == (struct tty *) sc->sc_devp) { m_freem(sc->sc_outm); sc->sc_outm = NULL; m_freem(sc->sc_m); sc->sc_m = NULL; pppdealloc(sc); } d299 9 a307 1 splx(s); d311 1 a311 1 * Line specific (tty) read routine. d314 2 a315 106 pppread(tp, uio, flag) register struct tty *tp; struct uio *uio; int flag; { register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc; struct mbuf *m, *m0; register int s; int error = 0; if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) return 0; /* end of file */ if (sc == NULL || tp != (struct tty *) sc->sc_devp) return 0; s = splimp(); while (sc->sc_inq.ifq_head == NULL && tp->t_line == PPPDISC) { if (tp->t_state & TS_ASYNC || flag & IO_NDELAY) { splx(s); return (EWOULDBLOCK); } error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, ttyin, 0); if (error) { splx(s); return error; } } if (tp->t_line != PPPDISC) { splx(s); return (-1); } /* Pull place-holder byte out of canonical queue */ getc(&tp->t_canq); /* Get the packet from the input queue */ IF_DEQUEUE(&sc->sc_inq, m0); splx(s); for (m = m0; m && uio->uio_resid; m = m->m_next) if (error = uiomove(mtod(m, u_char *), m->m_len, uio)) break; m_freem(m0); return (error); } /* * Line specific (tty) write routine. */ int pppwrite(tp, uio, flag) register struct tty *tp; struct uio *uio; int flag; { register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc; struct mbuf *m, *m0, **mp; struct sockaddr dst; struct ppp_header *ph1, *ph2; int len, error; if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) return 0; /* wrote 0 bytes */ if (tp->t_line != PPPDISC) return (EINVAL); if (sc == NULL || tp != (struct tty *) sc->sc_devp) return EIO; if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HDRLEN || uio->uio_resid < PPP_HDRLEN) return (EMSGSIZE); for (mp = &m0; uio->uio_resid; mp = &m->m_next) { MGET(m, M_WAIT, MT_DATA); if ((*mp = m) == NULL) { m_freem(m0); return (ENOBUFS); } m->m_len = 0; if (uio->uio_resid >= MCLBYTES / 2) MCLGET(m, M_DONTWAIT); len = M_TRAILINGSPACE(m); if (len > uio->uio_resid) len = uio->uio_resid; if (error = uiomove(mtod(m, u_char *), len, uio)) { m_freem(m0); return (error); } m->m_len = len; } dst.sa_family = AF_UNSPEC; ph1 = (struct ppp_header *) &dst.sa_data; ph2 = mtod(m0, struct ppp_header *); *ph1 = *ph2; m0->m_data += PPP_HDRLEN; m0->m_len -= PPP_HDRLEN; return (pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0)); } /* * Line specific (tty) ioctl routine. * Provide a way to get the ppp unit number. * This discipline requires that tty device drivers call * the line specific l_ioctl routine from their ioctl routines. */ /* ARGSUSED */ int ppptioctl(tp, cmd, data, flag, p) struct tty *tp; d321 8 a328 5 register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc; int s, error, flags, mru; if (sc == NULL || tp != (struct tty *) sc->sc_devp) return -1; d347 6 a352 1 s = splimp(); a356 33 case PPPIOCSASYNCMAP: if (error = suser(p->p_ucred, &p->p_acflag)) return (error); sc->sc_asyncmap[0] = *(u_int32_t *)data; break; case PPPIOCGASYNCMAP: *(u_int32_t *)data = sc->sc_asyncmap[0]; break; case PPPIOCSRASYNCMAP: if (error = suser(p->p_ucred, &p->p_acflag)) return (error); sc->sc_rasyncmap = *(u_int32_t *)data; break; case PPPIOCGRASYNCMAP: *(u_int32_t *)data = sc->sc_rasyncmap; break; case PPPIOCSXASYNCMAP: if (error = suser(p->p_ucred, &p->p_acflag)) return (error); bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap)); sc->sc_asyncmap[1] = 0; /* mustn't escape 0x20 - 0x3f */ sc->sc_asyncmap[2] &= ~0x40000000; /* mustn't escape 0x5e */ sc->sc_asyncmap[3] |= 0x60000000; /* must escape 0x7d, 0x7e */ break; case PPPIOCGXASYNCMAP: bcopy(sc->sc_asyncmap, data, sizeof(sc->sc_asyncmap)); break; d361 1 a361 1 if (mru >= PPP_MRU && mru <= PPP_MAXMRU) { a362 2 pppgetm(sc); } d373 1 d375 1 d385 94 d486 1 a486 1 * FCS lookup table as calculated by genfcstab. d488 73 a560 34 static u_int16_t fcstab[256] = { 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; d562 5 a566 12 /* * Calculate a new FCS given the current FCS and the new data. */ static u_int16_t pppfcs(fcs, cp, len) register u_int fcs; register u_char *cp; register int len; { while (len--) fcs = PPP_FCS(fcs, *cp++); return (fcs); d587 1 d598 1 a598 3 address = PPP_ALLSTATIONS; control = PPP_UI; ifq = &ifp->if_snd; d602 2 d605 2 a606 5 if ((sc->sc_flags & SC_ENABLE_IP) == 0) { error = ENETDOWN; goto bad; } d608 2 a609 2 * If this is a TCP packet to or from an "interactive" port, * put the packet on the fastq instead. d611 3 a613 10 if ((ip = mtod(m0, struct ip *))->ip_p == IPPROTO_TCP) { register int32_t p = ntohl(((int32_t *)ip)[ip->ip_hl]); if (INTERACTIVE(p & 0xffff) || INTERACTIVE(p >> 16)) ifq = &sc->sc_fastq; } break; #endif #ifdef NS case AF_NS: protocol = PPP_XNS; d617 4 a620 4 ph = (struct ppp_header *) dst->sa_data; address = ph->ph_address; control = ph->ph_control; protocol = ntohs(ph->ph_protocol); d629 12 d663 1 a663 1 pppdumpm(m0, -1); d667 3 a669 1 /* See if bpf wants to look at the packet. */ d677 17 a693 7 s = splimp(); if (IF_QFULL(ifq)) { IF_DROP(ifq); splx(s); sc->sc_if.if_oerrors++; error = ENOBUFS; goto bad; a694 6 IF_ENQUEUE(ifq, m0); /* * Tell the device to send it out. */ (*sc->sc_start)(sc); d705 3 a707 2 * Grab another packet off a queue and apply VJ compression, * address/control and/or protocol compression if appropriate. d709 2 a710 2 struct mbuf * ppp_dequeue(sc) d713 3 a715 4 int s; struct mbuf *m, *mp; u_char *cp; int address, control, protocol; d717 8 a724 7 s = splimp(); IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) IF_DEQUEUE(&sc->sc_if.if_snd, m); splx(s); if (m == NULL) return NULL; d726 14 a739 8 /* * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. */ cp = mtod(m, u_char *); address = cp[0]; control = cp[1]; protocol = (cp[2] << 8) + cp[3]; d741 121 a861 9 switch (protocol) { #ifdef VJC case PPP_IP: /* * If the packet is a TCP/IP packet, see if we can compress it. */ if (sc->sc_flags & SC_COMP_TCP) { struct ip *ip; int type; d891 27 d919 1 d941 2 a942 1 return m; d945 1 d947 2 a948 2 * This gets called from pppoutput when a new packet is * put on a queue. d950 5 a954 3 static pppasyncstart(sc) register struct ppp_softc *sc; d956 3 a958 1 register struct tty *tp = (struct tty *) sc->sc_devp; d960 12 a971 17 pppstart(tp); } /* * Start output on async tty interface. Get another datagram * to send from the interface queue and start sending it. */ void pppstart(tp) register struct tty *tp; { register struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc; register struct mbuf *m; register int len; register u_char *start, *stop, *cp; int n, s, ndone, done; struct mbuf *m2; d973 2 a974 2 if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0) { /* sorry, I can't talk now */ d976 5 a980 3 } if (sc == NULL || tp != (struct tty *) sc->sc_devp) { (*tp->t_oproc)(tp); d984 9 a992 10 for (;;) { /* * If there is more in the output queue, just send it now. * We are being called in lieu of ttstart and must do what * it would. */ if (CCOUNT(&tp->t_outq) != 0 && tp->t_oproc != NULL) { (*tp->t_oproc)(tp); if (CCOUNT(&tp->t_outq) > PPP_HIWAT) return; d994 1 d996 26 a1021 23 /* * See if we have an existing packet partly sent. * If not, get a new packet and start sending it. * We take packets on the priority queue ahead of those * on the normal queue. */ m = sc->sc_outm; if (m == NULL) { /* * Get another packet to be sent */ m = ppp_dequeue(sc); if (m == NULL) return; /* * The extra PPP_FLAG will start up a new packet, and thus * will flush any accumulated garbage. We do this whenever * the line may have been idle for some time. */ if (CCOUNT(&tp->t_outq) == 0) { ++sc->sc_bytessent; (void) putc(PPP_FLAG, &tp->t_outq); a1022 3 /* Calculate the FCS for the first mbuf's worth. */ sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len); d1024 1 d1026 11 a1036 38 for (;;) { start = mtod(m, u_char *); len = m->m_len; stop = start + len; while (len > 0) { /* * Find out how many bytes in the string we can * handle without doing something special. */ for (cp = start; cp < stop; cp++) if (ESCAPE_P(*cp)) break; n = cp - start; if (n) { /* NetBSD (0.9 or later), 4.3-Reno or similar. */ ndone = n - b_to_q(start, n, &tp->t_outq); len -= ndone; start += ndone; sc->sc_bytessent += ndone; if (ndone < n) break; /* packet doesn't fit */ } /* * If there are characters left in the mbuf, * the first one must be special.. * Put it out in a different form. */ if (len) { if (putc(PPP_ESCAPE, &tp->t_outq)) break; if (putc(*start ^ PPP_TRANS, &tp->t_outq)) { (void) unputc(&tp->t_outq); break; } sc->sc_bytessent += 2; start++; len--; a1038 59 /* * If we didn't empty this mbuf, remember where we're up to. * If we emptied the last mbuf, try to add the FCS and closing * flag, and if we can't, leave sc_outm pointing to m, but with * m->m_len == 0, to remind us to output the FCS and flag later. */ done = len == 0; if (done && m->m_next == NULL) { u_char *p, *q; int c; u_char endseq[8]; /* * We may have to escape the bytes in the FCS. */ p = endseq; c = ~sc->sc_outfcs & 0xFF; if (ESCAPE_P(c)) { *p++ = PPP_ESCAPE; *p++ = c ^ PPP_TRANS; } else *p++ = c; c = (~sc->sc_outfcs >> 8) & 0xFF; if (ESCAPE_P(c)) { *p++ = PPP_ESCAPE; *p++ = c ^ PPP_TRANS; } else *p++ = c; *p++ = PPP_FLAG; /* * Try to output the FCS and flag. If the bytes * don't all fit, back out. */ for (q = endseq; q < p; ++q) if (putc(*q, &tp->t_outq)) { done = 0; for (; q > endseq; --q) unputc(&tp->t_outq); break; } } if (!done) { m->m_data = start; m->m_len = len; sc->sc_outm = m; if (tp->t_oproc != NULL) (*tp->t_oproc)(tp); return; /* can't do any more at the moment */ } /* Finished with this mbuf; free it and move on. */ MFREE(m, m2); if (m2 == NULL) break; m = m2; sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len); d1040 1 a1040 6 /* Finished a packet */ sc->sc_outm = NULL; sc->sc_bytessent++; /* account for closing flag */ sc->sc_if.if_opackets++; sc->sc_if.if_obytes = sc->sc_bytessent; d1045 1 a1045 1 * Allocate enough mbuf to handle current MRU. d1047 3 a1049 3 static int pppgetm(sc) register struct ppp_softc *sc; d1051 7 a1057 16 struct mbuf *m, **mp; int len; int s; s = splimp(); mp = &sc->sc_m; for (len = HDROFF + sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){ if ((m = *mp) == NULL) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) break; *mp = m; MCLGET(m, M_DONTWAIT); } len -= M_DATASIZE(m); mp = &m->m_next; a1058 2 splx(s); return len <= 0; d1060 1 d1066 20 a1085 4 * were omitted. The data in the first mbuf should start HDROFF * bytes from the beginning of the mbuf data storage area. * The return value is 1 if the packet was put on sc->sc_inq, * 0 otherwise. d1090 2 a1091 2 int ppppktin(sc, m) d1098 3 a1100 1 struct mbuf *mp; d1103 5 a1107 1 rv = 0; d1110 56 a1165 3 adrs = cp[0]; ctrl = cp[1]; proto = (cp[2] << 8) + cp[3]; d1172 11 d1186 7 a1192 2 if (proto == PPP_VJC_COMP || proto == PPP_VJC_UNCOMP) { char *pkttype = proto == PPP_VJC_COMP? "": "un"; d1194 1 a1194 1 if (sc->sc_flags & SC_REJ_COMP_TCP) { d1196 3 a1198 5 printf("ppp%d: %scomp pkt w/o compression; flags 0x%x\n", sc->sc_if.if_unit, pkttype, sc->sc_flags); m_freem(m); sc->sc_if.if_ierrors++; return 0; d1201 12 a1212 11 if (proto == PPP_VJC_COMP && m->m_data - M_DATASTART(m) < MAX_HDR) { /* * We don't have room in the mbuf to decompress this packet. * XXX For now we just drop the packet. */ if (sc->sc_flags & SC_DEBUG) printf("ppp%d: no room to VJ-decompress packet\n", sc->sc_if.if_unit); m_freem(m); sc->sc_if.if_ierrors++; return 0; d1214 23 d1238 7 a1244 6 m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; ilen -= PPP_HDRLEN; xlen = sl_uncompress_tcp_part((u_char **)(&m->m_data), m->m_len, ilen, COMPTYPE(proto), &sc->sc_comp); d1246 1 a1246 1 if (xlen == 0) { d1248 3 a1250 5 printf("ppp%d: sl_uncompress failed on type %scomp\n", sc->sc_if.if_unit, pkttype); m_freem(m); sc->sc_if.if_ierrors++; return 0; a1252 5 /* adjust the first mbuf by the decompressed amt */ xlen += PPP_HDRLEN; m->m_len += xlen - ilen; ilen = xlen; m->m_data -= PPP_HDRLEN; a1253 8 /* put the ppp header back in place */ if (cp != mtod(m, u_char *)) { cp = mtod(m, u_char *); cp[0] = adrs; cp[1] = ctrl; cp[2] = 0; } d1262 1 a1262 1 if (ilen <= MHLEN) { d1280 1 d1288 1 a1288 1 || (sc->sc_flags & SC_ENABLE_IP) == 0) { d1291 1 a1291 1 return 0; d1298 1 d1314 1 a1314 1 s = splimp(); d1317 1 d1319 1 a1319 2 printf("ppp%d: queue full\n", sc->sc_if.if_unit); sc->sc_if.if_ierrors++; d1321 3 a1323 5 m_freem(m); rv = 0; } else IF_ENQUEUE(inq, m); a1324 103 return rv; } /* * tty interface receiver interrupt. */ static unsigned paritytab[8] = { 0x96696996, 0x69969669, 0x69969669, 0x96696996, 0x69969669, 0x96696996, 0x96696996, 0x69969669 }; void pppinput(c, tp) int c; register struct tty *tp; { register struct ppp_softc *sc; struct mbuf *m; int ilen; tk_nin++; sc = (struct ppp_softc *) tp->t_sc; if (sc == NULL || tp != (struct tty *) sc->sc_devp) return; ++sc->sc_bytesrcvd; if (c & TTY_FE) { /* framing error or overrun on this char - abort packet */ if (sc->sc_flags & SC_DEBUG) printf("ppp%d: bad char %x\n", sc->sc_if.if_unit, c); goto flush; } c &= 0xff; if (c & 0x80) sc->sc_flags |= SC_RCV_B7_1; else sc->sc_flags |= SC_RCV_B7_0; if (paritytab[c >> 5] & (1 << (c & 0x1F))) sc->sc_flags |= SC_RCV_ODDP; else sc->sc_flags |= SC_RCV_EVNP; if (sc->sc_flags & SC_LOG_RAWIN) ppplogchar(sc, c); if (c == PPP_FLAG) { ilen = sc->sc_ilen; sc->sc_ilen = 0; sc->sc_if.if_ibytes = sc->sc_bytesrcvd; if (sc->sc_rawin_count > 0) ppplogchar(sc, -1); /* * If SC_ESCAPED is set, then we've seen the packet * abort sequence "}~". */ if (sc->sc_flags & (SC_FLUSH | SC_ESCAPED) || ilen > 0 && sc->sc_fcs != PPP_GOODFCS) { #ifdef VJC /* * If we've missed a packet, we must toss subsequent compressed * packets which don't have an explicit connection ID. */ sl_uncompress_tcp(NULL, 0, TYPE_ERROR, &sc->sc_comp); #endif if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){ if (sc->sc_flags & SC_DEBUG) printf("ppp%d: bad fcs %x\n", sc->sc_if.if_unit, sc->sc_fcs); sc->sc_if.if_ierrors++; } else sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED); return; } if (ilen < PPP_HDRLEN + PPP_FCSLEN) { if (ilen) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: too short (%d)\n", sc->sc_if.if_unit, ilen); sc->sc_if.if_ierrors++; } return; } /* * Remove FCS trailer. Somewhat painful... */ ilen -= 2; if (--sc->sc_mc->m_len == 0) { for (m = sc->sc_m; m->m_next != sc->sc_mc; m = m->m_next) ; sc->sc_mc = m; } sc->sc_mc->m_len--; /* excise this mbuf chain */ m = sc->sc_m; sc->sc_m = sc->sc_mc->m_next; sc->sc_mc->m_next = NULL; d1326 2 a1327 23 if (sc->sc_flags & SC_LOG_INPKT) { printf("ppp%d: got %d bytes\n", sc->sc_if.if_unit, ilen); pppdumpm(m, ilen); } if (ppppktin(sc, m)) { /* Put a placeholder byte in canq for ttselect()/ttnread(). */ putc(0, &tp->t_canq); ttwakeup(tp); } pppgetm(sc); return; } if (sc->sc_flags & SC_FLUSH) { if (sc->sc_flags & SC_LOG_FLUSH) ppplogchar(sc, c); return; } if (c < 0x20 && (sc->sc_rasyncmap & (1 << c))) return; a1328 94 if (sc->sc_flags & SC_ESCAPED) { sc->sc_flags &= ~SC_ESCAPED; c ^= PPP_TRANS; } else if (c == PPP_ESCAPE) { sc->sc_flags |= SC_ESCAPED; return; } /* * Initialize buffer on first octet received. * First octet could be address or protocol (when compressing * address/control). * Second octet is control. * Third octet is first or second (when compressing protocol) * octet of protocol. * Fourth octet is second octet of protocol. */ if (sc->sc_ilen == 0) { /* reset the first input mbuf */ if (sc->sc_m == NULL) { pppgetm(sc); if (sc->sc_m == NULL) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit); goto flush; } } m = sc->sc_m; m->m_len = 0; m->m_data = M_DATASTART(sc->sc_m); if (M_DATASIZE(sc->sc_m) >= HDROFF + PPP_HDRLEN) m->m_data += HDROFF; /* allow room for VJ decompression */ sc->sc_mc = m; sc->sc_mp = mtod(m, char *); sc->sc_fcs = PPP_INITFCS; if (c != PPP_ALLSTATIONS) { if (sc->sc_flags & SC_REJ_COMP_AC) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: garbage received: 0x%x (need 0xFF)\n", sc->sc_if.if_unit, c); goto flush; } *sc->sc_mp++ = PPP_ALLSTATIONS; *sc->sc_mp++ = PPP_UI; sc->sc_ilen += 2; m->m_len += 2; } } if (sc->sc_ilen == 1 && c != PPP_UI) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: missing UI (0x3), got 0x%x\n", sc->sc_if.if_unit, c); goto flush; } if (sc->sc_ilen == 2 && (c & 1) == 1) { /* a compressed protocol */ *sc->sc_mp++ = 0; sc->sc_ilen++; sc->sc_mc->m_len++; } if (sc->sc_ilen == 3 && (c & 1) == 0) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit, (sc->sc_mp[-1] << 8) + c); goto flush; } /* packet beyond configured mru? */ if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: packet too big\n", sc->sc_if.if_unit); goto flush; } /* is this mbuf full? */ m = sc->sc_mc; if (M_TRAILINGSPACE(m) <= 0) { if (m->m_next == NULL) { pppgetm(sc); if (m->m_next == NULL) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit); goto flush; } } sc->sc_mc = m = m->m_next; m->m_len = 0; m->m_data = M_DATASTART(m); sc->sc_mp = mtod(m, char *); } ++m->m_len; *sc->sc_mp++ = c; sc->sc_fcs = PPP_FCS(sc->sc_fcs, c); d1331 3 a1333 55 flush: if (!(sc->sc_flags & SC_FLUSH)) { sc->sc_if.if_ierrors++; sc->sc_flags |= SC_FLUSH; if (sc->sc_flags & SC_LOG_FLUSH) ppplogchar(sc, c); } } /* * Process an ioctl request to interface. */ pppioctl(ifp, cmd, data) register struct ifnet *ifp; u_long cmd; caddr_t data; { struct proc *p = curproc; /* XXX */ register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; register struct ifaddr *ifa = (struct ifaddr *)data; register struct ifreq *ifr = (struct ifreq *)data; int s = splimp(), error = 0; switch (cmd) { case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_RUNNING) == 0) ifp->if_flags &= ~IFF_UP; break; case SIOCSIFADDR: if (ifa->ifa_addr->sa_family != AF_INET) error = EAFNOSUPPORT; break; case SIOCSIFDSTADDR: if (ifa->ifa_addr->sa_family != AF_INET) error = EAFNOSUPPORT; break; case SIOCSIFMTU: if (error = suser(p->p_ucred, &p->p_acflag)) break; sc->sc_if.if_mtu = ifr->ifr_mtu; break; case SIOCGIFMTU: ifr->ifr_mtu = sc->sc_if.if_mtu; break; default: error = EINVAL; } splx(s); return (error); d1339 1 a1339 1 pppdumpm(m0, pktlen) a1340 1 int pktlen; d1347 1 a1347 1 for (m = m0; m && pktlen; m = m->m_next) { a1350 5 if (pktlen > 0) { if (l > pktlen) l = pktlen; pktlen -= l; } d1366 1 a1366 1 if (m && pktlen) a1370 39 static void ppplogchar(sc, c) struct ppp_softc *sc; int c; { if (c >= 0) sc->sc_rawin[sc->sc_rawin_count++] = c; if (sc->sc_rawin_count >= sizeof(sc->sc_rawin) || c < 0 && sc->sc_rawin_count > 0) { printf("ppp%d input: ", sc->sc_if.if_unit); pppdumpb(sc->sc_rawin, sc->sc_rawin_count); sc->sc_rawin_count = 0; } } static void pppdumpb(b, l) u_char *b; int l; { char buf[3*MAX_DUMP_BYTES+4]; char *bp = buf; static char digits[] = "0123456789abcdef"; while (l--) { if (bp >= buf + sizeof(buf) - 3) { *bp++ = '>'; break; } *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */ *bp++ = digits[*b++ & 0xf]; *bp++ = ' '; } *bp = 0; printf("%s\n", buf); } @ 1.20 log @be more careful with types, also pull in headers where necessary. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.19 1994/07/27 09:05:33 deraadt Exp $ */ d146 1 a146 1 static u_short pppfcs __P((u_short fcs, u_char *cp, int len)); d169 1 a169 1 static u_short interactive_ports[8] = { d490 1 a490 1 sc->sc_asyncmap[0] = *(u_int *)data; d494 1 a494 1 *(u_int *)data = sc->sc_asyncmap[0]; d500 1 a500 1 sc->sc_rasyncmap = *(u_int *)data; d504 1 a504 1 *(u_int *)data = sc->sc_rasyncmap; d557 1 a557 1 static u_short fcstab[256] = { d595 1 a595 1 static u_short d597 1 a597 1 register u_short fcs; d651 1 a651 1 register int p = ntohl(((int *)ip)[ip->ip_hl]); @ 1.19 log @bug 367. paulus says the fix is right & critical. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.18 1994/07/20 01:49:20 paulus Exp $ */ d137 1 a137 1 int ppptioctl __P((struct tty *tp, int cmd, caddr_t data, int flag, d142 1 a142 1 int pppioctl __P((struct ifnet *ifp, int cmd, caddr_t data)); d454 1 d456 1 a456 1 int cmd, flag; d1442 1 a1442 1 int cmd; @ 1.18 log @The ppp interface now retries the mbuf allocation when it receives a character and it doesn't already have enough space allocated. It still needs cluster mbufs to be able to decompress VJ-compressed packets. It drops packets if it can't allocate mbufs rather than taking the interface down. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.15 1994/07/03 06:44:03 deraadt Exp $ */ d1033 1 @ 1.17 log @Due to popular revulsion, the ppp interface now drops packets if @ text @d1349 8 a1357 5 if (m == NULL) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit); goto flush; } d1407 8 a1415 5 if (m == NULL) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit); goto flush; } @ 1.16 log @If we can't get mbuf clusters, take the ppp interface down instead of writing beyond the end of ordinary mbufs. @ text @d297 1 a297 4 if (pppgetm(sc) == 0) { sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); return (ENOBUFS); } d525 1 a525 6 if (pppgetm(sc) == 0) { error = ENOBUFS; sc->sc_mru = PPP_MRU; if (pppgetm(sc) == 0) sc->sc_if.if_flags &= ~IFF_UP; } d1019 1 a1019 1 int len = HDROFF + sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; d1023 8 a1030 29 for (mp = &sc->sc_m; (m = *mp) != NULL; mp = &m->m_next) if ((len -= M_DATASIZE(m)) <= 0) { splx(s); return (1); } for (;; mp = &m->m_next) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == 0) { if (sc->sc_m != NULL) { m_freem(sc->sc_m); sc->sc_m = NULL; } splx(s); printf("ppp%d: can't allocate mbuf\n", sc->sc_if.if_unit); return (0); } *mp = m; MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(sc->sc_m); sc->sc_m = NULL; splx(s); printf("ppp%d: can't allocate mbuf cluster\n", sc->sc_if.if_unit); return (0); } if ((len -= M_DATASIZE(m)) <= 0) { splx(s); return (1); d1032 1 d1034 2 d1083 14 d1112 1 d1317 1 a1317 3 if (!pppgetm(sc)) sc->sc_if.if_flags &= ~IFF_UP; d1350 5 d1356 3 a1358 1 m->m_data = M_DATASTART(sc->sc_m) + HDROFF; d1406 2 a1407 1 printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit); @ 1.15 log @bug #319. fix from @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.14 1994/06/29 06:36:16 cgd Exp $ */ d1040 4 a1043 2 m_freem(sc->sc_m); sc->sc_m = NULL; d1050 7 @ 1.15.2.1 log @update from trunk, to fix serious ppp lossage. @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.18 1994/07/20 01:49:20 paulus Exp $ */ d297 4 a300 1 pppgetm(sc); d528 6 a533 1 pppgetm(sc); d1027 1 a1027 1 int len; d1031 20 a1050 8 mp = &sc->sc_m; for (len = HDROFF + sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){ if ((m = *mp) == NULL) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) break; *mp = m; MCLGET(m, M_DONTWAIT); a1051 1 len -= M_DATASIZE(m); a1052 2 splx(s); return len <= 0; a1099 14 m_freem(m); sc->sc_if.if_ierrors++; return 0; } if (proto == PPP_VJC_COMP && m->m_data - M_DATASTART(m) < MAX_HDR) { /* * We don't have room in the mbuf to decompress this packet. * XXX For now we just drop the packet. */ if (sc->sc_flags & SC_DEBUG) printf("ppp%d: no room to VJ-decompress packet\n", sc->sc_if.if_unit); m_freem(m); a1114 1 m_freem(m); d1319 3 a1321 1 pppgetm(sc); a1352 8 if (sc->sc_m == NULL) { pppgetm(sc); if (sc->sc_m == NULL) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit); goto flush; } } d1355 1 a1355 3 m->m_data = M_DATASTART(sc->sc_m); if (M_DATASIZE(sc->sc_m) >= HDROFF + PPP_HDRLEN) m->m_data += HDROFF; /* allow room for VJ decompression */ d1401 4 a1404 7 if (m->m_next == NULL) { pppgetm(sc); if (m->m_next == NULL) { if (sc->sc_flags & SC_DEBUG) printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit); goto flush; } a1405 1 sc->sc_mc = m = m->m_next; @ 1.15.2.2 log @from trunk @ text @d1 1 a1 1 /* $NetBSD: if_ppp.c,v 1.19 1994/07/27 09:05:33 deraadt Exp $ */ a1032 1 mp = &m->m_next; @ 1.14 log @New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD' @ text @d1 1 a1 1 /* $NetBSD$ */ d426 1 @ 1.13 log @Some restructuring of the PPP packet input procedure to make it easier to implement PPP over sync lines and PPP compression protocols. @ text @d1 2 a73 1 /* $Id: if_ppp.c,v 1.7 1994/01/25 05:56:06 deraadt Exp paulus $ */ @ 1.12 log @some minor splx-type bug fixes from christos@@deshaw.com. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.11 1994/05/29 23:44:23 paulus Exp $ */ a146 1 static struct mbuf *ppp_btom __P((struct ppp_softc *sc)); d427 3 a429 1 len = min(M_TRAILINGSPACE(m), uio->uio_resid); d746 1 a746 1 struct mbuf *m; d767 1 d769 33 a801 29 /* * If the packet is a TCP/IP packet, see if we can compress it. */ if (protocol == PPP_IP && sc->sc_flags & SC_COMP_TCP) { struct ip *ip; int type; struct mbuf *mp; mp = m; ip = (struct ip *) (cp + PPP_HDRLEN); if (mp->m_len <= PPP_HDRLEN) { mp = mp->m_next; ip = mtod(mp, struct ip *); } /* this code assumes the IP/TCP header is in one non-shared mbuf */ if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, &sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; cp = mtod(m, u_char *); cp[0] = address; /* header has moved */ cp[1] = control; cp[2] = 0; break; a802 1 cp[3] = protocol; /* update protocol in PPP header */ a803 1 } a804 5 #ifdef BSD_COMP if (protocol < PPP_COMP && (sc->sc_flags & SC_BSD_COMP)) { slen = m_totallen(m0); clen = pf_bsd_comp(sc->sc_bsd_db, cbuf, proto, m0, slen); a805 1 #endif /* BSD_COMP */ a921 1 #ifndef RB_LEN a923 18 #else #ifdef NetBSD /* NetBSD with 2-byte ring buffer entries */ ndone = rb_cwrite(&tp->t_out, start, n); #else /* 386BSD, FreeBSD */ int cc, nleft; for (nleft = n; nleft > 0; nleft -= cc) { if ((cc = RB_CONTIGPUT(&tp->t_out)) == 0) break; cc = min (cc, nleft); bcopy((char *)start + n - nleft, tp->t_out.rb_tl, cc); tp->t_out.rb_tl = RB_ROLLOVER(&tp->t_out, tp->t_out.rb_tl + cc); } ndone = n - nleft; #endif /* NetBSD */ #endif /* RB_LEN */ a1053 52 * Copy mbuf chain. Would like to use m_copy(), but we need a real copy * of the data, not just copies of pointers to the data. */ static struct mbuf * ppp_btom(sc) struct ppp_softc *sc; { register struct mbuf *m, **mp; struct mbuf *top = sc->sc_m; /* * First check current mbuf. If we have more than a small mbuf, * return the whole cluster and set beginning of buffer to the * next mbuf. * Else, copy the current bytes into a small mbuf, attach the new * mbuf to the end of the chain and set beginning of buffer to the * current mbuf. */ if (sc->sc_mc->m_len > MHLEN) { sc->sc_m = sc->sc_mc->m_next; sc->sc_mc->m_next = NULL; } else { /* rather than waste a whole cluster on <= MHLEN bytes, alloc a small mbuf and copy to it */ MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) return (NULL); bcopy(mtod(sc->sc_mc, caddr_t), mtod(m, caddr_t), sc->sc_mc->m_len); m->m_len = sc->sc_mc->m_len; for (mp = ⊤ *mp != sc->sc_mc; mp = &(*mp)->m_next) ; *mp = m; sc->sc_m = sc->sc_mc; } /* * Try to allocate enough extra mbufs to handle the next packet. */ if (pppgetm(sc) == 0) { m_freem(top); if (pppgetm(sc) == 0) sc->sc_if.if_flags &= ~IFF_UP; return (NULL); } return (top); } /* d1055 4 a1058 1 * The caller has checked and removed the FCS. d1066 1 a1066 1 ppppktin(sc, m, ilen) a1068 1 int ilen; d1071 3 a1073 2 int s, xlen, proto, rv; struct ppp_header hdr; d1078 8 a1085 2 hdr = *mtod(m, struct ppp_header *); proto = ntohs(hdr.ph_protocol); d1125 7 a1131 2 hdr.ph_protocol = htons(PPP_IP); *mtod(m, struct ppp_header *) = hdr; d1135 12 a1146 4 /* get this packet as an mbuf chain */ if ((m = ppp_btom(sc)) == NULL) { sc->sc_if.if_ierrors++; return 0; d1301 1 d1303 2 d1311 1 a1311 1 if (ppppktin(sc, m, ilen)) { d1316 4 d1488 2 a1489 1 l = min(l, pktlen); @ 1.11 log @check for escaped char before checking for escape char so if peer escapes 0x5d we interpret it correctly @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.10 1994/05/24 02:33:56 cgd Exp $ */ d372 2 a373 1 if (error) d375 1 d1324 2 a1325 1 printf("ppp%d: bad fcs\n", sc->sc_if.if_unit); d1500 1 a1500 1 return (error); @ 1.10 log @MIN -> min, MAX -> max @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.9 1994/05/13 06:02:48 mycroft Exp $ */ a1369 4 if (c == PPP_ESCAPE) { sc->sc_flags |= SC_ESCAPED; return; } d1376 3 @ 1.9 log @Update to 4.4-Lite networking code, with a few local changes. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.8 1994/05/08 12:33:49 paulus Exp $ */ d426 1 a426 1 len = MIN(M_TRAILINGSPACE(m), uio->uio_resid); @ 1.8 log @Version from ppp-2.1 release; this version has been restructured to make more of the code usable with sync serial drivers @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.7 1994/01/25 05:56:06 deraadt Exp paulus $ */ d139 1 a139 1 struct sockaddr *dst)); d233 1 a233 1 sl_compress_init(&sc->sc_comp); d439 1 a439 1 return (pppoutput(&sc->sc_if, m0, &dst)); d540 1 a540 1 sl_compress_setup(&sc->sc_comp, *(int *)data); d613 1 a613 1 pppoutput(ifp, m0, dst) d617 1 @ 1.7 log @PPP_HEADER_LEN -> PPP_HDRLEN @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.6 1993/12/23 07:36:06 cgd Exp $ */ d91 1 a110 16 /* * Here we try to tell whether we are in a 386BSD kernel, or * in a NetBSD/Net-2/4.3-Reno kernel. */ #ifndef RB_LEN /* NetBSD, 4.3-Reno or similar */ #define CCOUNT(q) ((q)->c_cc) #else /* 386BSD, Jolitz-style ring buffers */ #define t_outq t_out #define t_rawq t_raw #define t_canq t_can #define CCOUNT(q) (RB_LEN(q)) #endif d112 1 a112 1 #include "slcompress.h" d121 1 a121 1 #include "if_ppp.h" d124 5 a129 6 int ppp_async_out_debug = 0; int ppp_async_in_debug = 0; int ppp_debug = 0; int ppp_raw_in_debug = -1; char ppp_rawin[32]; int ppp_rawin_count; d136 2 a137 1 int ppptioctl __P((struct tty *tp, int cmd, caddr_t data, int flag)); a139 1 void pppstart __P((struct tty *tp)); d142 1 d144 1 d146 1 a146 1 static int pppinit __P((struct ppp_softc *sc)); d150 1 d178 1 a178 2 #define ESCAPE_P(c) (((c) == PPP_FLAG) || ((c) == PPP_ESCAPE) || \ (c) < 0x20 && (sc->sc_asyncmap & (1 << (c)))) d209 59 a267 1 * Line specific open routine. d278 1 a278 2 register int nppp; int error, s; d283 5 a287 2 if (tp->t_line == PPPDISC) return (0); d289 1 a289 4 for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) if (sc->sc_ttyp == NULL) break; if (nppp >= NPPP) d292 6 a297 9 sc->sc_flags = 0; sc->sc_ilen = 0; sc->sc_asyncmap = 0xffffffff; sc->sc_rasyncmap = 0; sc->sc_mru = PPP_MRU; #ifdef VJC sl_compress_init(&sc->sc_comp); #endif if (pppinit(sc) == 0) { d301 10 a310 3 tp->t_sc = (caddr_t)sc; sc->sc_ttyp = tp; sc->sc_outm = NULL; a311 11 sc->sc_if.if_flags |= IFF_RUNNING; #ifdef PPP_OUTQ_SIZE /* N.B. this code is designed *only* for use in NetBSD */ s = spltty(); /* get rid of the default outq clist buffer */ clfree(&tp->t_outq); /* and get a new one, without quoting support, much larger */ clalloc(&tp->t_outq, PPP_OUTQ_SIZE, 0); splx (s); #endif /* PPP_OUTQ_SIZE */ a334 2 if_down(&sc->sc_if); sc->sc_ttyp = NULL; d336 6 a341 9 m_freem(sc->sc_outm); sc->sc_outm = NULL; m_freem(sc->sc_m); sc->sc_m = NULL; for (;;) { IF_DEQUEUE(&sc->sc_inq, m); if (m == NULL) break; m_freem(m); a342 15 for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) break; m_freem(m); } sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); #ifdef PPP_OUTQ_SIZE /* reinstall default clist-buffer for outq XXXX should really remember old value and restore that!! */ clfree(&tp->t_outq); clalloc(&tp->t_outq, 1024, 0); #endif /* PPP_OUTQ_SIZE */ d359 1 a359 1 int error; d361 4 a364 2 if ((tp->t_state & TS_CARR_ON)==0) return (EIO); d367 1 a367 1 if (tp->t_state & TS_ASYNC) { d409 2 a410 2 if ((tp->t_state & TS_CARR_ON)==0) return (EIO); d413 2 d450 1 a450 1 ppptioctl(tp, cmd, data, flag) d454 1 d456 1 a456 2 register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc; struct proc *p = curproc; /* XXX */ d459 3 a462 5 #if 0 /* this is handled (properly) by ttioctl */ case TIOCGETD: *(int *)data = sc->sc_if.if_unit; break; #endif d487 1 a487 1 sc->sc_asyncmap = *(u_int *)data; d491 1 a491 1 *(u_int *)data = sc->sc_asyncmap; d504 13 d523 1 a523 1 if (pppinit(sc) == 0) { d526 1 a526 1 if (pppinit(sc) == 0) d536 14 d626 1 a626 1 if (sc->sc_ttyp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 a630 4 if ((sc->sc_ttyp->t_state & TS_CARR_ON) == 0) { error = EHOSTUNREACH; goto bad; } d642 5 d652 1 a652 1 register int p = ((int *)ip)[ip->ip_hl]; d696 1 a696 1 if (ppp_async_out_debug) { d719 1 d721 1 a721 4 * The next statement used to be subject to: * if (CCOUNT(&sc->sc_ttyp->t_outq) == 0) * which was removed so that we don't hang up completely * if the serial transmitter loses an interrupt. d723 2 a724 1 pppstart(sc->sc_ttyp); d734 111 a844 3 * Start output on interface. Get another datagram * to send from the interface queue and map it to * the interface before starting output. d850 1 a850 1 register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc; d856 9 a864 2 int address, control, protocol; int compac, compprot, nb; a876 5 /* * This happens briefly when the line shuts down. */ if (sc == NULL) return; d886 4 a889 5 s = splimp(); IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) IF_DEQUEUE(&sc->sc_if.if_snd, m); splx(s); a893 62 * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. */ cp = mtod(m, u_char *); address = *cp++; control = *cp++; protocol = *cp++; protocol = (protocol << 8) + *cp++; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; #ifdef VJC /* * If the packet is a TCP/IP packet, see if we can compress it. */ if (protocol == PPP_IP && sc->sc_flags & SC_COMP_TCP) { struct ip *ip; int type; struct mbuf *mp; mp = m; if (mp->m_len <= 0) { mp = mp->m_next; cp = mtod(mp, u_char *); } ip = (struct ip *) cp; if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, &sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; break; } } } #endif /* * Compress the address/control and protocol, if possible. */ compac = sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS && control == PPP_UI && protocol != PPP_ALLSTATIONS && protocol != PPP_LCP; compprot = sc->sc_flags & SC_COMP_PROT && protocol < 0x100; nb = (compac ? 0 : 2) + (compprot ? 1 : 2); m->m_data -= nb; m->m_len += nb; cp = mtod(m, u_char *); if (!compac) { *cp++ = address; *cp++ = control; } if (!compprot) *cp++ = protocol >> 8; *cp++ = protocol; /* d1039 1 a1039 1 pppinit(sc) d1043 1 a1043 1 int len = HDROFF + sc->sc_mru + PPP_HDRLEN + PPP_FCS_LEN; d1113 1 a1113 1 if (pppinit(sc) == 0) { d1115 1 a1115 1 if (pppinit(sc) == 0) d1124 4 a1127 1 * tty interface receiver interrupt. d1132 129 d1268 1 a1268 3 struct ifqueue *inq; int s, ilen, xlen, proto; struct ppp_header hdr; d1271 2 a1272 2 sc = (struct ppp_softc *)tp->t_sc; if (sc == NULL) d1275 1 a1275 1 ++sc->sc_if.if_ibytes; d1279 1 a1279 1 if (ppp_debug) d1286 11 a1296 8 if (sc->sc_if.if_unit == ppp_raw_in_debug) { ppp_rawin[ppp_rawin_count++] = c; if (ppp_rawin_count >= sizeof(ppp_rawin)) { printf("raw ppp%d: ", ppp_raw_in_debug); pppdumpb(ppp_rawin, ppp_rawin_count); ppp_rawin_count = 0; } } d1301 1 d1303 8 a1310 1 if (sc->sc_flags & SC_FLUSH d1319 2 a1320 2 if ((sc->sc_flags & SC_FLUSH) == 0){ if (ppp_debug) d1324 1 a1324 1 sc->sc_flags &= ~SC_FLUSH; d1328 1 a1328 1 if (ilen < PPP_HDRLEN + PPP_FCS_LEN) { d1330 1 a1330 1 if (ppp_debug) a1347 1 sc->sc_if.if_ipackets++; d1350 1 a1350 1 if (ppp_async_in_debug) { d1355 2 a1356 87 hdr = *mtod(m, struct ppp_header *); proto = ntohs(hdr.ph_protocol); #ifdef VJC /* * See if we have a VJ-compressed packet to uncompress. */ if (proto == PPP_VJC_COMP || proto == PPP_VJC_UNCOMP) { char *pkttype = proto == PPP_VJC_COMP? "": "un"; if (sc->sc_flags & SC_REJ_COMP_TCP) { if (ppp_debug) printf("ppp%d: %scomp pkt w/o compression; flags 0x%x\n", sc->sc_if.if_unit, pkttype, sc->sc_flags); sc->sc_if.if_ierrors++; return; } m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; ilen -= PPP_HDRLEN; xlen = sl_uncompress_tcp_part((u_char **)(&m->m_data), m->m_len, ilen, COMPTYPE(proto), &sc->sc_comp); if (xlen == 0) { if (ppp_debug) printf("ppp%d: sl_uncompress failed on type %scomp\n", sc->sc_if.if_unit, pkttype); sc->sc_if.if_ierrors++; return; } /* adjust the first mbuf by the decompressed amt */ xlen += PPP_HDRLEN; m->m_len += xlen - ilen; ilen = xlen; m->m_data -= PPP_HDRLEN; proto = PPP_IP; #if NBPFILTER > 0 /* put the ppp header back in place */ hdr.ph_protocol = htons(PPP_IP); *mtod(m, struct ppp_header *) = hdr; #endif /* NBPFILTER */ } #endif /* VJC */ /* get this packet as an mbuf chain */ if ((m = ppp_btom(sc)) == NULL) { sc->sc_if.if_ierrors++; return; } m->m_pkthdr.len = ilen; m->m_pkthdr.rcvif = &sc->sc_if; #if NBPFILTER > 0 /* See if bpf wants to look at the packet. */ if (sc->sc_bpf) bpf_mtap(sc->sc_bpf, m); #endif switch (proto) { #ifdef INET case PPP_IP: /* * IP packet - take off the ppp header and pass it up to IP. */ if ((sc->sc_if.if_flags & IFF_UP) == 0) { /* interface is down - drop the packet. */ m_freem(m); sc->sc_if.if_ierrors++; return; } m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; schednetisr(NETISR_IP); inq = &ipintrq; break; #endif default: /* * Some other protocol - place on input queue for read(). * Put a placeholder byte in canq for ttselect()/ttnread(). */ a1358 2 inq = &sc->sc_inq; break; d1360 2 d1363 3 a1365 15 /* * Put the packet on the appropriate input queue. */ s = splimp(); if (IF_QFULL(inq)) { IF_DROP(inq); if (ppp_debug) printf("ppp%d: queue full\n", sc->sc_if.if_unit); sc->sc_if.if_ierrors++; sc->sc_if.if_iqdrops++; m_freem(m); } else IF_ENQUEUE(inq, m); splx(s); a1368 2 if (sc->sc_flags & SC_FLUSH) return; d1400 3 a1402 3 if (ppp_debug) printf("ppp%d: missing ALLSTATIONS, got 0x%x; flags %x\n", sc->sc_if.if_unit, c, sc->sc_flags); d1412 3 a1414 2 if (ppp_debug) printf("ppp%d: missing UI, got 0x%x\n", sc->sc_if.if_unit, c); d1418 1 a1418 1 /* RFC1331 says we have to accept a compressed protocol */ d1424 1 a1424 1 if (ppp_debug) d1431 2 a1432 2 if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCS_LEN) { if (ppp_debug) d1456 6 a1461 2 sc->sc_if.if_ierrors++; sc->sc_flags |= SC_FLUSH; d1519 1 a1519 1 char buf[2*MAX_DUMP_BYTES+4]; d1543 2 a1544 1 } d1554 15 d1573 1 a1573 1 char buf[2*MAX_DUMP_BYTES+4]; d1578 1 a1578 3 *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */ *bp++ = digits[*b++ & 0xf]; if (bp >= buf + sizeof(buf) - 2) { d1582 3 @ 1.6 log @include rather than -- if the latter exists at all, it's supposed to be included by @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.5 1993/12/18 00:40:54 mycroft Exp $ */ d209 1 a209 1 sc->sc_if.if_hdrlen = PPP_HEADER_LEN; d217 1 a217 1 bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HEADER_LEN); d395 2 a396 2 if (uio->uio_resid > sc->sc_if.if_mtu + PPP_HEADER_LEN || uio->uio_resid < PPP_HEADER_LEN) d417 2 a418 2 m0->m_data += PPP_HEADER_LEN; m0->m_len -= PPP_HEADER_LEN; d633 2 a634 2 if (M_LEADINGSPACE(m0) < PPP_HEADER_LEN) { m0 = m_prepend(m0, PPP_HEADER_LEN, M_DONTWAIT); d641 1 a641 1 m0->m_data -= PPP_HEADER_LEN; d648 1 a648 1 m0->m_len += PPP_HEADER_LEN; d748 2 a749 2 m->m_data += PPP_HEADER_LEN; m->m_len -= PPP_HEADER_LEN; d951 1 a951 1 int len = HDROFF + sc->sc_mru + PPP_HEADER_LEN + PPP_FCS_LEN; d1095 1 a1095 1 if (ilen < PPP_HEADER_LEN + PPP_FCS_LEN) { d1141 3 a1143 3 m->m_data += PPP_HEADER_LEN; m->m_len -= PPP_HEADER_LEN; ilen -= PPP_HEADER_LEN; d1157 1 a1157 1 xlen += PPP_HEADER_LEN; d1160 1 a1160 1 m->m_data -= PPP_HEADER_LEN; d1197 3 a1199 3 m->m_pkthdr.len -= PPP_HEADER_LEN; m->m_data += PPP_HEADER_LEN; m->m_len -= PPP_HEADER_LEN; d1297 1 a1297 1 if (++sc->sc_ilen > sc->sc_mru + PPP_HEADER_LEN + PPP_FCS_LEN) { @ 1.5 log @Canonicalize all #includes. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.4 1993/11/04 03:45:23 paulus Exp $ */ d137 1 a137 1 #include @ 1.4 log @Removed test (CCOUNT(&sc->sc_ttyp->t_outq) == 0) for whether to call pppstart or not: now we call pppstart for every packet, which should aid recovery from lost transmitter interrupts. Also a fix for 386BSD/FreeBSD which doesn't affect NetBSD. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.22 1993/08/31 23:20:40 paulus Exp paulus $ */ d80 17 a96 16 #include "param.h" #include "proc.h" #include "mbuf.h" #include "buf.h" #include "dkstat.h" #include "socket.h" #include "ioctl.h" #include "file.h" #include "tty.h" #include "kernel.h" #include "conf.h" #include "if.h" #include "if_types.h" #include "netisr.h" #include "route.h" d98 4 a101 4 #include "../netinet/in.h" #include "../netinet/in_systm.h" #include "../netinet/in_var.h" #include "../netinet/ip.h" d106 2 a107 2 #include "time.h" #include "bpf.h" d137 1 a137 1 #include "machine/mtpr.h" @ 1.3 log @Fixed bug in if_ppp.c so that received IP packets are passed correctly to BPF. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.22 1993/08/31 23:20:40 paulus Exp $ */ d672 7 a678 2 if (CCOUNT(&sc->sc_ttyp->t_outq) == 0) pppstart(sc->sc_ttyp); d833 1 a833 1 /* NetBSD, 0.8 or earlier */ d836 1 a836 1 /* 386BSD */ d842 1 a842 1 bcopy((char *)start, tp->t_out.rb_tl, cc); @ 1.3.2.1 log @Make all files using spl*() #include cpu.h. Changes from trunk. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.3 1993/09/02 12:10:59 paulus Exp $ */ a90 2 #include "machine/cpu.h" @ 1.3.2.2 log @Nuke references to machine/mtpr.h. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.3.2.1 1993/09/24 08:53:59 mycroft Exp $ */ d138 1 @ 1.3.2.3 log @Call pppstart() redundantly. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.3.2.2 1993/10/16 10:49:27 mycroft Exp $ */ a672 2 #if 0 /* don't hang forever if we lose an interrupt */ a673 1 #endif @ 1.3.2.4 log @Canonicalize all #includes. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.3.2.3 1993/10/27 01:42:19 mycroft Exp $ */ a74 1 #include "bpfilter.h" d76 1 d80 18 a97 17 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include d99 4 a102 4 #include #include #include #include d105 1 d107 2 a108 2 #include #include a110 2 #include d1433 3 @ 1.2 log @Modified if_ppp.c and if_ppp.h to add priority queueing for "interactive" traffic (done in a similar fashion to if_sl.c), and BPF support. @ text @d72 1 a72 1 /* $Id: if_ppp.c,v 1.21 1993/08/29 11:22:37 paulus Exp $ */ d1040 1 a1040 1 char *pkttype; d1117 2 a1118 8 proto = ntohs(mtod(m, struct ppp_header *)->ph_protocol); switch (proto) { #ifdef INET case PPP_IP: ilen -= PPP_HEADER_LEN; m->m_data += PPP_HEADER_LEN; m->m_len -= PPP_HEADER_LEN; break; d1121 5 a1125 20 case PPP_VJC_COMP: case PPP_VJC_UNCOMP: pkttype = proto == PPP_VJC_COMP? "": "un"; if (!(sc->sc_flags & SC_REJ_COMP_TCP)) { m->m_data += PPP_HEADER_LEN; m->m_len -= PPP_HEADER_LEN; ilen -= PPP_HEADER_LEN; xlen = sl_uncompress_tcp_part((u_char **)(&m->m_data), m->m_len, ilen, COMPTYPE(proto), &sc->sc_comp); if (xlen) { /* adjust the first mbuf by the decompressed amt */ m->m_len += xlen - ilen; ilen = xlen; proto = PPP_IP; break; } d1127 1 d1129 12 a1140 2 printf("ppp%d: sl_uncompress failed on type %scomp\n", sc->sc_if.if_unit, pkttype); d1142 1 a1142 1 } else { d1144 4 a1147 2 printf("ppp%d: %scomp pkt w/o compression; flags 0x%x\n", sc->sc_if.if_unit, pkttype, sc->sc_flags); d1149 13 a1161 7 if (ppp_debug) printf("ppp%d: packet rejected, protocol 0x%x\n", sc->sc_if.if_unit, proto); sc->sc_if.if_ierrors++; return; #endif #endif d1163 1 d1173 12 a1184 2 if (proto == PPP_IP) { /* IP packet - pass it up to IP */ d1191 3 d1196 2 d1199 5 a1203 3 } else { /* some other protocol - place on input queue for read() */ /* Put a placeholder byte in canq for ttselect()/ttnread() */ d1207 1 d1210 3 a1212 7 #if NBPFILTER > 0 /* See if bpf wants to look at the packet. */ if (sc->sc_bpf) bpf_mtap(sc->sc_bpf, m); #endif /* Put the packet on the appropriate input queue. */ @ 1.1 log @ppp from paul mackerras @ text @d67 3 a69 2 * from: if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp * $Id: $ d72 3 d103 6 d142 3 d176 18 d208 1 a208 1 sc->sc_if.if_hdrlen = sizeof(struct ppp_header); d213 1 d215 3 d243 10 a252 4 if (sc->sc_ttyp == NULL) { sc->sc_flags = 0; sc->sc_ilen = 0; sc->sc_asyncmap = 0xffffffff; d254 1 a254 1 sl_compress_init(&sc->sc_comp); d256 9 a264 9 if (pppinit(sc) == 0) { sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); return (ENOBUFS); } tp->t_sc = (caddr_t)sc; sc->sc_ttyp = tp; sc->sc_outm = NULL; ttyflush(tp, FREAD | FWRITE); sc->sc_if.if_flags |= IFF_RUNNING; d267 7 a273 7 /* N.B. this code is designed *only* for use in NetBSD */ s = spltty(); /* get rid of the default outq clist buffer */ clfree(&tp->t_outq); /* and get a new one, without quoting support, much larger */ clalloc(&tp->t_outq, PPP_OUTQ_SIZE, 0); splx (s); d276 1 a276 4 return (0); } return (ENXIO); d311 6 d394 2 a395 2 if (uio->uio_resid > sc->sc_if.if_mtu + sizeof (struct ppp_header) || uio->uio_resid < sizeof (struct ppp_header)) d416 2 a417 2 m0->m_data += sizeof (struct ppp_header); m0->m_len -= sizeof (struct ppp_header); d436 1 a436 1 int s, error; d459 1 a459 1 #define SC_MASK 0xffff d461 1 a461 2 sc->sc_flags = (sc->sc_flags & ~SC_MASK) | ((*(int *)data) & SC_MASK); d475 29 a572 1 struct mbuf *m, *m1; d574 5 a578 3 u_short protocol, fcs; u_char address, control, *cp; int s, error, compac, compprot; d595 1 d600 8 a607 15 #ifdef VJC if (sc->sc_flags & SC_COMP_TCP) { register struct ip *ip; if ((ip = mtod(m0, struct ip *))->ip_p == IPPROTO_TCP) { int type = sl_compress_tcp(m0, ip, &sc->sc_comp, 1); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; break; } } a608 1 #endif a626 4 compac = sc->sc_flags & SC_COMP_AC && address == PPP_ALLSTATIONS && control == PPP_UI && protocol != PPP_ALLSTATIONS && protocol != PPP_LCP; compprot = sc->sc_flags & SC_COMP_PROT && protocol < 0x100; d630 1 d632 2 a633 2 if (M_LEADINGSPACE(m0) < sizeof(struct ppp_header)) { m0 = m_prepend(m0, sizeof(struct ppp_header), M_DONTWAIT); d640 1 a640 1 m0->m_data -= (compac ? 0 : 2) + (compprot ? 1 : 2); d643 3 a645 9 if (!compac) { *cp++ = address; *cp++ = control; m0->m_len += 2; } if (!compprot) { *cp++ = protocol >> 8; m0->m_len++; } d647 1 a647 29 m0->m_len++; /* * Add PPP trailer. Compute one's complement of FCS over frame * and attach to mbuf chain least significant byte first. */ fcs = PPP_INITFCS; for (m = m0; m; m = m->m_next) { fcs = pppfcs(fcs, mtod(m, u_char *), m->m_len); m1 = m; } fcs ^= 0xffff; /* * If the last mbuf is a cluster, we can't just store the * FCS in it (other mbufs might point to the same cluster). */ if (M_TRAILINGSPACE(m1) < sizeof(short) || m1->m_flags & M_EXT) { MGET(m, M_DONTWAIT, MT_HEADER); if (m == 0) { error = ENOBUFS; goto bad; } m->m_next = NULL; m->m_len = 0; m1->m_next = m; m1 = m; } cp = mtod(m1, u_char *) + m1->m_len; a648 4 *cp++ = fcs & 0xff; *cp++ = fcs >> 8; m1->m_len += 2; d654 9 d664 2 a665 2 if (IF_QFULL(&ifp->if_snd)) { IF_DROP(&ifp->if_snd); d671 1 a671 1 IF_ENQUEUE(&ifp->if_snd, m0); d695 1 a695 1 int n, s, ndone; d697 2 d720 2 d726 3 a728 1 IF_DEQUEUE(&sc->sc_if.if_snd, m); d734 62 d804 3 d809 1 a809 1 do { d819 1 a819 2 if ((*cp == PPP_FLAG) || (*cp == PPP_ESCAPE) || (*cp < 0x20 && (sc->sc_asyncmap & (1 << *cp)))) d824 1 a824 1 /* NetBSD, 4.3-Reno or similar. */ d827 4 d842 1 d870 3 a872 3 * If we emptied the last mbuf, try to add the closing flag, * and if we can't, leave sc_outm pointing to m, but with * m->m_len == 0, to remind us to output the flag later. d874 38 a911 1 if (len > 0 || m->m_next == NULL && putc(PPP_FLAG, &tp->t_outq)) { d922 3 d926 2 a927 1 } while (m); d938 1 a938 1 * Allocate enough mbuf to handle current MTU. d945 1 a945 2 int len = HDROFF + MAX(sc->sc_if.if_mtu, PPP_MRU) + sizeof (struct ppp_header) + sizeof (u_short); d961 1 a961 1 printf("ppp%d: can't allocate mbuf\n", sc - ppp_softc); d1004 1 a1004 2 bcopy(mtod(sc->sc_mc, caddr_t), mtod(m, caddr_t), sc->sc_mc->m_len); d1049 1 a1049 1 if (c & TTY_FE) d1051 2 d1054 1 d1057 10 d1082 1 a1082 1 printf("ppp: bad fcs\n"); d1089 1 a1089 1 if (ilen < sizeof (struct ppp_header) + 2) { d1092 1 a1092 1 printf("ppp: too short (%d)\n", ilen); d1113 1 a1113 1 printf("ppp%d: got %d bytes\n", sc - ppp_softc, ilen); d1121 3 a1123 3 ilen -= sizeof (struct ppp_header); m->m_data += sizeof (struct ppp_header); m->m_len -= sizeof (struct ppp_header); d1130 1 a1130 1 if (sc->sc_flags & SC_COMP_TCP) { d1132 3 a1134 3 m->m_data += sizeof (struct ppp_header); m->m_len -= sizeof (struct ppp_header); ilen -= sizeof(struct ppp_header); d1158 2 a1159 1 printf("ppp: packet rejected, protocol 0x%x\n", proto); d1193 7 d1204 1 a1204 1 printf("ppp: queue full\n"); d1214 1 d1221 2 d1247 1 a1247 1 if ((sc->sc_flags & SC_COMP_AC) == 0) { d1249 2 a1250 2 printf("ppp: missing ALLSTATIONS, got 0x%x; flags %x\n", c, sc->sc_flags); d1261 1 a1261 1 printf("ppp: missing UI, got 0x%x\n", c); d1265 1 a1265 6 if ((sc->sc_flags & SC_COMP_PROT) == 0) { if (ppp_debug) printf("ppp: compressed protocol %x, but compression off\n", c); goto flush; } d1272 2 a1273 1 printf("ppp: bad protocol %x\n", c); d1277 2 a1278 3 /* packet beyond configured mtu? */ if (++sc->sc_ilen > MAX(sc->sc_if.if_mtu, PPP_MRU) + sizeof (struct ppp_header) + sizeof (u_short)) { d1280 1 a1280 1 printf("ppp: packet too big\n"); d1289 1 a1289 1 printf("ppp%d: too few input mbufs!\n"); a1341 2 if (pppinit(sc) == 0) error = ENOBUFS; @