Subversion Repositories ALCASAR

Rev

Rev 2057 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2057 Rev 2483
1
‹nËÉVì=ù{ÚƶùýâW/Á[ã<ڋ'¼Ú˜kp›Ü$µ…4=‰jñÒ4ÿû=giXÄâ­yß_?GË̙³ÍÙfFµ‡¡îÒ°çx7z)_*¼x‚ß&üöövØ¿ðÿ—]K»»¥­í­íÝ›E¸Ú|Av^<Ã/
1
ipt-netflow-2.2/0000755000000000000000000000000013213006644012322 5ustar  rootrootipt-netflow-2.2/Makefile.in0000644000000000000000000000671013213006644014373 0ustar  rootroot# Edit Makefile.in and run ./configure
2
BÃ'ä…ïyá¬vóÞÿýÙcòo´:z³Þ9<:ùM?näw#ÿÝÝíùoo•öö¤ü·K[ 'ŝMP²ù]þOþÓu2)rM{FjõÃF³Ñiœ4Ûd¿LêoMhvÜ:9í´5¿ã“ÚÙQ]oÔêÍN£ó!GNþ§^í蝭zŽT½È
©¿»cßÑ%Ý*åHž^R/E¼¤x1ôí€Zæðô䘴›Ç­ë’Þ>n°þöÛӓ³VN]=9n5*Íj}´Sõ¤yÈz‰Œ€ZƒÝmÑò]µyv¬wª¬Y§þ¾sV9Â~¿"1'Í©ÙÁÐ1îÚ¡o»—pk„´âZ{@GÇêTßhLª&ŸSÈ»1Æ°!Ž*íŽ~ÖªU:õɖ6‹Û›¯‹%œÿÎrOßVšWpt’­Tùc@©SÂÍÃ-“­DaßóWB†íì£k#$!uè•7Èû‘¦eŽÕ $×ÔlÏ%Aߋ‹t)ñº¡a»Ô"=ßh™~ƒýBÁ7nò—v؏ºQ@}ÓŽ¹aÞôÀƒQ°sŠÍÈjÛZ½]=…·@ ÛéÓq]#í
2
 
3
®q	¨xÝÿ¥fBïy>¡ÎEcrE}—:dàY‘Csä¦o›}b¤o_öµÌúЀ˜”ç¹Fë°ñž}HEhG¶Ýæ!UoxçC·¬™ëyOþ{‚q?aË#Û¤n@÷ÉÛ֑ é´þk£
ôd¤ÐŠŠÐzI¶áÚ¡m8ħ×6r>/ àôù¢j8ÙÚÛÞÛ%¯)Â䫦Á´ìxCrD¯h]W4ê„s(ÃgáZuبŸ
3
KVERSION = @KVERSION@
4
À£º‡À’'íÐí ´ÍE»—FºW=WryÁþ[‚4R‚· E@©ó„Éu¨‚»À
4
KDIR = @KDIR@
5
™J©’Ë^.´$Ð=æø íªš4&Ëö˜Žï3#ƁÃÊ{½R­ÖÛíŒO
K÷\çŽ÷èT:gíŒù>¨À”YÂ9Ap¸|VQ˜q^q=‘³úk{½ðÆðilI¼	aJó)9WÆØÀ7Ÿ]’=°]ÿ»¶LkÏ`æ=WÅ<S1,ŽH,«‡ö<áo#Š>í™n˜†`ìY	½(MºwÄ>úÒ ƒ=Û1¯N#|NÊnlf‰=ÓsR	ivêoaÖ~Ñ2bŽï¬í¬çâ»×k¯ñÎöìÛµâæ:ëûu*Õ7¾ÒÅÔ½%±’
5
KINSTDIR = $(shell dirname @KDIR@)
6
´¶“#¯s`¡Ë̳¬§,d³³oýÀþ“.&¢3°Ú™l72¯hdJÀ;œ„FøÏp€	€øÄ4Ì>=›¯ã–wX{ÖãÁ¸·YÇØažtú¶¸F§‰Å|zÍk£‡A—¸‡A›Õ4¼æ̋¥(@ü‘Ôƒi«0y‘kÉæȄMy°i?
Äò40C¸V7ê-7'îï¶Çf„굃³C6+f£»‹èZ=ÛÃù­%°¬ß=?$ê°CÇpÆÙèî1
¿¼ôéåó¡[QƋñf#ú#Sc0tÀ‘<’m1V‚à>aãl	è~|gc`ªœ×2¿Ÿ£¢Ý¥ËÚA?ûÃTbtŽø†kyƒA[?›ê×H5Hbz7ðv– ù¶Ö6Ñ¿Q—ßÉÁ5cL֚õ£u‚™žï9Œ	*d+_™ÿ؁ù·Ôxô
óê^Ô¹uu¢–ày4³yÜÒm×¢·$U
6
KOPTS = @KOPTS@
7
>“sÐåAµi¸:hãý¢À%Z”›2÷K’Α|*éÐñBÃY$#U ¹3<°ÃSPãâ	I+úÄ®…7!Ù®…€‚ÖXãn†i3ï—Î.FtTá“!X >°nœ8ÎIXË@W5—6QF›¤gÈú?)Ibˆ…¨*qªg„“#š&¢©‘åC(ñºXzˆ$ט:Sk4édl©Â¹7!‚qIŠ @Ê$Oš^&0rQP–ï
‡ÊËTòD„y€ÁÖ}‰›©=i0h‰ùŸN3í[jÕìëâæ&³$“U]>f£Ý:ª|Ð߁Ÿ"YK/e°‡$Ë “¡áBŽ„7„¦=€Á…UæWNP–
7
IPTABLES_CFLAGS = @IPTABLES_CFLAGS@
8
SpæLÎ*H?
8
IPTABLES_MODULES = @IPTABLES_MODULES@
9
©D>KþÔ)Üöãô0O Ðq‰7‘Q Ö2FÉIè‘b~K®ÐÈõ\]6¼±ëÈX‚uîˆÑõ®äbº`veV|Lžw?Ûöˆ*öλ!ƒÈìc1¤P6†–L1»w¬f¤°*•²=IÙ|—JØ#Z8Ž…xÂñi`[<¼#‰@ü
9
DEPMOD = /sbin/depmod -a
10
b
!c‰}GÃtB”„.bçù§Ç!Vb´õ¦;Âג…
áœØâñôõ@ÁÇ “Gïè¾=‡&ƒé»`&2GÀß3i0Ãüó@»~[®,va£ŽS^"q÷2O
10
CARGS = @CARGS@
11
+âÀp…‚è…Bß-AØ·&Æf!c}Þ`¦ç[³d´-HùöfVLŽTBðØ¢N‚àä*ÔéÍ nGÑÀogzŔq•»]»|á'øÆ4(1L“
hɚkß	.Æ!¶h?8ñŠÑ2Ċ(Fo+{êûžˆR:«Õò|?&uNdA,ܹfß÷\/B¼Y3»pµžCÏÐ8Aƒ×ռݓ¼ý泧tžæ'mʙÎU!,¶3Ëü(iÿÆýÑ£ÎB)©‹Ð=Q§z¸A@2Qù—
11
SNMPTGSO = /usr/lib/snmp/dlmod/snmp_NETFLOW.so
12
Íõßp՞Q¹ØL–,ZÔ¸Z‚ˆ§Þ[Çë¢Ö·ö ˆ©6BÌsŽkž´qs?¬eþˆ(´s¨{ögÐ+·Ÿ´ÀcW[g`;ã¢ÛhÙ®:Œ:,H©<¶ëÿ:«7«urrHj¯ºúwãåH°B:9Ð5`.Xð¥¾>ŠbZI2¡W¢&ÐI-Ÿ>	â5±ëÉpq&œ<jŸd® ¨Ñ¬Õßg¾s5X­øëT:c‘0!NâŽ8†R6_4¡mpF–ësꋤ)#¯™EȌíðéšö–ÙéïÞÅõ’ŒRQԒ¼e*€šÿ§¾­ƒMò#×Ì$›G^úÆeÚ»Šãx©Å¢yfÔ€8bÙͫԓµÍ|~{óõîúwìðáØÆpù0~ÊôˆÕ£ã9·þœ™H,2sŠÎËcŸZhfÞgQ¢J1Q³¢ºÌÇ;s7Ãâ„ðaeá¹c¾5&ŽåpO	”–Å^-ñGÖKUžGÀvLÀ¬Àg:ú3–üGž{ÖïÌßÍ+ÛfÒ+¶Kïü[ V»
»‚†ÚÜ
12
SNMPCONF = /etc/snmp/snmpd.conf
13
ϳ(ЌbÇ2Tí)Tý­Z>{Œ¹ËX¥ÒÍ¡â¡»ø²lCÍû¥<–Áúu‚5zȧFÇP÷¡XóB§â¼Ÿïq•‰¸X]0¾Ì/ròyøüçlÊ{jäð|/^—â,ÐfŸZsÉ()©E[$+iÙ¾¿GzÝ3¿ˆ“ª%RŒ­Ñ#Fi~Žñ¨ØÏO2beHó¬4#‘ÍXž‘ššhÄ°'2
|SK6½n³Qñ
”ÓºÃü¨z®KÍp2<ï#ÇI}YÅb@êÛÜ÷<ým›åÜãÉQòæІQSßb]a$žÆŠC,ƒû§÷њúẌ́Ø3½DÞE‰sí1vK.n¦tM.xWÝ:)³NÍ\:J’±Kwþž6Bäž\¾«q7s[ÛâVºÐÑe)ڒ%“ã©}G‚2XŸ0¤ƒ!ߌæÉ;û²/*VQ'Ä`Ðpµ+h»4¼ñü+\Ǫtê
1H„xعËðùüü¶ÀãÔÒ2]
13
SNMPLINE = dlmod netflow $(SNMPTGSO)
14
±UûFÃ7v´%HËpaÒ°ê6®{'‡áìK XsÙ¹­°mÉSóRøÉ%ª—2X
14
CC = gcc
15
@ÎFŠêŸ–á<†V¡ç‘`
撶£j
15
 
16
Z§¦­¢¬6€ §‹;7 R¨KÈöçB›Ueòû´‡{7V8gµ–£Šb‘èÚ6H£zÜ€žl	æògWáóOΐ9?l3ô¸
OaÎ<Ì÷$æí™[倫t%_£r•Œw)X4	@"‹±1D—¸Ü5€©öNˬÅuüuÜ#ÛëA2ލü œ/²G	G7üÜÄW¨
hµÙÒq²e,”p±€Y÷Ìó}Xa¼>§eØR¯ù>»s"Â嘀/Çy&žËŽ×£ì˜±žñdìxA²çÛ&îñÀáQöLaÊY3Ú;¦e(²} 8B‚<Ɂõ6
˜òcá³}¸£ÚÆãËsã—M‘›(g\Iƒ_2³2¶öáá™l´È¾eæèÜ·àŠ†Ë‚_ˆq™r^YUJÝÊ8
TV9Ò/$Þ¬U:'§ø™û6†>ãçü59õ9ß>ùœ/6M>‡\q
16
# https://www.kernel.org/doc/Documentation/kbuild/modules.txt
17
{ªÄS“ü‰"¶POÃmä³Êw5xâÆÇýà*9¯
17
# https://www.kernel.org/doc/Documentation/kbuild/makefiles.txt
18
7ò8h]»T™·WT'NQB®ãX+œ›‰µ<bxÉÜ.å‘J¸=/†Œu'	³¢e”È»&G{°?Cƒç.åÉ>º`@äÁ	¼§–àÒi| !>ʓá¬ùQï™<›Š–Íäa|Ž€q'Yú`·‡‚¥ñ¶cvÍJ€9Î~^Žo°Æ#nd_e»¤¸“ý•ÝwâN¾Q6xñ;	,ÙU”´
18
obj-m = ipt_NETFLOW.o
19
˜†qeŸ…¸“­äb|,utKHI©s„Œ½³µzkb¹u¾8äêBN\Ž$YÈ}ßJBGŠ÷ü¾6Âlµ†Ìoe-6¾Ãúc|Ã*‡ñ¬Ã-ÁºÉõټ۞¬#ÍgÞXžãOx6+n’D0y€©Œò£ÿä–»â¶-MŨ·y°¤J-Sf¬a©J½YÓ^|ÿ=î÷Ÿ¬«A‡tª÷ÈßÿJÿþÓææviüûOÛÅííïßzŽ_«Rý¥ò¶~Þ¬×ˊ2hÃ(è[ä²}ö哕ƒJûÝyûäì´Z¿Ðd¯_ë§ø1œòE¾ B¥|пІÞÐÒÎGsB2ð7?—•Oúh`â÷G'Uö©#lSàŸ–(Ð[ˆßµv>v=í¸òƒ’WTý<PþÊËj­Óú9Z+góTaû—Su¿o¤£bëø´¼ÂáŸ^ä›ô(Ìj•³ÎI£	–êè¨|Gíÿíü·]˜ŽÃز|Žïÿí”JÛãßۂ×ßçÿ3ü^½,tm·Ð…PI{Å÷¦ocÅÖ¡†ËŽ–èB)ââ«z¤öËqlJó˜ƒÎ»ò
19
ccflags-y = @KOPTS@
20
þÝGhû…(𓋀]ñ=®~:ì›ùH²+Å,)ÃDÅóŠ|¤Ïo°º‡é5ûɞÉ7XêÇùÌÆÏç!L Î(4@L€àâ½µCRÔz6Ãê¥øÄÎòSÁ¢×k°¥Ÿ~(Ž~I>x±<w5$}ãšrÖ$/¬¨ÁΗ± ftœ0’NIìv'О=6oÊJ¸òi#eŒã­á	y˜µ¶aˆfW¾üs¿ô5û†$‘­Ùʸûù3ùáЇ0ò]²‰-\úFÞW &«•Ü+\)îRâ@(‡•!Ìã8vrTk¶ËÙø›Õðreõ“»J*åµÆrŒ£€üE ’ß3u±®ñ®FVÓØ·âò•ÿü̱6üY^[±q溼òåϏÅÏ_Åõõå’Ë}¼d"—,@×Y„VЄD pý€¼FÀ[¤_qåË+Ödù¤ò‰_‘4ÎI¾š‚2,šÝ%|ÉsLñZÊ,«Õ¦	:fåûVbzN€Wô)×÷)-kn¤Oš
ø E¶ŸñþÈwu k!UÃe‹2=Ûµ¸Zƒ/fªhã¡Ú¾®dè€DÈ
µ}K`σ9“2T!oD¡‡e;sê¨\:ôÝ ٜ­/$t²ÓŸ±=ÌeG „ý(È¡0£ÇvFøø_S<yMn<߷łÂ³'†n49òIöÂ_׳èQæ¼fsBÿ—´tþ‚\$æêB!:î¨ëq[)4‰Ñ)bÛUf‰òll6W$A!Q?	‚ÕuÀY“:M‘ËteŽçÑó(‘40¬»? ºßKKpN(K2;/ñÙ9ˆœÐ&ó3`§jFfæÄ4™ì3{ò)SO€jo
¨ä( 3HÔtɸöl‹ÙxÇ6ў«Šu\{û÷cañçJóvtyI\ïÂõ‚DWÙ¸¬ol@…Åæ3‡ðçdšØ\"h'ÝÜl'7ÕÆ­ßjÌïLð4©Š	e˜H"¶-‰V–EôJѯIW¢´ò3ÃI‚VBˆ¸éX0!s6ښ6¸BS§ç54‡Øh#ÿÑì&ǐõlÓz¥¶Á”cƒØþð6èÃ=ÌWÐä$Å/¼*¼cÃøüé<ÀÐÃ3ós&fXÓâ¹äø÷¢ÎߘÿŁå³}ÿ}»¸WÏÿ¶K;¥ïùß3æý= ‹c›l˜g+>ã—
¾ê4’ånL±ñ_×vVƒÂÇß˟7ò…Âêkø
20
 
21
?gâ¦üÔúW€}ØV/´ƒ=?
ælmeYYF†²ÁHÄAØ~"]'8ªîâÀ¿W+§oÛàg>­å7>­>ÃÕ¸û…è‡ß÷FÜñ;âå"{È(BÞ¼Ñh`˜ìŒ£çc&‡>¸„ú‹:>Ý'+Ÿ\%+ãU}Ü?œƒù<Q„èÍ>Ö
yQ«Ó>­þŠ,M:9À=[íSóŠå²” ”ì`”%°‚¤++‡Ñ1ӑÃ0HV„&ÝÈv¬xÏöˆ€µ.«ü´Ð+Gõöù§õO?cþ‘ì®þ\@~ò1.⠑:ä™{åz7®štȁِ"$`½Êœ7ìz2žÄ6dÍ»ZŸz³þüžÛægü}Wl°á
0×Ï>®Ë?"¼&Æ\%ˆð’†çŽÝÅò¡*9ÆRÐmH”*§òçðä¼Ö8%Y®nY¡oØá"¡ZÒc#,|¡ÒÓ569„ô×Ex,rtêÇ*¤ ŽÝ΁>=ǖíɄ `4šqú
ÈC—üüËåòPt9_—Å.¶ïºÒB-Æp†¶·By¹aRx™ß€¹‡|þôOëù—ŸŠ/‡«Šn¾gô¨Ónœ7Øâé8“à¼YŽ[±]±]Sp*¶
9—åaÿžc\ÜL„qE®Y:±ø+²†ÿO©i÷lj­+9Ä쿼˜—¼_™½DØÓ`¯.uwŒÂkžH+8¢ȅŒƒ¬Y´g@b6:õãá…	´gG^ê
Iù4ì”é¥Lÿ˜Ó<ïR¹-ò¡öÇy=¡cú0•×‚°„åPb=‹_‹ÇcàÇØ®'D±ndœy…Ø8÷³jAp‘®·K÷=
21
all: ipt_NETFLOW.ko libipt_NETFLOW.so libip6t_NETFLOW.so @SNMPTARGET@
22
컬®áÌî*Ú¼&p1¥‰p¦R—ÊÜ‘‹<ÀßØa«Ì7r6	¸b@sÅ'ÄE‘•b¬{SD~èE®5éÊ
ȇŠ±®¢/_)εKé•øm암®Ê+ÌüF_'J#þ͊!ÉîÉañb„‰aÊ9hÚ9×´Ñ Ôó·ÊiS¸(k±¼ž•èhj>µPþöžµ¹ãÈÏÀ¯A,„°‹II¤¡&!EDdeƒK`I"ÂË»€HÆñSÊ©+Ÿ_ì$uu_î'ܸO×ÝóؙÙHɎ>¤D«`¦»çÝÓÝÓÓáæqàFÞ5¥çҝPšh O8ˆêT>.Y}ŒÍR‹gˆ%¿Å9À©ñÍI2<k9à0Õ¹õ9Ï¡k¢nRû^-Ù7 ‘è$©
22
 
23
±J`ÌãÞL<#wÚUÉWxÏØ,DòæhZ‹Ž8ÃɞÑÅh{–ÈÑ ÆiSÀq€›JyMîîZ‹O,֘Ð0Ñe*Û¨ì炤ªpbOΓ¤¾LÅ0v«.‘†K¸€T£}§7MA„G6˜M»¸ÄÄ#…Œ==¨í¶Õ¯Ãön¢Ò€?®8ñÆ+O\×½I ÒU‘ŝBÛ»ÕÌP¡‡8ÀábÁ"2<+F&&ˆùı¸iÃNßåï±n·þ9¾HUßéîÕk; ‹t»é»Ràùt%÷8Ã÷q{€}Þë1§'~³*Ãæ3i|ó§S]ù:£Ÿ †ã‹ö%è
23
ipt_NETFLOW.ko: version.h ipt_NETFLOW.c ipt_NETFLOW.h compat.h Makefile
24
Ôn+¦|4'[ŠŒ˜s&‹¤IÄ\¶!] ….1˜§8lIžá¿íRê¿|o\5ë4LœwQ®-Rë…ʘQŒåõh BU"$”­û•ßÅÆFΒ—Ò{]uȊjŸÍ¼ÄüUùQ'§8±æ„eå]à
24
	@echo Compiling for kernel $(KVERSION)
25
P1"¦€eªà	ª†ô°”uý¶ËWŸ…Ø#@")@Ò~À7^0@˜êÕøÊ-~ÿjh›Ë&»÷Ué•[¹§­®Ä£¹A˜dˆôo|#º!?öB6ªƒe±‘ßeMÿÒŒó™H¸âw¾“˜à4¤Ã‘àwö„5€~8ùL\Oӈòš…Þ$ðZÖGüêš „7Í O D
25
	make -C $(KDIR) M=$(CURDIR) modules CONFIG_DEBUG_INFO=y
26
¡6ª
Ô.¡åc‰f®ÜÓ·9³C½d§q,ëŜej‘‡ú¯ðOö3ÿ¡Ê&ìL‰à¦N¥
26
	@touch $@
27
Ýùœ—A”§*ž~'‘b¤$Œ©ƒ.|̯á‘à’À†buFª#1çZl|Ðìª8‰”‚tÈ
27
sparse: | version.h ipt_NETFLOW.c ipt_NETFLOW.h compat.h Makefile
28
þ¬Sètà¥à•¸ØﰌõûÙû{‡PY8MÑ·eÎïÛlÚÀòÀ˃zœÓ-X!+ŠÖ80‹µñ–ú“QËÀïìqŸ[Ԗ×ÒzU÷dN‚´3:I¬ü¶?žMÂ[Wþz>J¬¸?\Áâ˜ÚXaLX)ùª¾‘°½˜¡’¶xS„|Zÿz¦°!fT$—0¤˜Ú/ü€iX‚õ7	®¹Ä†¸„#5‘¨™ۊ„•WD--ÌM:Æoû؁R’"«£ÐÙä|Uº•[X±º hÜ¡ږ3Õ¥Ë` ¸Û€é‡{ˁËì„âYøÔèµé9×5u\ÿ̱Tąî Ö(DÔG×â‹Ef¨w5ßYğy'Bžb]³bSùýf-—C…5IËäé1cÒ*U-)¡¶”Ëî…?œê:`¦%/mŠSŒÍèŸi²=Þ1}€eý+w“•Ü5·¼GEÊDš°P¼ǑթÂJØSH)ZâáMþnï{NO›8΢Š¡ED«˜0~…dýÒ«pþ•ß“ƝJœù/ª˜ÜK4’b ,R¯eßx±Îìâ²»áVŠN8ëg<s¼á¬´nӀ:HfuE£›ÔÂá™-þ捽D“tÌG1J
çS-qµj4\íà鲍–Heäõ¼~?ÀàK•ÃÚ6“É$«?âϨ&’x3„«þ$‰çµ&kôoÏû«©ããIôŽÌÉn”VY}èc äÎ;™uÀûA¬-^tZ†W¥ÈZ
28
	@rm -f ipt_NETFLOW.ko ipt_NETFLOW.o
29
žÌY‰húãZšžº¸Çå3IfU§ú£Eø”‰+²¨R¨ººï÷¼i8"Ï=l´)„« ³œDµ)H8I¥<5k²¡w
29
	@echo Compiling for kernel $(KVERSION)
30
[œ2¢³Jò¼^\‡(ùXm©\ZÔåʙÀäÀRéX–J ï™×³;P<Åg¾wŽþ‰¸C±jüå0ÊIÆ$ÿÕ}“Ü‚ÄR#ÁvèÏüáõbÊ·öŽ-Nçxy	·‘)&‘Co&ro‚‚Λ«™•'òZõz]¾9¤ÉáJœ£«TqžÕÈUs«ÚÎÕ!º¦;]ÏùCÍù·¢óèË\OÕñœÉ4x"?¾^V´Úq›þªÈd$íhàpübî;ŽŸP/‚CöÍá¸ÕnnNžè$A¾äؾԟ’)ÇG8î¶ÐXTrÄÍ	xÿš ô	ÚZ½‰ŠT·YëÄq€ÿ.ÃFÇA†KµOÆAÎG".X qõí¹Ò٘ÄsÈ!b·kÀ@øuvè[£¹ÛÝ«µ÷Ѻ‰NYë’&×vwˆãQï
30
	make -C $(KDIR) M=$(CURDIR) modules C=1
31
°ÖñÑa£
[ªsÅDÐ-&¾v‘ÅâoüìîÔ[è%󍚛NåÛxsi^RqÜ®*ÎY¤˜x‹p[{/Û;õçщÃ.îkÞ=znt¸Éd©KÚûVTï7	&¹..C6(‚‘fú	­FxÁk•sáw£%Ã;&o1ÎD9\á<œû…ŽY(œ+žç¼ I?Ö<Yë”ßÿèÀ\WÒ¼Êˉª4Æo¼á /zP6»Üj3¢Ü¬v<€ÒƦ3Ոçj—2+æäC/奼pìê Òn¨ÍXƒH:>™Øhˆ&9î,›ûâí#ÌdVõ€-å
QZ»ŽêMGkÝáûë9÷H&ѶO|úþ=ZQžGDUŒ 2ŽŒ’Ð¥»øžEâÙ QPQhyzS‹[–}Ö,ß_2X:ÏаhÐо"®"&œ#îィ²‘Ie_¹>ëz´q/€Ý»ë渡ë+`ŒUyóGë$¢yü—º%¤;,)2ìUö˜¯\òšqܜð\2ˆs›Õ>lü‡G;UiÊ
31
	@touch ipt_NETFLOW.ko
32
Ntó	•J9V±:4uµl.lPº;5UzZqó¨òö3vL é€À
^B9s¥mÎČjÕÃø›ñOäx	#Jzbd¹Ù>²šI!:(<cö
32
coverity:
33
y£t³·]D9*ÃÎbP¯œ^y`y’zyjÅq3 ÑÒۄCÜÝl‹¸1Û$Y_ð¥8•i0˜ƒÙuÔ^Ž,j…=‰x‰À³“ÍӸāÉڜк2CCDA)
33
	coverity-submit -v
34
+bê2‹Èhò&Àr4f›Þ4Úù•³Qr¾„’v	Íà¾CÞSo<èEÖwiu7¬ú“Èè!llÂ"âRD¾7<IMˆSáffŠSjY^§(dg¼Kå肺Ý2ÚðÅ:›çÒTò8gÀzÜn0!Ý蘰%ðE•hlSû2C»Ñþ­îrWÑZÅ7Þ£UïpÐqÓ1ŸÛŽ†HÏn8÷°¨½¦^à«6F¾ÏÆä2X„?î][ò6l[g5ÀËè(ôXvĹԞz§Ê½•ºÄÜa/¼ŸUéY~̪¨ˆ­’…e…X~¨i
Ei–ãñø™ÎKÍ쭝•aè5‹&ݡӗ*ç1ŠX¿(NgN "ͧª¾2ö¦kc×ð\…&´Æ_âÁ;¿ä4NG"¢–ÚQEºuìÍ·j_0ñ‚+&—v^#’P$5Ûª˜[žæ8iläçnµÉæGl	D/N”!Ä\6ŠiÒÂݕ¿µòp®Žûx ±[5Z)ýÝ$È|µRªf€^°òåÄå@ÇuîôBówÌíÃF¬Š úxîóæJ'
”¥hy’kƒ@ÖàÓB9f°ˆ…VT¢ ¬cî“C a’(k¹œqd/µÈ˜µ“ùŒ_¼åJ“03ÂR*G–a¨W7BV'16s‰:_ã­é¶_¶·;©T*ÃãŠEÆÇLt¥íîÓ6#S^
34
 
35
Ú|Šöžn³^ߩé'÷f縶½ß­ã£ÄíåÖó
¬r£õf#1{iJ'Tf0ÝDh©ðg™X‰%`û..v+YŽbûtP–/ý(¬”=£Òq‹ÆJÙ¼ÐÍׯ㛞VÉsáÌ÷@JR~ÚI Ïú¸ŒUbøxèÎ^íy½{pÐhwn‡y„~oŽn„¾{Ü®o?;nt^v÷èÈp<šr"¢FhAéԎw띪ø%ãÑD"®´´hb®q)È<––&±WkÇÝ­ü›lÑ»í$ó$a¸3VV0½ñDÝf¿¡¾Üo̳[¸T
¦#Øó¾žð¦×׊b|—äU¬íìT3ýÉ&3$9‰1}¢6iNaŠÊŠøõ‰~–ÿ—í&}ëê\uIQQ­EÇf`SZPs½l.…
oëGCÝÙI‘VÉü¸¡Smé’Ƚ_¯‚â%öÏïR»Þ±Â“ú!è};ž‹Y±Å†Zl%Ë^^^ºò*DÂÓШ¶C#1Ÿ™‰“.-¬„Ö'Ph’¿)çqçz’öÌŪ¬]—â^`¡ª"҆´2è-•Xè«X<v£°î8Ï'S<&–:§kŠ¢$NùUGơ̂@¯\Å$½nfíyj|›xºŒHN,6Š±AîÖ
ƒû£õ#™ßs£J2¿7¶i‚@2Í[0’
…éDzåw$V3KtN~JOm]LúZЬü„¨Ì#»Ð˜4Ì8,x4M®†*²Æ¾*-hͧç×÷3çÀŽÞT’]µ« v|&±Ø_ã'¸¬ÂÂfÁåeVoÕÐØrÜ:„éqîÓñ|8 *›Ù®ßɟpqë¿Õ—‰Éùô¹Þ—‹BÍyý²µ>ïi”o
•_î^lGáÁ\ìðFk˜Å3å|¬B˜ðGåîñp„<éªÕ6®ˆ}º4¬ÍïK¿+nØsBßvešöHĒqì܌-þêG©»ROK£)7y’î+-÷ʂ!âžìÔ¥‰.K&`qÓ0…veƒ‚°ömrA±ÛzÌ$”¤Î%‹õétäŽúY£IíÎ
35
minstall: | ipt_NETFLOW.ko
36
Bf•¬“tòõ­Ô]îd°àîEê®°»D2PF¶°¸£,‘•(ñºê.µ€3CáŸÊïœC!vU@¿H5¼2c_=¥¼R¬)Ú“NƒÞPÛ®W3¯Òá't`úä?8½³EirD!Y~•90R˜
36
	@echo " *"
37
2u/LÂO‘m‚ýÐrłÙâ—È×äk¿D¾íõ@¼ƒì|î­Î³ùw&ü“mHvT€BßÝɈ(?´­¢h‚ïªx2–Y™‰2cöXýJóe‹§».QLKW¢ÆÉPäëNFQpiß@þk.ÅCèŒ"М\2L‰Ýçç̃ƒ¼_Ü;þËhÀ¿Š{ñÇYÿ·ô TŽÅÿ-ŒÿùAþ
37
	make -C $(KDIR) M=$(CURDIR) modules_install INSTALL_MOD_PATH=$(DESTDIR)
38
9vHCŽ¾•<;õB¾©]ÌfÓp³óĬóÉäf:HdPnFèòìbµ9†daµétèŸ^»,W.4£Ø{Ý®7¼ô®‘y
ñnÞ|0žUÊݳa¥œE>?‹R¯òŒ§@ÂC„ZMƒo-ÐÙVöŠ}ú)$Á¦_?fÙJ™9°ºEƔJ<
® ÄÀ?Ǎ%ˆ2.¨öU•] ÙÒÆþÌUYñêáºÚó6N·€JÐ+Ÿ–=¿²¾£ j}¡Wή“Xh¢(à[îµ-{AÁ
ýq,-B5·Ò{%Fë=òËýõÒV L¥Ó‡*ë*q€ÜépÒ{8¹™7RËb]ˆeb… W%¾¦Šè)ƒ­t:ʼnC–=ø¹Uh:€£“´šØÚࡇ*I©Ý,¦¨éýû,íγÒú*~+oq@wyÌ[g÷¡íþÆúÚÆéÆÀ}›Na³Ìú@ks«ªBПaKÎb}>a^r•©lb+¡>Hâ‹ò—8AiðyvÙÈ.QöC•[2r‹_b†Ù<Ȏµë[5³Ä„¾(}…=ÅÁoÿ+ð.»Â7Ν¢8òøÿڃ
;þ3n	ùÿøK‹˜Ï¨äúܝ´zˆ‹Î}_9—Ë×·€ããé½x‘ú,ÝdGxépÀ§ƒA2³ˆÛ}B/•Ä&â9Ry˜ªá±¬@1Æáaݕ Èú>®P Ó¬~åñÚòöHjîûáÃ!‹:n¢
38
	$(DEPMOD)
39
¥îÇ85Ö:®=Yp—9ÜùÀ0vûÈï™IO@9Âo†”7
39
mclean:
40
°8
40
	make -C $(KDIR) M=$(CURDIR) clean
41
ƒé›5øì+Óù̝û®tãgåbñ¡S|à”ÖX±´¹^Ú,?rå»Ev¿¸V,¦ï“º¦Eþm°ÒÚf±¼YڈÑ{ò„9•ó¥2»Ÿìɓ´$΂yì/úËÁǖʚæ	ìҎH‚í_<:¦r¢+.Ý)ÈÓKÀ$u"l/ð¦Šð'Òb@Cüž?xƒFžþ„ìkBkòÆÞðš^bt5´‚úšl6|}ê<ž¾žug×SŸU«_¨wºG½úñÞQ»³¡Š¿ó	ÐƊm¥ÕÌF«Ÿiw?ÛË6Züëaã3È8®o×ÏëíU즏åãVöú´^x/ìsð;ÏvŸ¶ºµÎÑac{ukÖ|vp€{Á¿^üG¼×«½«Ðûòÿz±h¿ÿ±^Ú¨|äÿFþOÃòD—´‡SŸÇàS@#Ô§ÞiïÉÌú¯'#7˜?†4þ#Eà.Bž¼îPà÷¦O/R1õ€£ŒQo¢£9¼bž¡ëJ89›]Â
41
lclean:
42
ܤ=£1c`üµÓùŒ^sõÆývpvÍ))+(²'`d£¿”ë³Ýæ3¶ëýÀ²ÖütØÁ çyP8¦€:ƒQ·9%ÄyŠõh‹z0
42
	-rm -f *.so *_sh.o
43
ÏÄßSbþ€^äTŽY²A]â8™,pDò{àz>º]3¼³¥wCÔÚ¾|¶ûb2õ›U†H2Ôç9<yÑèìÁ.Çj͗ìEíø¸Öì¼Ü¢C ôª@ÇÎêñjІÖÞxvM›8Ò8¬oïRí³ÆA£óíÇOf½ÝfOŽl£µãNcûÙA혵ž·ŽÚu—±¶OÁ¤9‰%Ý}Fcª6sÙhšÈ*+ö‘>ó@œ˜^ß<”œŒ7œÀ$£3¯™Ö¥.Y_(þŠ3Ÿ¢nª-ž¨çx˜|È„…Ç¢R ÈFcÂY0q/IÐNëc0@#
ÖL3öÿ3÷:,ˆ'QmØÁÍt/˜zÌÁä›àœA6q4*¦óÈ(+Šé€ycXgi‹Ž´Æu·vê©B:À.Ý5·¤êsx´SZ+ªŸ‘m•˜ŠÚǯŒd»@+……‘Û,
,®+ÎďW¢ë㫟’Þ•ù[JeW•+«ieD½ßhuºõfçøe*…½™Ñh¥dòà½£ÐÌÛ­4v›
43
clean: mclean lclean
44
P¥¤RŸ«<Þ!M^—ÜŠ{•Pt$ŠfÙµÐS½³d¥ŒñÕëfdØAQQŒ8«€ð‹/AÀÂãÎo¾·ú햂%ûÝ ÇodÛàat³sz5ܚf<ñ}#‹ßzyÖٍårü&O¹¼

+>çÜmÆrꆞkÇãÒþµ.d9ê9™o÷¨œ¾¹ÿ‚¯{®¦5{UI¯"µ
zЇY£&Tl°…Ìjƒqi^š‚ֈŽÈQo&Ð"ð
Tù§Æjç#?ôGÊ¡ˆ¨±ôex|ß/rÇþ,0.Yçñ·7òñ·$šÁDytRÍEÌ¥’£¿j´˜²ÅUÀPzáïd' ú	~ÁšY”Bß0IH^Ê'Z
44
	-rm -f *.so *.o modules.order version.h
45
á`opüF5ƒ±¤ü‚	ô´^
45
 
46
EUñ+­¹
46
snmp_NETFLOW.so: snmp_NETFLOW.c
47
A/hŒ¡}s&Ăn7Ëûv€VªM£#— 
9!EëÉbZÙOÄÐ`}„ÿ1þ¿mÿë
47
	$(CC) -fPIC -shared -o $@ $< -lnetsnmp
48
OŠðë¹ïÿÁßxo{à
ú_¹¼¾nêåR±òà£þ÷aìíÀŸŸ¡+4ÌÜ¥ˆ{À´ùH³P½&szÍZÞp9ê'o6Óé£1è1ó<`õXùAž•‹¥2†°->Ø\Ûج[‡Ü~•·PÙe0™ù›éÇéÇì‡_Þþý‡ïÿƒýåíOÿxû#ûîǟÙ_ßþý¾ÿéßßZµa?÷Ë[Êüó_”©
48
 
49
(À¿^ôü²ýrœkòkD/>-—®.àIL˜ê#ïÜ'ƒ]¥ì¬;Þ¨¿±Æi+SžÈ-hdÄ­„å4àß%»è®UÀ‰uó²>.δÄ>e·ÿß·?üøö»ÿþ¯·ÐAԉì»?ÿéûŸz]-nx^k^³ÿ{û×üíÄù۟þó—þ汆8ï…1'˜O›ñNI²qÚ@ª	МB†iŽ]B:U.9¥²S¬°âÙaK†Ý´dÛao[…Nc§ðë¬ôh³TÙ\3-¼ei‘}XÉ?d÷ù$ì9í½7Y!…¯»§sè±ÙEâ8ÍR¿Ê
49
sinstall: | snmp_NETFLOW.so IPT-NETFLOW-MIB.my
50
ËRïhE„BÚIÝÖæšJifÖû |ÝAuT†ÿ¥­î³ÖN·uha%v¡çñs5ÏLsmžQIü”ëãvýOßÿÿŸ½?]l#GEáûWz
50
	@echo " *"
51
XÕ¶I™¢Dj)[²]EK´ÍSÚZ¤ki—OE&¥l‘L63)[Söyƒï­îƒÝX°f"IÊåîé3ßÔL[L @D^4Zö7­cÑùïîNfý¯moïíþÏúÿ¯øÓ°ys~,nëÔ…E—ìÒ)*?'fû}´@þFç¶ßêÔö›œÙ.wb»ú-NkÿüYíŸ>©½ç9íê·9£ýV'´««íèj¼Ãb:ñu¶×¿ñû€pú8‡á4y¬ø³itEçˆä™ôÕZ×áME—¢ÁÒ°"ÏÀ*¦èý{Ø2[¢Gˆî¨fª¥Ô-o„nAñٓΊ1éuŒwæSZÚñš4iœg w·äñ
51
	install -D IPT-NETFLOW-MIB.my $(DESTDIR)/usr/share/snmp/mibs/IPT-NETFLOW-MIB.my
52
u.6(»¦wµÉìr¥îdÖŒ•º94ýKÇ3}jfF¼–9@G/=4B»Øîk6¡7¿ámÏzdI­«póC`â$•µ 	óÀÀMð’Øè¡ç!DCTÂüïNðñ4¢¾6KC5Ÿ±ñÙf«–¨*8Ó˜,‘‘ÄO$U°åhUYžiÖÏé|‰‚† bõ-‰>O‹Òl<D߈-ÑÉÂÀT@Q*3y²ýV<]‰Ô›nbHX~˜z¬ýyõµßZŽ
52
	install -D snmp_NETFLOW.so $(DESTDIR)$(SNMPTGSO)
53
ÔBبÛlHKbjµäU#À¤â4µê•íÎG}‘;ѐ–ÒÜ/õËDÍB}*Õ½š†RÈÙSƒòÒíÚËqÈ¢»'¡ lWy!”“×ir‰/$hBJ7ïª]]´I5bNj-ÕùÄ@ØFM¤¼(ŸJ4£nDញ7è -B÷D™|c¯_ôVž-Ó¹‰Æi{\89KI¢ãá-F•]]=Ÿ}Ñ÷Ü3øSÞzK4š´)/·W‡¹ÛWñžlE`{²ûðÆ#ØøE—Ñ0JqÕºÄgØä͍8Ù^E£4ÈÇ*¥D¿WõábŸcÄ¢‡¼,ÓW2—ËfÔHmZÂmSÙc"ŠM§,7;a"hè`¡M¸½­á]W4oa)¸ÅfÖ¶>`j2‰þP›„æ闪xÓŽÉ{iÓ¤Øq4»ìÞFÿïÿ?L~ë
53
	@if ! egrep -qs "^ *$(SNMPLINE)" $(SNMPCONF); then \
54
ú¼1Œí
54
	echo " *"; \
55
ÃðSx'Βh"Ók”Îç¯â!p%×5xW>Á_ËÜmʝ¡ë„+!¹î*9álÖ<š¢=·L^]%#(~oo¯aÿD[,BÙgÜI?w‡øä~,~®ŠßºãY{íq3’|—§;¶=º¢\Ôf@ð"¥
J0loTÒêj“ý8£L9ì"‰º¨‘Œ©» ”\φÑMÙjuñQÔ½‰ÇН?VþÛlA7ÄC€ŸÝÌlŒûÓ=»ÞB[ÌíÐó·îÍuwJõþÒøõ®Çñ0¾ŠBæ‚]&ñ¶‹´5û³.H “~ÒíEáßÅßúá¥J]]-µCèÒñz֘p„ê¹ÁGhڊ[í~_-—ô‚¼üoÐ6ÿÅÈ75ÿ_°ÿÛÞÞÍÙî@ÿÙÿý‹ìÿi;Câ÷2á”tzZ,Œ.í¾à¢C*˜e}´º@ýC.W¢ç,B´È}GFÆâ6¬ïÁJ“*ÞÕ¾]"Úæ"µx±,$4î.ö¶^U|™vxvrNN9è*1x«ïÕr¦Ìiëü¯ïG«ß		+Jè»,~_])™‹\¾t.?¢¼÷[*sókòëòAº*›Iì[M,>	d¿+¥ €aç¸4OZÓ2:¦”my»t[¶ÿ$­‹Ú
55
	echo " *  Add this line to $(SNMPCONF) to enable IPT-NETFLOW-MIB:"; \
56
ïwü ֐ýªõ¦˜fk`ØdEd"×¢O d6/ïÒÔÊpZ½^C`ì0´wÍt2ŠÇ=³tZ§ïš†ìTñ«/Îåõö§ÔcÌ"ŽþWÇpF<?5/N›Ç*µT¯ìUê»åÕÙÕÚñ @#Ÿ{Áe¸]_Y‰&öÇÞû|D îÚÇ¿í´=•¸w€WÍÙFãbPœßŒÙH6£4I§°#¥¤;ÑeÈ,D`€南x§ŸüºÞØ)[£pÚ¢	[úTŸ”Ù’/Õy<VF#™LS›·Áyðt«^³'¸º²õééÓÆS<™‡„j­Ûípzb†Ü{˜†‹ÿµuú×Z'%Êgµ­-DÙaÍ[ô¿Fã¿”ùbu,V¿w±m,¶½ XŽëÏ/Î:gÁÉ[›çUÚJm{7kXåøRbá³ì˜n×í¹ýªùúì¢YßÛ®—>Uî``+wr~ãŒeÃ2¾¯áö”SÓ|µ–—/²ÄlWjßW¶lb`WÈø<ut‚‹Ÿ%oιQ0Ž¶°É£ºï„Ø®<crU%´ä×<Kãiv{×<ñM‘'y©²AÒ„þò”¥ÌÑÔèlWŸU·fœƒ¼Ô­Lâ¤Ò«ôËþ*3—§Ô`¬„å•y`’c~üœ6µØÓ)ÀZƒú#*‹ÒôT¤Ùöܔpp„Äw%U>_¾RÈكª¦Ý»£sX¬š¢¶½—£8Fa%›=ö6‡?Ï()‡Ü
”djEtËYB•'ÀbôN¶ÆΕúÐ߃Ñk;Ìé÷èÅÚ3{&O¦°ŒG>|Áð¿òFN)ËòÔ6Zþ¹]×½—‡	FÝOŠ3ÉÙÇ¡€0Q´pLcç=,¤–K Tíí”í%|+ÈÐø€Ð¸+Ë9#ÐÆqüg8Í€Ú©ÀòâÙD,í¸„Çdû ø„Ï%?•œœ;̹Ü;•CŠñÊÚ¥@R™Ò>AÔ	©Pd•¿nîlWê8:–9h„éuÇÃÇ\FˆJÔ%<*SýVòuø«ïáU™Þ¨/ÖáêîF»Ý¼èÓãR_°âì€>ö_*øx’l¼´+*¯®¨aÚhžŸžuÚïÎϱ0è@Tä±Gÿ‰}—¯_5¯Àߍ—HÌ\Ö;ggÇÁ›v³c^ϧ¢DmCdX^ }o	$‹º¶c ¦3Àÿ6^ÒWŽÅço/Ž‚ó·g 4NòÊÊÓúVA^pÞ:oB~-+•$T«Ùl¢¦¶»“C`²Vžní|]ÓëVÓõ2œC–
56
	echo " *"; \
57
I	~Uj Ëè÷~xz€¿èNd={øµ:o!	ålV©_ÎêÄ÷(,Ó¿ªÏ¶w-‚ß6
57
	echo " *     $(SNMPLINE)"; \
58
^7ZÇ+[ÙÔ³ŸVjY-øfëôçƱ§ÔÖ"ºòÊ]Ž°YJ·)0ògŽ{ɉfp|vØ8Z§¨äÐÃÍ]G¿a ó‹f ߕ®`
58
	echo " *"; \
59
ñ®I˂+œ+X¥d!A±½âÈÊ?F¨-ƒRr´žµ;yb­Ä¯x\r¡‡Ðt
59
	fi
60
£!蛟ù|¤‡}f¢ÃÆx6ÎØ"ká¬wÍÚäÜ5Û“Tv’ȱ€ö°u " sž<AIì«®ôˆÿ¾>t´ÖÿÖ´áp:•Š)¥7¨˜§Â&¹ŒÐlXàfA øgŸ—©H¼„¥¶ ’’jCTÎ`ørÿiªZT$ÉnãÙ(À`4“îU˜¬¤qÚN»„ŸB¸ð¦ó†Ì4ðïmwˆÌ—Mã“Lv?ÅÞÎ%Ÿ(EÒ¶ë˜Ö›ÌAÅG˜Wû-N)öL"Ɖ…º"ýêIßÐü´ ‰Í‰Q
˜Á»?»¼|ƒ‘ìíސPXñ¬S¤è#Ô´8°XIz‹<–ÞVÓ[Xû{P.Mäï•>ãŒR‚?âq—%b›¢¶µµ…x$ Ò/Fz8ô4Ël]•Û©Kèa%²d
60
	@if killall -0 snmpd >/dev/null 2>&1; then \
61
üÍv7ÈΎm	`
˖TMû×Å	ìŃóæEÅauÁ¦x§òÈi£Eš—^ɶ¸È÷Wt±«Î™ï¥[,ÓE³b½+ê"ê’lÌ/y_§Yíe[ϯ“f(£ºC°y¬í•fµ=AӍ]ãLø¥‘
W‚É‹¤8€¢]C@_b½<q%{qU°iÂ-Ö²U¸UžG-_ÕÞnؖ®
61
	  echo " *  (snmpd needs restart for changes to take effect.)"; \
62
À­ª  ªjQÇ¿(P(ћâuÌ~ñNÿëì¢ì¬Ïë0É?´`€ÝjtÛMCµÒóîõÞ2I8ö䞈u؄ð1z”‡Ûj~MQÉ63R#Ê
£†_(…$2ö¢’^‰±n²7.rTúdX•c<KIžõÈ97§”‰ª(ä=çR•Њ‹A	(7Øx)ÑýnÚ= t¦%r¦é„U…
Öâü«…Ê!k_—@¢í!ÅãÚ(éN&!@Ë Ûíjí)žêemk‘Kn»Sëᯕ
62
	else \
63
|3-¯”ÖÑ4…Ò&é´ôˆRËù£/ŠKõö¸i^z걓ákRfÒë``à<5Ý0Oì#
63
	  echo " *  (snmpd is not started.)"; \
64
•†C{GØuðé4á~wXŸ?C×υ:9´ÙÝ!þòíŸÔ¢‹äÅÔܒ:øãË»eºðÊÊÖ'vA´µµj>Ħ:¶™FhF5˜{ÌèdïÄ ÙÃÿzÃý•Ûš.v“ÂÐ“Ì šàÇ^Éyi©ëYOºµÌÛN;¯nyûÊdÑä]kƏ•¤U,BR_Œ¤®ÏA¢É-ß)á?f°ê<B*6^&ꪩ"0¥n¥”­ÃP8P€m­®ÐI2©¬!òD0!‚ÆÑÑE’ï'ÚêX8­Iæ|8Ë¢B%ëû/ï“ÝÂñÛùgŒßâá[8z‹ό]¶¯¨o«	_1Ú½egöNo4¾ùïÂתoüs—ƒTÃJ
64
	fi
65
LW²Øb»¬†Iåýö߉Ÿüó¥°Ïò]¶¸Ç
65
 
66
¨IÒx
66
%_sh.o: libipt_NETFLOW.c
67
{Ëy½fÃÌé=È.î¸ù½Eëó‹jÉ	X ÁI0莢áíL+ŕ’Æ¡[Žœ’;ÁŸåì[‚0Ëf	ŽB–­{ÅEö¬"ÆñàŽ¾1>Ý;ï€ÚùëQë
>>—‹ìuø‰4Xm˜\]1z¤ôg£	¯š8̤D"ìŀOE í/_ˆÇ[I…ÅOÐq?{l/'ø4A°…׸
Ž‡ñÇp
67
	$(CC) $(CFLAGS) -O2 -Wall -Wunused $(IPTABLES_CFLAGS) -fPIC -o $@ -c libipt_NETFLOW.c
68
ÀJáShº.šM÷1l‹0î§>ÉçåAžsõ`ÿ·9Kñeѯ=d8ý!µÜ[oå@lˆºâðìþ%5¡¾ßšUcLTÝù£Õ/hÔûBJôÑɅë\¸n
68
 
69
Ó)Ár…kAJïèÒûʝÉv?ÕEª^¸æqë!kÒ^0Ê3Ô%¢";•MrëéÁùîô§Ó³_N±ÐŽÂêÑp?õ£«(­^dO"ýpô–öfj>÷PŒQ.ú§¯Ç¿·¶ru`•z¼ï3cïÀV½(Ï:H¼pf‘â{Ìyù‚·:²,&}ΰ+úÖÅôçN÷—Q¶ôý7èÙ¨Íia&Yö<Í"öʲ»’x,Å%…%SÙÓðýÞJ÷+³§b½Ÿ¤êS…õÒåès–`—Ñ-ç¿ýËـ-¥hS¦òTVÖÒߏœ&%5¢6ŠòëJwø¹t$‡)´ÃÅÛ:¬QIÔ¯ak[ª±çXòQC^`ñ”×p™Dü’®K×èn䟊ä¸y:üØä–;2ŸmF°¿p¬oÃR°$b¬ò
69
%.so: %_sh.o
70
ŠxÉhv
Kcd„ˆà#_ñâ§SÁÊzÿÉhõG¨`ëÓ`@i²¯±è“'
70
	$(CC) -shared -o $@ $<
71
…KÃÂZåi7¬¢;\­[ïÊå4ìÞÐÏ/ºÕøÈD5‰²×ïË ö{ª»KŠT|5òRÔww½ý†¨öW/6PãQÞØÐ+*†è> {áÞ䮄,NÜ£¯†ñ£¬°âqèK4D¦3óþXskï_2·*b=oÄyŠÁ
û='&]moþ¬C!Œg*¹ÕÅ'§ì ;kå%;÷ãV®+‹fë’s]Îg‘™ÐnFSÛË9®ùŠ© F(Ä'j1¬eµ½
¼äøˆ¯«`5\Q•rg?rúQÏ&9Oû_¾OËötõÎá/™‰,©vˆV¸ÑÑAøø6TT‚†0ì&…Ù麹Žÿ¢©8s„xñRH}ÓN¯›ôÏT¥[Šó%(gQmZ³ÎôˆÕµL:iͽiŸè%nïsÿd¹8DZju”e7ˆQn8œÊ‚Œñ}~‘åx§›<¤Õ>çæÑþrʦ-SÇ<ŒË”/¢©€P庳aê–Ù2ŒÂ¢(AÅýÀ#çW=¬y֑£Ë2Ië$ˆêÿîrr.?Á׈i¹”À˜A^&sE	ËGt¬ÌU 2¼z•<ßO`M(^ŠôBb–¢çÏaA}'LZFA?Õ|ÜÅÓ\NSPrÕäÎñ“-¥<ž„ÝP-ê ‰9Ÿ¸¼Y€KëÉ~ôBüŸuª*®ã勅• –ÒB/ç×ã’iÌNQcè×>†zñâ>m&åÛnÑ}[#E–Gî(¼>åÕËÚîècŠÔË{\
kœLJ	,ð
ô¾¸NPÄ@Rea·2€[ȾðKŒ•ÅŠŒ¥õ,¯Ó˜›×ŒÔšsõš·QØa;A}á‹Ç¿
ÐSÞÙ ¹œÏ|¤^T„çÜÄ雵Ûaw¤hs…—2tØ òл8çËLCP¦˜È‚ú!98oZ&Ú7§¯ƒ·gg?áÝÅcFóo—âaŸž~UÈ#™?¨{̇9Yu‡I\ÉÁTø),åÃ;DN+٘èñ@…¦û¾ú~«ö°õgô ÿ²Û»™ÄäJW^r龒$ãÅMgîÚûÕ|âÄýÞ$µN!é¹°
ù$¾€}•º•K6¯*We•KÉ d²1sÇ®àv%Y30«ú4œ¡™7ûÖ±üû½ÿtbXöþï?wjß×sï?÷þÇÿÏ¿Òÿ{8Šûb2œ¡+'3»‚cØH˜£ÒW¼bÄC&¶Î;2yã¤õJ¹öFø:»Àyü|GBË;€ÿ*GBÆ!P7A$¶W¡¹.…ª9áwÉ&ÞY&§Þi7ãÒ{ЧC7)œNÇ1{ò¶=Ólfygýƒg dVRGp
4}:elGÙ§,ÐoÔ*b»"ö*øc‡þÝþ~ç{ø~¶…~kø?”uUtN½W%_àU©"DµÿO=·¹na?»D_‰uŽuYµ—!ï?°»Ü?ò´55ñåÀ£}—àÛ«%pÔ‡C_&€³˜ÄÚ8&Ñ×ç‘x8™uÈÈJb)ÆQ/n&(.6’bۂÝoó5JýÛî4òp;¾ü»<XA®¦;<òA·doÈ&iir ”éämw+:íæ1º*í¯É×ý¹rË[%Nâñ VÞÁWþ€Ah´Oƒ³ÃN³´;±†¯}©@f=Ÿ)§1çoçóAuv@vò øÛïDT¶è¿Æ˜R¨!ìr‘Öi§ù¦	„X›†8£rgnù¡o¾>N'M±fIÌ5/HÐ:µ\ÎQ£C9;ž>Kˆ.ËH¾CzñP÷[}µ †®{.1ê~BÆItÇå ºô4Ÿ,A¥g¸]\4öAîy “1n8ÿ{™oUŸü‘f § îÕÕ4¼²€žy€Š#5e^YR ôÖÊö×j_/£N	àáN’²ä:UÂlç‘$°ÆmŒ¢±ËMùa'Sêü¨ž½d{0>Ðϯ¢ôèv‡ýMãݛf…Îx伋&Ô¶ÑëüÈ»Œ&q=CÌ]ª¾ç!9ð$„…½çŽwfOïÜáÎÂXä>+qVnŒ@ÉjÀmtfêâ©ûl<rÌmz` „„ÚNYͪíz!\jö¼061ßç!†qâTôÔâÖôÌdUUw»˜xTZ-%D-Áà<ìÞø¥kç¬Ó@óÀfç¢uˆrO_â‚ZC³…­•Ñl_ĉu4‚T_Yà^·w†!*«ë‹üD„{®ä (£ŸŠ§ A,3	pÁD´Í™‹µ`:Ìۂ™Au”O‹á¬JŸ¹Pª·šÀÓٸ睘Ðëi÷Ê;3-˜Z{g¦tâ¬kÙh$E\DÇB6eWeÈ_Ìåag͐£ì2·]€«A몗=44ù0AÍö2ˆ
÷z6ºâCv	ÓØË 6Ôz+ÚÕ¶ûgsa^GŠ.Å~¸¼ÜPê´VÖÕmå51¾Ñ`ÉÆWeYqÙöcJ³s°~
%íwVèlR§Æáòº’ÞƒAÙntû¨Ùm¼Dõ™—aXä¹Î¤ƒXÆ¢áõ±)¤{â¯X„pØûîµî‚&XÁ˜ÕWÜ¢%ÚÀW¥¢<¬SÍPægÔ;_r–ñË5#€ìM1;˜o՚€	WÈ/\ù>Í¢7r°xɪ¢
øUuŒfÎЩ	cyGæ(VôÚ&ž:ðÉÌæZf+²ù0Y“Tæ¨à=Å·"ox‰õ0ÄmAítÿϕw{x-Ä7¥ÌpÑ'Uñ~
x b›\Y·!1–••cVTþàÁòsÇ(Ê2÷sŒÁeó#X
71
 
72
P.ùÍÓCúÆCtÛ¯_}
72
version.h: ipt_NETFLOW.c ipt_NETFLOW.h compat.h Makefile
73
ñŽ%gÁÅÑÙéñoŠ6ÈwI±Ы <¤—5ˆ
QS¥Ùd#Sƒþ$]¹¸€ÑcŒ+š"àžÞ‚–Àd
‘mºbϯh}~Ø\^Ÿ?n*Úu¶ë%¼®±œ§YrÇ7!ùœöU[üÿq¥áŸ$X²œâŸ{¶ÀðêÀ0ë/°¬oííì2,U‡¬J
pyµìgµqA³+
LZ’È2b]~U/Kø|ËYåø¼¤B¥Ôq·z}÷ƒ>ÞBŸjê¸jêw.PX?ÇɬwӉ%½Uã%8Ëk֒`߃ÊkPF;)Dª­R=¬2¦ÞFÄKn>u{!ºi•&l&€ú)¶ÞÑ`/TIöÞÆKùãö²"o¾u=*¡4”›>*«@_e[¼´OO΃æÅEpzÿž]X„j•vÿ›Ó5¡Wˆ½d2.ÁÏ5¸€ª/«v7EYCÚȕ`Ió¡9=k¿;|{öê5;ÿæ«(žÑÿr~F„êÛbaZ!¾¶Ñs;ö«Õ…ì´€A|8ìÃ8Vĺ‡%6^³TÑïèU8å¡VÆ4ºšw§í֛ÓæÑâzfªž[Ï©(¡zŠjaYáÔa9-;R8¿\œ¾éüvÞ\<TŽQ#Ò©¬=PVŠ¡Î‚ŸT¿ûøªqôsãø]óó'wÿsÝ÷‡á´DOŒUå£èRe˜Ðë2¥â€ÊDéZƒ_-ã¼Âå‚Ò¥˜;YM×<hH SçîQçæ[Ájd¬hÝE‰6P^®"% (#€q»Jñ}K|…楊º‰Ñbåëd*ÊÜt,fI6š£¾Ýx‰a®Ð–ö-ÍàM³sÿª/š
­]/'¶°µZ`e.fp*âHØÉ9©¹²Ù'š¥žFbxEs08üC&î*¼V]ó+<=¡‹˜GÀVJû2…zzÆkc͖ÆtÑRh3Á? ,ÇѺßbœ=š° XØ»–,Cê|»ˆjÒ­)ý3ùïÿ}kÑ2ô¯Ð®¾á2eŠ,¿Èküÿ¶KÁ7±êÈ8®öóOk÷¥GNi—ºL8î¢Ùn^üÜ$ûï%TS½ˆ ߃Ü9|lö'æ¸ÔbÐÐ×KäfâÁÃö÷®ÏÕ²²€Ó9hÚîf¼¾h6s‰ïNÎr‰‡g''-{hŠ¶XºDã°Ó:;Í&ï=²£iMÞloš§ðg‰Éé\ő€¼ýNÔÜÅÞ0i¤.LJE×*êMh„e½(Â/}D;¥àá~œä…]–XIWp ƒPE	¡Z[èc>FrVqC¾š†£ø6@Úýp¦¡¿ô—\´vŒ6nº ¤¼ê¬° îMf,yP\sÒº垕0œ	üàŠªÌ,5d¾ít‘´¶!±Ø¢t"`˜¥O%Nç"ËZþ°ijñƒßeýê”$Í}ÿÊ£¶¹NáVÔ}+×êÅÃÙãµÅd^Œ“T´OZ·u~ñ££Ñ²œiÂ÷îzMÔڔ$œĄOž :Þ{9BëôZxÅXD­(“¨ÇeàŠ˜Aú6=¡ ñúS9#g!voGô°8)WOhC§Vkñ{ºF<ÉO‚'ú=ã„7~“Ëéd±»>¡‡]ò`˜ß2Ò`‘³*|x,Ÿ0ôãzFï3ª4î3½ #jV¨]¨ê¶–K}z]¹ÅoÔk
Iˆ†Cƒ	-	›_3+Ёæ®ÊêJVýÑCMÈ­1ºÞâ7=ZÇö)„:.#÷e³¶É¾Ò£ü§‰{DxmÍp»^H¡¼Œ%zfš ›Ó¾%e3—´ÙR´ííuÀÅÕ!I•ÒÈÚ®6i˜{]¡Cæòjým¨î¡‚š×{;Yzí÷f~én‰tµàÙ4ã>Ÿt}Yõ&ah¯@fª!³\M»—Êk´Ñ•ämöJ°jin?è•ûÖ³=ße€u¸@—=Ò7 ¡gmòjw˜¥ÌâþDÔ,Oº¤¹0—~xá‡ÔlfI^³n¾2—oˆÍÓ%·ƒêÂ˾H—_/\DÙk®Õ•£æ«woNÚo:ǥҚ$hÍÏ©ÝfF[±M†<َ-Hù@?^—›Õ"Uß²¤U™S¤?	ùvoŽ¬ÖšÚRÜãÓ3Ïb0¡Ž(Ò!ùñïãÇå
73
	@./version.sh --define > version.h
74
ëZ{Œ÷Ú¼1G‹è¥mµduÚ
74
 
75
SsžP…ݪeš~9ݔ™"B;ÿÊV‹õî,SW[àðÏy5ë®ÎïaȚ€ç‚ºÒ/Ë=²âkWÉÚ7Ñð’+¥^´\J0v‹ê¶QÏh•X´³–ìÿÝvÖFJ¢O <Sƒ`Ž_0Wÿ*R¿üÂyLrüŸxT«¸3sPKoå¤0—Ü€¾+²¢|]Ôi¶–ÿ›ìèi]ÍQÕÌ$ûÓÇz™=¿Ú–;㔶íŸDâý­ˆHÖÞ|ʛK£¥ÀYBLkq_фŒ‘©½wô)tž#Ë¢S{œH[៎”2¦ÄôG9ùýDªX‰c‰d݌må4Àþl4º“õ‘;ÙÅõ¡/,€”èÈŸÚ*·åÝáÇ.HÈêÝ`´GØË"«è2cãõç”Þã„T=FÊK˜âœ
75
linstall: | libipt_NETFLOW.so libip6t_NETFLOW.so
76
ýƒ9vvèhûbc 6ŽÅƑD_áLj¸[/RÜljäÙ´}/=Ý'Ðhફi<›”Ø¿MæàÂGwI²ÙZöþqM1`ÑÅda>>¹’yg­£à¸yú¦ó¶ä++¸·Ó£ãæEpØ8
.HæI=µŠ6>U·uÿìæ󙻧ùîa|aþ¢æ0ó¹hušžö˃ævóY1ò4ß՘
76
	@echo " *"
77
ó5߀ÝkôYàÆÃTºífx‚t`šÁ T®òGvmÏ4]½H\£GqãX(%p}“ÏÕL“í'ŒsmÕ¬|{•€S1›È3=z}¹bï'æEâ&ÍmË$·CÞ¹›ò„#lòe˜8{¿ÌY%iÚè‹B¨§µúôÄf¬ḧ́‰ ÈÇQrMm°LŒÕFÉkøí'R®d´	r	ÕÇö:¿¥6	[v»­x NAº»g³Îö Õ¼š(6ø
‡×?Ñí¥3Ø~b¡
77
	install -D libipt_NETFLOW.so $(DESTDIR)$(IPTABLES_MODULES)/libipt_NETFLOW.so
78
ÚÀH[aŸ"b_†´®Dc4¼b¯æƒi<¦˜¿ò,E£$pZ®pY"^ÆsÞæ8‹Ÿyɼ̦ò‰!²éFMòXfÅ®äÖÔ?ÍÌv÷r[õnŠzÕ%[Í@îbhËÏgéŒóÛLhý<xéí<(.èækæ´³U¿Ï¤ÆšíYM󲏧zvê×6EÓs„Á<Üù9_88Ôú¤ƒ5½™'Aµ_9Ç3õ}«IžAkÏòn"ƒœTî?áiªó,þ¿mÂߟ׿ՔWjv?ô+ÚEŠ°/Ua@öõþ_¬·êÕëÿç_áÿe{·^ßÊúÙݪýÿ—ÿÁ~X(
78
	install -D libip6t_NETFLOW.so $(DESTDIR)$(IPTABLES_MODULES)/libip6t_NETFLOW.so
79
úcéNi®ÏãÓSä*_I‡/ʹ‹˜ï¾ey÷-â븀 ²}¶0¦yŽ[*"ŒðQ¢åúEÖ"QVD<e4¥nŠôOE<Á’e úN»©)\Ü
¦µ$üÿu<v]wÑËËÑK
79
 
80
G8˜
+Œ=pýÒê¼={׍Óß0ñEã´óÛ€§×(ÞÐ!‹F“a¸¡uÓî8½ƒF0Ž“æÅ!¬¼Æ«Öq«ó4F¼nuN›í¶x}v!â¼qÑi¾;n\ˆówçgífUˆvˆ¤…ŒbNw³3 èÐ~ˆ¶Ó¿Á@'@ã°‚ý6„ï…Ñ-P؅wr·x(M—N±¹"µºHl
P†UH}~¦“ýÍ͏?V¯Æ³j<½Ú2šdó¥$jÓ¸©Zç–ß-2ÇM^å©ÐŽGȨÀæz“¬êzQҋ«½x´Ž7ßµñ«?ë¥Éæ$ÙÛÛªÑwªh-“îØ$ÀPÔÕët4\SòoÐFW)ü˜$µg{;:/ÀqGá8%f-σ«YÔ·žÕžîuÉ«z¯[«©:7±ŽlënpÑ<<»8Â8¿Ší-ýÊ]®» 7ôÐ!«¤³²¢‚€è„~6mc€ÇeJmoe%
80
dinstall:
81
¢AÏúŽ­o*1…>¢änb:ƒ“Ɔ<#;	_éšĞPô+¡ofOñÐ/	§À‘:!íM‚Á°{•èå0ŀÄn
ÝÄÁß5Eؓ'7ú³o}",ÆÂñ	k³‚n*eC Qviä¦OJÜÛ]Á}cÅÔÃ3éÏÔØ ò)Ž,Ú°yíN[šMPW¢—Ï#V¾\Øm$¤U%"Ÿ;ælÔ¹2e)r—lüJ8¾
81
	@echo " *"
82
¤Û +%ê›þX!Ï+Ô#+~æ[Á÷>Žý0¿sÌþ¶Ù8ÂPw­¿5A+wb.Û=Š7ÌÞ	².
82
	@./install-dkms.sh --install
83
 
83
 
84
1¡å²™`­×l5ÞþÛJë5ü‚:í¼£fûó¶ëîX?[±äBèI¢M=üßö³Ýjú)•a*[ç¯[¿:ðÝq—à»	
84
install: minstall linstall @DKMSINSTALL@ @SNMPINSTALL@
85
	hqƒèÿ[ý„‚@–¾}&B ‰À…q6…Gû îfX­GáPP’•!‡%TŠùr–‚È+l<ÞRPéǘ `OpÉP|E•îÊD;MjME †|èBA´NƒW¿ušmXžQ:…ô{ˆWqxA¬ ëòü§òüñC¢›q~qÖ9;<ƒM“šø­>T
"ôaYÓÀè+AtÎe49Á“œ
Ú J`Á±¡öêð<x}Üx° ^aË3‡¯¢4±!Ña‚8Þ	Ú‡ÁùÙE·b³i/ìÀRž Ì:‡ÿUD]xJí:ÿ™‹`ð+U¤u~»Ó9&‰Ý<t¤ ÉÚ°çSèãOÇt¹h“„ çÎßu¼ùÀiWˆ´…ƒ.¶Ôƒ®7þ£vGÒoyd*lúâàF`9n„U® %è8G`nI¦@asp|A2í	ç4gWvÚüµ¼=ÃæONa9{O
85
 
86
ȪS4€®6hl‡o›Gøð=þØ÷ÛwÉ»I‡^[XðØø×­‹\6l>Ò\œu$kÛ»ÑlԚÐ!±jhÝ!׍ºŸ
86
uninstall:
87
¨ò﹁{>öÙÓ­«í™OU‰¢±òÛ®©b¤R7^5¹™Ç˜‹¡‰'Ž8<9Ц:½7št`Ù8ŒûĬv¶‘NÞ­7þŠáí‘ßAFæËn’AóW}¤÷eõ’”OMÁš.ˆâÃ-w-í^…%ëº$6;S%ü-¥±«©»Ú“s<0ka¼,rLÖê;m{–Å«t
|Bn|-±µ•‡ÝÄÑى¶Ð%/`;hrM‰á¯ÝºaÂNçX¡§¬mÃzVՌ\ÉâçP±ÚI·§YÆpÌî÷zzä$NRËëMA‘§ùÏǍÓ
87
	-rm -f $(DESTDIR)$(IPTABLES_MODULES)/libipt_NETFLOW.so
88
ùBÆn2¬²‡#yԂ%â™ÿŽ"X¬yÿgIìºbWÿÄ÷ò8^1s¡³sÄ/ÕZn÷šŸR؅@=oÃ.ìe›®ïq<8þ$NŒÉĨ•xBÓDA玲È4Óäûš[®.Ëå
88
	-rm -f $(DESTDIR)$(IPTABLES_MODULES)/libip6t_NETFLOW.so
89
Ñòg•«»å¶‹ÊmgÊm»åvŠÊídÊí¸åv‹ÊífÊíºåöŠÊíeÊí¹å¾/*÷}¦Ü÷n¹§EåžfÊ=uË=+*÷,SîYf܁¼åhÞÖì)~öM‡§ÄĬwÒ;r^àNIM3ú¨ßfxÔE-x˜v½i4aÞ3ªª&¦¶½§W¸‹°›˜™Ä¹OÑ	7XDê9Zà¬Ü±@žå$üž-jj(A<ìNû™²(bQœf“¡-£ZÚÊ9ÉBìTÌáU°_'„馡$œõÌiÕQ<êFãLq”z!?‰†°ÝçëJÈ3Ô¶î½b˜So{¡v-L0{[t7† Ó£‹ÂJ÷¶Uy©Ê/R¶ƒËí8ž†}vúV·«á
89
	-rm -f $(DESTDIR)/usr/share/snmp/mibs/IPT-NETFLOW-MIB.my
90
ÖZƒ‘Çi´íy•~¯¡æWúTÃÍ©´¾%睒·™õ¬¾UËÎKW±d zè(œdažÒb°sFÓ)q”º­g´3ðe¡Â‡+ài£Ó.RîpOÍU ú{}.ñzUt†}j`èôT`{w„i}¤:}€S³§µüì¬Ïœ·#óΧQ<Ò;·ä®Ì=œ%i<
90
	-rm -f $(DESTDIR)$(SNMPTGSO)
91
§>{/&œšrs~}—D½î0·`ÀmµAXՆxz<&#ÅÓÊ|¶‹[håíó–=ÛÈw9)Âò¹VjÁ¡ìÎ{il)~œõLêjМ6EB·2qÙP™çñd6”Ýu䩍šæÇùMšœÉ‰oO“môêémSR¶¾í4mž¤Ù®ïx`ýl§Bö´;ö‚>ےRS’Ü^!'\œ>z¶c5êˆE>5½=€#éövÁ³=Óûe´h»úï] ö¤ÛƒŸ8F««áx6Âã<uîAžNgtp
…ÕOX»
(í3š Ó½¢Ñi¢3ÁŠIfÍ´qV •ÎulкN4€ÛVñ£F§Ðféɇ"×-ƒxÝ>H›Oۇgç düֆJd¥œD;×CU+§·N›‡‹#Y-'6`S);:Å¢x·b»C&ǝa¤rÕ¶ÎBU–<k¤46¥> ºK—芴¬Ï.![aqÊ¢pØÈÖû€ÊEÆåæžàf(Ä»n?udKOAæL¥ñÜ"Ħ¯€üEÉò„0ãabÎñ(P*~—°Ú¹±Ç>ù3´ÇèáÉ0€¡^ªçw(‡]GWÀÕy²ÿ\3wk[5ÝÌíêNµ^­Ïi*—~‹Öfهlõl&r»%Ïg#X×Ènì2ÿNãeºÂ'Ë£ÏjþîàYöî u`Ýd8ß\Ý©{÷R†5mò;Øéêr@~‘¢&A“ÏI¦âÌÈ{Ák¤¬“îS`"½¯ílm}X|…ÂçØù. Ñ]ÜþyâbùFÆ}j‚j¥§q­£¯lß	Ÿ¹¢x˜®ØñÚµ"ºìKŠÑ4
Ѻ¤Ïò¹ÊÞC"k%awÚ»FS²ßQWÒêàJ$q<v®è,éõ»ããàË'‹Ÿ(
91
	@if egrep -qs "^ *$(SNMPLINE)" $(SNMPCONF); then \
92
dˆRæ¤ùkç¢qØ	@*¥³É0,¯”øG•/é0¾©|œÊ7uæ Ýø¹iJÃÒ9‰Ê+ÅLÅwµ½\g靧Ž!ÄW¡ñ+Æ›ö
92
	echo " *"; \
93
ßÁ ¿wh+	jiÆwwb6Žþ1¹ûøö¤¶÷¤¶‡1ëžÔéßþ®Y5‡ÍŒ‰?уì¸`äǃè ¯©AêÉè'iþZSlnâÿOohàLÐpš»ìD°µ
¼ùF¥NŽšç·†3q÷òÞd| ë¼<jxŽa¥.íø>wªx{›Y]ó´ñê¸I}l(K»WÿPÐQŠgȼP€íÀÊ6ó®gñ÷p›²2´œ4Äu€‘뚝·Aã¸yúáÀ¤ÃPØé²Ö…KÞ쿯V q~ÿa_<}ò_#"Sì~/JCĚ^Ãìœ%h-Çölf¼"övÊ~®æ5UŒñáý¤žC–%{>9ƒñÉo4fÃ=ɳ´GTÄ×%fòŠºÞ:ïΡkðB´,mí
93
	echo " *  Remove this line from $(SNMPCONF):"; \
94
8—þ•6·1n,ðQ#âÄbÞ_8!ÜÌ(P·L2²DÙpŠ½µZž+¥U;ìçok5vXwr}—8Å8Eâ“èáÏÅ»ãfÛåû)/ä¸Æå¾oŽÎ(Ɨ°ŒHi®išdøwŽ€cŽ€Mÿ³‹Çh4Ó¡9‚r¬Ã9ŠË¶^~kã ò¡–øœÛîN|/„,“8ÁŽVf|×åšk8É´e‰—™×•òÆAª<HÚõñ¯òôÍ0°ûÞÙ2¿Yo«é©­FO¦C$8òéh/ÂOj‰ü•~ŠV
°Ñ¤–Y8`lHa‹TΫ¦I•¾30ä2ނÁïT",ü¶;‘æÜϔ¨Oðl4Óûl„–¨ì. öËe!O”2¥€uTA5<‡g§¯[o‚S<Fó§æQóȱóI\+ŸÄ2Ñ覅ÃÁçëéAñÀØBçéBJ­ubdÒ§ÑΖ4!#?"yoqí?>nµ;:#‡CüC'³é•To›M`$5b3šƕYùUü'CU8@”B[Ðy¨vç˜txÑä­k
Ä.|5۝‹³ßhL	çggÇÍ_ß6ÞÁ¦™v«_t@	ÓÏf)Ètéª=ähi-•Ðwp»¡L¢T‚¶‘ú"&h퍇ð¥fNúm?’&ï5ñ÷hû½gWg݈;tKԎw''¿ÑUii<(øß<§2ÔæÈ-TS?ÄR˜º±gí
94
	echo " *"; \
95
ÂÀŠ[b×ÿ…ÜzZ«HÝQˆ…°u²Å–4K0Ú->á„!NÍãÙ¢òå²rì‘ËGKü%†ÁT7‡9HÒxÚ½
95
	echo " *     "`egrep "^ *$(SNMPLINE)" $(SNMPCONF)`; \
96
9jiÖÝÑêJ7GQ/HÅG ;˜à›ØJnJébԁéìgԕÛ"œ¢Ì¦"„[þôT;ñfᬁÉDdáO<ð1.þ\€~ªb…ô0	è&w㞄äK¦üäxñӄ¡á#¡]®âx¦ØWPho‡·UÁy›…Jµ›ÄÃ>#ÄlŠçP½î°'_3p):08'úu‡\ŒßkÑK1~3Äf‹ºÑÐ*‚ŸÜÂ#+;…­Ó4ń0-ÏcCÍB34†ày¾]F‹mJˆÒRrPÆÀü °úÉ}«‡í
96
	echo " *"; \
97
°šóU×_Œ”$	o×40hw@·NK¤€(
97
	fi
98
È˾~»íNKΉS®>Ûñbj1&òE²,:tÞUÊ(+è	Qøëi7;_SÏ}«é´e¿¬ð¸ËîÇ|¬ÔR!nÈÃ]‘ç;¾åȾV*ie-«šÞÂ&‰K¯,ÕF.Gt$\p¹r¤ÁÉbTî|ÈYãÎÙIëÐê'·àùpÕö£7m²O0giv;p…cϤg:¤2ãüSȝÇÎ|P³T;¼Í@ÿz®þ¡IvaŽ&t"RM<ÈèÏÃThtÌ,á?jÔ`Ø©(?Áý	dg[È(e;yL°Èé½/e-×ú3éá­Né͉úæMÉ>NH2AfóZzŽþƒW!Þù‡}¹FáŸpø³ÆqêÍ5,üÈ
98
	@if [ "@DKMSINSTALL@" = dinstall ]; then ./install-dkms.sh --uninstall; fi
99
p™!iI¡ƒk	+7lqö
99
	-rm -f $(DESTDIR)$(KINSTDIR)/extra/ipt_NETFLOW.ko
100
6Ä
100
 
101
 ›)¨Ì¾ü˜°}Èe±=“—­kØ~Žf½k]Õ¤›$0®ˆ"ÑçŠj± <0q¯;í#f—Û½Œo镹Î/¤Í̲šbP:Üî8]À=†—3SÜÁ/	¬‚«¤É@• Ïn½ÅHU´öcÖyÊ@EdDÑ2¹4l1(cY/¬š3©ã2¸QU’yç%’0a”\•Ê"¾ñÁríPN̂ã{S©µµ´6ãžD¾-]Å))rЃð@¶Ô)µÑ©Ôé™bÀ(MÂá€ÙECßp§-÷ÇÌ{‚Ç‹áÍ<DÙu{à›‹¨XÝFñ,áS)µP0«,÷“)Ë+²>i… جê䔲kƒüÌ·í9@ÞGベÃù‚•ZØ5òm»E‚UÀ&¡ c±‰ñÉ΄!o{uåñ,[7¾¾“oØPfZµXUi¶è\ŒåñË$Þ.ÉÓ/#³	(‘Æ }°°)	¬Å[ X#³ ¤½°ÔڝWàXN£ž)£Wʐ²%ŽVìQ4ÆGžáÇQ{j
±_¢pÜ»c=œ	ÆCåh´O’/žî£üýþç¿é¹÷ßÓ¤ñäÛց¯¼¿ÿ~·èý÷Þ÷{Ù÷ßÛ{µÿyÿý¯øï»›³dºy7§³Ë»ÕïÄÙ%¿”À
101
Makefile: Makefile.in configure
102
t3ŒÏ¹ñ7>d}b3O8¾¥^YÔ·j;ây÷²÷c
102
	./configure --make ${CARGS}
103
ê&U§³—'Ÿõî‹7çÇÕÕUôâMCñ¶ñ$Å-Ác“Ø›M“0±8<H?^]ý1"ǁ/Äþeœ^¯þ«Oº[ýÄ:H®¨ªÁW:àtBÞ»xš¸ú†ê;†úª á²[Ë÷k×áýђ”køe÷÷OςÆśw'ÍÓ·Š.rÙM{×\fmãr©"ýpؽSEú™"Í¿¾k]4|JRÓ¥êJ¥_*òi©"8²º’¥‹3(âÄòE]fq«†µh)œ–«VÆK­mL—ªe¿q‘Ã¥Š„éµiVi“Ér½=$¦ì—ý4·ìj¹Š{ÛúÏPÝéÕgÀGþ!~RÄãÇ<SU“¨8k¢}Í÷3 ¼MgVQ2ç”e¥T×ìraãë,Œ2Vûq”Âþãqõ1ßïña9êOʧ0Jhæ&4Ë.ù䱘~ª™EŠ×ñïæôSÙ­ú°;¦š­‰„^ÿ˜…³Ð‚·¾ÃCÄ}ñÝÙú"Þo\€úðù#MÙ/øy‰ÿ¤Ÿ7>áßèóF‚§œúá?(&äL1¸a™†ÉµÖÄsà	‚+™*
M•ŒMèÒ3W$Â"NŽm¸È5ìlÉ»Eq¹ËaOp¹kråj*õª‚0ºå¾Ñ„®œÃpP Ò|dƒÃ9Ö¢z'G.Wî–c+ø4bÈ£„’H„—¤£|¥)†¥F¸… šÒ„ås¥.±Éh«Ô8oÐHt)Hº§¦ÔB–8zü#A"29È8ÄRÅڂ>?¯]Ð<u§èj³› £hò•O/£~&ãåHÐ!²b<3—|~ŠR±eÍZI!Oܽ/Äõۂ¥ÞÜ3r,*‹Ž¸Õ
103
 
104
‹Kl<±°‹Klôã`M¯ªiD’@f©vðä@h5—@›Äí›¢×H²pÆd!0Í)+!&¤Ȧ«l9†Dé¬7¨©Fbt‹ê÷*Ήþ*þzîì–GÈãŸßo}À¾ˆ—4€ºÏ0¯
104
load: all
105
:Ô ¥ìՐ+Ôù»„ïGujŸÇ!²°G„}7˜Xú±”v¯*äͧŒˆQê¢÷àoLñ£uVExú,e!)+HzÝqióðüÝïý'›IZÐ\xåqôXa_¯V7jÌ:4Œ>s›é?*‚ORûaÒ£Šª#äËÒæÿþ=Y/ýÞ~RÞ/•~Øÿ=y5–Ÿ”KÕõò_6ËÕ^w’Î@®®*Ï^ä½›J
105
	-insmod ipt_NETFLOW.ko active_timeout=5 protocol=9
106
yH JÃçÏÅ{êª+û K]ú˜anD"YìK2…øÎ,‚É),>Éçè1áz|
106
	-iptables -I OUTPUT -j NETFLOW
107
CÓÅ¿ˆwZ­VËb?²HÅÊ1¼'ŽNE2¨ËÞG˜ Šþ9a²p¼
'™ÁÄp
107
	-iptables -I INPUT -j NETFLOW
108
´cÇ¡‘­þãKÑ(ª˜ë·V®^MÃ	t+Ô	#¨w,?,½ŠXïó`€\ÒҚXãÎÄÔ>ŒÐDüñ9ü,BjÒ9_°ž÷=Œ³à'^I3$~+ҏ¢iõj_*rq¢¯oÚâoÍRaºÍ:(mïNÿ€ö|ù ¤Ž]Ó¥î ÌýJÙh#ÃÄê÷€‰íÚÄ~G—‹úQºuH¨cŠðAßÁ¤1éïSLûº @ë?@Õèùè•äðam“‹¯‰Ù˜,_Gh¿z7‚q¸ù¡4`Ú`
108
	-ip6tables -I OUTPUT -j NETFLOW
109
yӅxP¢9À7!^ü ©Úª¾0°!TuWýÖ\%Gpð™kºU"NÊ_¸@ôÜRG¼Èµ³¦(\/«ðÓ¤J¶>%U L=E÷}“¤„lMB‚¥äŸèÊ>i3!ûÁ’ž2—‰²Š—Cw?¬âÛ×[d.@ú~ó÷Ëéf@˗òQûÃٞ44ÿ$y)ýôôÇ'(,p8ÿ1žjü%”7 ƒþâG
°v‰aäâ9±æð²Ëßá}Ù$4­uã»?×M(…wH	°ø5z¤ú¦Ÿ6™Ÿe·-‡:Õ¨?£N5ˆÏ-€Î\Å3?=¼Û‚Ì‘²‘øüBÔhd°­D©†’
¡Ð‹¿©ȧ5ñdc}­š {®½ÉROªœb£?·ˆ™¯tŠxÊ<0Ž†Hš3ÌÐQa’ÆÈgð—ˆ@Ë•éo»É5núÅâóuå泸~óÁJ/=º®*?›(ŠÊâ‹RnŠfƒÊž7#x‰?ŽÉ+¥
109
	-ip6tables -I INPUT -j NETFLOW
110
Æ÷ÝYòq;Éò¹K»„ý
110
 
111
fô%é×t‘þ#:S›¤*I	®?û©ې¥üZè鄢”Åw®wÃ2·˜y}U‰Œk§ó>ßTn?‹›÷·Øwé´{‡éX)øk™5Eý%
111
unload:
112
¾Íñl8ügŠ§¤(àj™ª•]V²x@"‹-™÷xÿ1væ%^
Ät¦JYÜ8A$RÖ
‹ÿô¬sk­JÞÞЬøßÕOÍ¢€æ~°)((‚Çø–Sæü£ÑIhF*D¥Ôuʍà”m•‚Üø:äÃ{,ÿŽñâÄÛ¬ð6°v>
Ê3eCI·š!¢¬‚ÔTÄ
R;–Ó"Wï
R¥&MìÏÆU¿4¶ŠËb“8m•º­/Y‘“öö×ÄCñžkîc9ݘ®Y)â4²¾ÿOò”úÈ£´©¦29Qbáߢì&©ˆé¯áíi¦çʲҒۂ¬Þ„w‰äHžTÌKüRè³¼.•õa1ŠÌ
óçüY84<8Ô<qQÞB›ƒì€Üà˜Ð ™M‚⤩Á$Š¤ƒr<8ɌTÌFÜIS=\nÇdzDìƒRH³kzC¢›½À®qK[e&€eq‚èîÐkí2^¦Tì“‹›Øúâ2sîÔǹ’?æóíd
112
	-iptables -D OUTPUT -j NETFLOW
113
;dœd]Vpþ	Z‹RhMƒ
¤^̈ñøò±OV§Šeí?¯ë,Òv¨<+9òÃULVèÑV^ð¬Mñ¤™Ϛd~Ø;¬ÂéJªr;²µ¦skMï]kZP«T’È
113
	-iptables -D INPUT -j NETFLOW
114
]a$«§€äñôÓãòàÔN€ÍäÚD*aßŰxãŽÀø— %T9aIªJškãó¤êßãh\z,—áë10’æo­¬¢Òòãõû͈Ñrŏ׼£}!·¶”¤6¢?ê­éµVMVõ&Xr%oÇÕ¥ãkþê8þHG)DF©0׌ǜfàÙô«Ü.êùZ(1@úÆAX{ÑìÆ:§؝¸*r2	IGÓ­ùŽÒ…J·•&Y¦÷̘VDTÁwŸ×ƒë÷ïeÒµàó€~'O0	Ú;ÿ˜º•”>ðF€ø˜ƒ @øqJ¤Ç“4¯Ê1ÈÑ[›JZûRѦ˜t¬5¼Hî}äb$ˆ2=@ë]ொp(ûàݼȖ÷^͒;‘…ÞÛžœçÓÛÞôïÐ)3–1ùwd7:꜈úøõýüŠ?v£TëHfC× ½ª>©1£nº”Sþ3š”ä,‚Þ“Úïgô˜ùYt¡.Y'Çã±^u6Á‹>»š¨ü4ìÏ`3µÿDv µ›bj[[€ ÔGjŸˆ>Zæ3ÃM*M‘e!ì.à»ÅpmnÏç	îí>ðý1©â9úƒª<]~Àiê‹÷–úÐÔÞêéß0¥	&ÒÒ|,s£l®<þýњrI†ƒ¤~J5»6µ&ZOPtíá³jm ÄÄÿ÷üaò‘È{Õ>ìôpŒT-ý6£:”µ\‘Ùê’ sø÷c4ˆ†¸a¤9¯{ÔȽUr»7Q·ú^‰Ø¢NU­HÄÃõ·ã@öš€…‰Q`€Ðµú\Wï§zŸUIñpÛ£Í1M“C*Xøד}F.I{‚ïœ0rè»4.¬ºVVuѕ{O8<'f€,úO¶OzˆÂý»…$<Ä«ä¥ëW³Â©__´µ.þªÉ êTÜ«î¶¯nåJ?[7uÌB2€òa³R‹Y¤{úßî…dmõ›NXâ`=gå<M°`¶®ª3zŽð§ì}8¼£ûd|là”b-§•^’>æsH€•3’êQàfí‘Ào—¥f
114
	-ip6tables -D OUTPUT -j NETFLOW
115
ˆÕQA©u½F“Ù$4÷夻œÄLÃH‘m©¤2‹>fÌ°ºãH‹Œºº@“=X8ÞӕˆuJ.ŸÁóQ8¥+ASF©„„9Â{ñb«ü5Hìó±2Ž@©“æ!½gÏñ?>']Á³¾SDÐ[Õ£ bÁ¢:h¯ÿ°Gs‹.º
j¹¬ÑK$ØZuMê=„>äÌ+ù
115
	-ip6tables -D INPUT -j NETFLOW
116
öâªGBcç:BZŠhwy£Ë÷@+g¾Sa/‚zk‘ã®*C6PAï:žðuN
116
	-rmmod ipt_NETFLOW.ko
117
ìˆڋ‡È‡”_¥¯
QÃY…:ƒ¯„6DݺBù“6¾ÊÑü†Ë_Ì÷”Þ*¬îyA8T<À7(%"dCBâ3HêFó)žRY2£* Š–6l}(0mmU€E-e@p…òp8Ô÷ê4oÖGawÌG×éÞ(JÖlq&Œ9ÊmÔæê9üóÒ½‰rêÖV=ö]¤aîÄWWø„E	Ë2kßH®žØàZÈpIí^ʞrdNA†:چƒt{Úóº 4k_ã¦øZW(ëeda?1ю
HŠCD_Hƒâ
mHa zv°ñ„(¡­4«ì‚vMC˜±i¨É-í;J Â3ETä#¶{Ëd8¢Jàçt>ŸÀbkçl‚cÆW.àuåíyT»0l¥ó×Y”VíŒÆøN¾lîao;T‡îÊjŽáÏÑ%!…Á"dÂÎÁÇ”&Ñuœ¤Òÿ¨ßÿÁÞ«ß­š½}2ÉتžŸ]o.šÍSÜû¬ý¾µ½ý~ë`»>Z“y¿5Ï~±ó¶uÞáoSá”ÛÓyÍ#áæÕtÞÙë×v¤“O»ô. ŒCT"aL8e¥uL|F¼Á‚6åíé§
^€%°Õ$–·4õ‚r3°¿_ê…ÝÆ&ë]9/ ”þ®Ú¤I}wÿ3LßýϨþíoJe…š². ®ròCk^j´!Còä÷ö“Í2-ê¡ZÔCÝ+æ¤L<ÿž¬¿ÿ½_ýðä/J)á\yìûB<ÛZ56‘¡Ý20Å=!K=ǝdQ)ÕϺ\X©»9{Îg~q†²?ñ¯›á|•°¿A#¡î߆³ì¢ú<OŽž¥òàˆßß¿ÿß¿øðä÷ɍŠ6ˆ³ô„¿ü‡õáÔ6Tµýå‘·Ruý‡ré÷OÊ¥ý2®.C²È”7Yø›GM?=u¦¨Ã&ÍÁ8]Mc²R0ÔÖ(˜©†ø~[ž¤¿À›[w̅ע{_cÛÔ¾vðtÿ?¶Õ'NKWµf]<.$DJ	G[SF/IûøXç…h“½yë(ë=øÙ@°ÁþIòRRŒLF·ŸE×9:{×YUÀ–
117
 
118
VµrÞGddá0*ûN§UZqÄöaߪeÁ&ã+S¾šƸ¼ó͑}ð+ÜNa«©µè»?ÔóT=©§mˆïþPǹ_Ø^Ñt·øcÕ¶W5ƒ ä=»¢n0œ%¼W£XírÐø
šP’?7^ CÕ/äù¯hl2§¥³´•¤ž‘Z1…GäUZ%á{4`.PJ5U¬¾ÆqZ¸ùl“n4Å 4œ¶¿oÍҊȤ¾:nþT>ȗ¯gËó®,[~;‰ËZŠ/Y~'[þ#’–Ç¡‚^4»
þVéx8éöK¸W,;ۙo±¼ëO<•_^¸ÎçÊÔˋ×û\¡msÁ¢ZŠáâ1K3ñ館dWÿ³,ç¸SV›lgéŸW¤ÆE¹@õ²½'7¿2½ê^´V
Óïƒ&[É~Y+ûÃ7W24üå?Ê«¾Ú‡ªö•BàŸ
118
reload: unload load
119
šä5W|²é4ÔÊ_?îŽ*qßáϏ ރªó½žæY-ý¢`Xɘ?âÙýÄjjÏiò´%£TäT
119
 
120
¥|ž¹N‘ò‘5F–õ³js¦“8)ETZ±hVª(*[E¦ÇS&Ú±²PM’ü)ßÕäú<Äsj~Eàº-Ï`Ëų4`Ïæ˜O…d`µJ6‚WgÇGH³Å€}òå2­Ó	ÔdlTEtªŠsýFRžó™|¦	ÍWa0î7£ÚúŸ£ýiÝoU¸lÍúܽ´Á¬æ÷eÕ×ùðnQ»£g*¦M½ëjïzª|X\’¨$­—äÞÚïÖ>•,݉O	×þ†ÿüçšQ3õƒu[­^‘”¬
120
ChangeLog:
121
|r
121
	gitlog-to-changelog > ChangeLog
122
›º¨€]?AU“%
122
.PHONY: ChangeLog
123
âùc¶\šyûRr±Ÿrî»/g>Í+‡¨$Ä~æ9Íã_+¨W9ù„…O¹å"³Äs¢Þc÷¡Ì-g8¿¡ºÃ¾¿T™]¦Ðw0úU
ßÇp©‹Çó^Þ0Œ|}áHƒ5:ÊøŽx€Fiäÿ̜ íã(Ýi”5¦þc}Kïbkuâ©öí«WúáN_?ÐéÛû5ŽÁ±j^™ƒp¹3òÏö¥f†µ‰Bèâñ?Û;ÆEïÿOº7!>‚½Â7}ÿ_ÿ²¾¯gã¿ïüÏûÿÑûÑìîÙv~‘;‹ê&̖At5›†««?ýܼh·ÎNQ^«ß?®þtÔº ø_­SPS(å/¥øy“fJÔQ^ýéì¼Ó¦øãÇÕÖy½¢´ƒC
123
 
124
›Š9™$æäì3;@2íÇÕ£æ9ü†¼ÍôÃ	G±Ñ]=l\0búñã*zxî¼iŸ!(º>F—›Éx4Ùì¡ýTQÁ«ILàèîÁaÊ1(þÓ¯b÷P>F4Áù´3Ÿ¿”TMåÕÃC¼ÅíõÐêCV$2xï
>;R̊~ÜÛ<Š{3Ý{óær
û›€s6Dið)ýšÒr`¹||ù÷
´"B¿bªñj¯Gî¥7Y9¼ïÀÝÄ H\Ú)‰LÙs’~¤fC_7;€ÆÅ°/dÀ…굃»ç|]ƒ˜Mº)üP|¹ºò#iD‡azWÎ=­8¶Ø`|¤‰Àreqòâ/¥Ãwô[v¥rß{Ô|õîMÐ:}}öâ*Hcôö—W“IwŠ®+>ÿ	j§#±1ÈöŸÛí߶I/jº	n­«½š¥wû«+êçF2»Á´ß¸]]Eã$¥Ñþœ-))\ëkKQHTAãøggpÞè¼Pô€Œ°«+øçjyu„ŠÚx>n‚Y*Ð
îÙudµõ ¹Fþ¥,ÁØCf«±¢±ÊŽäõÈ®®ffü¾pzHðáap·ÅFrÝE[1pŠøËs±1„	%‘Õ“¤ֆüÜ8i½ªŽîÜÞU=·qä¦ûHd
,‰FÑe²éCn!ÌÒb°Ù2jåG|ÂLÐ@—ÿhùÿ[¬3Ê·òš”h8yÊèÞjŒþuì/!ý>ßÂÓ&%íÒø)}	dHßwÑd‘âÒ¢È;ˆ¸!7ÑpHÍߢæ÷…y”$ê/ÕL„0øK;†­:ᣣböŒuÝ_…§	y5`gSU$ mŒ•|^A˜Â¾*T®>$æÝÏ
124
ipt-netflow-2.2/raw_promisc_debian_squeeze6.patch0000644000000000000000000000225513213006644021025 0ustar  rootroot
125
Uà7X(ÄÆY]lüB-øe6Æ÷aÐòÌÒ¨y’xq£—Gµúš«’ˆ3¼ºª§Âþ½¥\uSN®É	9í|iÏ®¡5)–Y?
125
 Short manual and patch for Debian Squeeze
126
§E¾°ÍÇY… ¼™ƒÏcÛ»/:—ÒÕ¾j›K4t‹ÌØèߌî™+¢ê%x…ê"ñãÑO'm);ä…T}­®ÎƦ6)ÛîÝ˗Û[Ppi9ä©2#s¾•Ä¹GèÙÓrmb¡X,\Öþƒ‰™GÈ̑:ïŚ3†k¨ªÑý ›àã=¸qy:M)×åMrᲙYªWÕ¬Üwty£Á¯Xê<TH+î_þ øuûûh7	u%¨Çft6}
126
 suggested by Pavel Odintsov:
127
äžôÅ®Pÿ_<Ã2:qHÄFKœ½ëœ¿ëˆ¿+yüÖ©'{oQù½9`nPœŠŽr´€£E„xLGù¾C÷gÜÁL'O¯Қr_ÝWQ:Œ¯6ÒxƒWø1ª!V«çoÏNÛ·RVÿIþÿìà_±ÿßÙݭ׶³ûÿÝ­ÿÙÿÿKþÛ\ÇxpùTÅÔ1³¥Ö,J’'@û™^…i™”"²³OXœn=ݨoÕöòÞÅ:ÿ¿2Éq5íŽÈÒ44öûâ.žQ0;PP¢D†Þ°OéŽû›P!
îS„¶Ú¨É£ŸU”(§«oN߉7á8œv‡â|v9ŒzÊ!:_š`
127
 
128
}»”˜°Ìk¤£­ì0_£ƒSF7ŒÈhOj4¢®j‘(+@M©›"ýSÁwÊd¸‡±¢Ìf£°Lkûä%]ÇÆ\Ëð=Zªƒó8˜
+ŒÀÅ/­Î[S¢qú›ø¥qqÑ8íüv@ƎxpˆñWY„±gÑH¶;vÇ)ºîb'͋÷P¨ñªuÜêü¯[Óf»-^Ÿ]ˆ†8o\tZ‡ïŽâüÝÅùY»Y¢"i!£˜ÓÝ3èÐ~˜v£ab:à7èäš `àBð^ËK_taɚÜ-JFÓ%ódۙZ]
128
On Thu, Dec 27, 2012 at 07:46:30PM +0400, Pavel Odintsov wrote:
129
$¶¨wc ßP<—QBñÌäj<£“!£I6_J¢61¸|Qðœ8[ž¼T¯_ærzéÝě‘Ü\Î_šƒÄ—u;"ÏÝ^|á?ZË=y0’}˜ažœh¼çOS_º<Gò•˜øRg}o2úëö¦_¤9ì\×;7“öÌÍÆ7¾,ôGìK§3|ïL"X´{7¹wøȝ¿·ƒ ;Í4]¸ä;ŠR½i·{ùÔ´çbôD†=` Ë|FjA…0ŸÓO҂ᲃÛb~x+»d0¶|\Ÿ6:«ß	\í
•ebîyczbÊÈåUóîÇôòí°;&2œP~VH_!â!*%pWžX_£<¤ŠQ®ìdݛ›ãEV¾w³4 üšºÄeDŠÚ€ÛãØMF›³qwHnôå°ec®m®s¸5<òÄwÓ»*Ùt‘º—~±]ÅðY ‰q)Bƒ¦8Ùcykúó—¡da݌ÒDÔ«{Õíz5Rp»\oÉzómZSGkVšs8agŒfSøÿmN´£µ½ºh½iR¡Öq§yá/Íâ—Ó¨æyJ¢jÿÖ>ìç$wI/ºÅ2³~b|ܟ‚æÏÍÓN›B7ÓÅ$,-Úi¢ÔyŒø¬hŽ84ï“ÌDT;ï¨ÔmÎèüøjˆH•Â1 E5¡Y‚Jà>v†$*

ŽP%ÁÕUiF@0¿o€UÔåÐËfT4CêQyÓêH*TŒ{s‰·1ȶò!FpÜ:lž¶›¥µ7çÇkå•ÜxÚÒEi-«¡Z °á>¼€ÊiiMo]íW*ÅV)IFÉC¥Uûq«ÑF¤æleƒÆS4;ØøiM1`Øïkõ§L¸»Td|^¥²a
ØÒ5堑)éÇRçƒÍ­\eÖ}d?µ;VÔw÷ʬhrè8ï >z\«Õ¿¯nÁÿÕöë[»»kNÉu«(» ±¬2MÁ¤š[ÉÊ­PñIElíìì˜nô„†É…]ã=‹¶á¸Ê…I²YÔÙþ`6¹*D)6ûۗm‘Š¿ð†δDæ,l…†[ãø«5!Á8	Ò-k×1Ð(¨†öJ¡‚Öi«ƒÁ“„
129
>
130
åª\‡X¥HC潉ÛD¥Èã/,¢bTxŠ˜ÐÞÔátéÿ€þ¹q,J»ë{[e…׍…±/dË(][ÌÏ!$âó)Žn‡®ÖJ2$eÙjWnN .œ9δP©ù‰‘%¼ý¶õº#E`mÇÓ.nRpBv‡ç”,ãÛͲªòŽšPz«
›-Šjò`Owtv"Å.Æ5Yoí·:Î ªÛó‡u†!]o·1>žB÷é
130
> ËÒÁÔËÉÊ ÍÁÎÕÁÌ ÄÌÑ ÐÁÔÞÉÎÇÁ Debian Squeeze ÑÄÒÁ ÐÁÔÞÅÍ promisc.
131
qØ\ØÀ¯(Š˜‹ÑA1*=â<ȇàDÏÌîÙ Ò¿›™Y˜
131
> 
132
–„9±çŸyð5•$ãǨº`Õaßä‰-K)LR–¨í-ÐTö¶2”Ý‹®U÷¤‰e¿ÑÞ¨e(љˆ°àÖpg¢B
132
> cd /usr/src
133
MuŒGÈó;|Ë¢GEÖÂIå#s)²KC­Éë<…ð5™ÒÖé_?Zbì¨ùºu
133
> apt-get install -y dpkg-dev
134
šù»NóW…#À¦”½Ö/gW)}AgI˜5Æ«çeœ ‹í!hQÃìð$ã¾GŽS₎P@k°7V¡­Ú§G¯Þ½¦¸°ÙŠÔÙ9z{Îw<e-îy	¶¦N4R¥‘•v+âtý֋ÖùëÖ¯e›
134
> apt-get build-dep  linux-image-2.6.32-5-amd64
135
'š–´>
¤ÏŸz¶£íüŠ˜ÍípvM(Þ>Û$"´|~º«æ’&ç”"m;Kš¿ˆ46Ošš¿L2rICŠb²¹­xÉEãÿJ.‚è~BÇC›0:Y~“(µÆÀ­Àº>êµi¢¸ӏøŠYêDš˜åі
V¼{G	B“)Ùt䔽œ2¤aQr
135
> cd linux-2.6-2.6.32/
136
榒Ê\¬Y kHä[«ƒXUìM¹–TÑݜ%+L³’§}Þ:=>;ü‰«ÉHžy1¾->Ð;1dÒyf±§$(T&š”¶æ—†x‚Åj¿S¥J^P£[£Ð\liì“Q:!
136
> apt-get source  linux-image-2.6.32-5-amd64
137
ú/S£X 
ØüŒF ù€ös	Ë(^”c!	Ç°{£jÞ:ðk…&èr|ù¿ˆ·å9®½ì5Þ¼¹Ðz~ðþ¦¶Ußqøƒ‡Wfƒ£A½LoA£Sq·lVÅ0¹ßomy5vÍ®E²²ÕYxb¼Å ¨¼™¢ÕfO2Ùr*\üB@äD·qÔwZ6¥öR.@󺋘”¯~?°Š–¸Ó&é4ÏӒŽsÐgÏߕ
137
> 
138
"ŸVr)¾†Î(Ȥ·¬lp>7S3v@pxöî´#Jµçϟ–=9ÁI£ý“(™„ZYkÛèp!Dkñé]qkAA^³«°zò|ÁƒšCgx§Bv
ð•|N°/ìùK`¨ODÆNϗìрCé5•
8-yošö¡€GdéGî@$
138
> wget .... /root/raw_promisc_debian_squeeze6.patch
139
=ùÃzÃI¨¢BÑiöý´¢Â÷u¹ÙµÅ?,‚€œ3Žâ$Þz«‰2¦©Á㬪ª-X•ƒFï/gÉÀ×[X÷£ô1º&¹êŽ¡TŸn”œ&ÊÞîR4TlœlRõ¡‚výÓÐ*õÞ"âžž^FW›Ô|j€iztÀʝOmˆm<ƒ"¼&
139
> patch -p1 < raw_promisc_debian_squeeze6.patch
140
§›²ýy|ø¸¡BT%VØ`ŽP’–=±Ðݧd·îe4¤ˆK³dFç¼Ô+ªÉ¸–Ø°?6„fæ@:-䊺b¾°‡ˆØ˜o6kD”RM…Ò£tûü²xhgAqÝC
pfº®òdöŒ[I
#6¸+‚!u~BC>™M¯ˆ{½çÀ^åÀà…å=08áKî.Î*$TÄÃî‡ùŒ$ೊâ5ҍ')›áÎŘ\l‹YJšx楔Ÿ˜úÊAå?«Ò«€Ž.&ý™r Ë¼1c«ê©¬ã<›ÒWßDÎ#x‘”@LŠ­ƒB$üÇ|€~7íBŸô`6%šª#H*qÔsÓ}6s ¹D"/Oà«<o::h'„L`,ûòø˚ŊHÎg‡s*"ëØ@®VnMò¤).ÃڞڇèQ2Ãn€ct»›ËxÆÏLF4DŸ(•~á9|8ªF8¾‚¥:ˆúº3Ïè蒵¦£x"ÑjN̞‚&¢F-kòy×ÑÕuðqÄì¿ÅG4ä@Wcù•ŒF
140
> îÁËÌÁÄÙ×ÁÅÍ ÐÁÔÞÉ ÄÅÂÉÑÎÁ:
141
E஫!ƨ¶/Äé»ãcBқM§ˆ˜€T>*«ÞQúxó›ŠÒ ðd‡!úOo@wöuæp\Θ¯˜V|\êöÇž-ŒBÏ:\¶`C‰Ps
141
> debian/rules source
142
NfEy |VS”OrØUCKëJHY¿ËeQ¬åeaˆÊ%Ìb¹,cŽÇc}`šE´Ö	³wH¶.!µð[n¦A쟾ûUÝúÀ*tÔÏÅO͋Óæ±¾ªWö*usÒí`ÇÑ	c"L¬ã—­Ã7.šÁ/g°DX*Ùâb9Ò²ñ1ö¼Šdçѧü]PíQó¸ñ[óh‰êË+öì”ÖB:]¡Ô©¥‚wσöo§Aãð'±õ©Vw2`….ÚÈØÚõ,IØ&ò|h«BŸ—êó >ŠÆ68~.ßÍÀïÚ¡'ÍÎ,lG¯É+²½‘¦Ùm@ðÖ\ ªÚn0/{~®/Ө͜™ØB†ÎŸ@R©Cbáqø‘­Ì¬±¯éxãÓDΚìNςMJ …Â(Û>ûÐDM%<¼QNI"„ü¸º9:=îõñ»öۊhœñOkOCǃòÄ?®zx§Únv‚£F§lLãBÃiÖÿŒ*Aù
142
> 
143
_âÜýt@ÇS7;+°G¤Û*û[û~·YèÑß¹ÊZ,˱Ø]_Q0àÌdNIÓEd6«÷vv/iRÇH”48øUÆQ‘Á+J˜ðLɁü¯ºJPlC‚îTï¾d‘óÉRrSG¨’¬
143
> úÁÐÕÓËÁÅÍ ÓÂÏÒËÕ:
144
9±ˆ…T{Jc&sÄøɓòêÊ
144
> debian/rules binary
145
~àÛwúUÖÊ ÷*4cªšª¬D»¼—V(¬bÝáÇîîÁâ	îÁpC¡PÂÔ^<¿é“¥%¦É.—
145
> 
146
… ™]nfãq=9æýSNµçƒ.¤,¦”9ê¹>vûæd ãùÃ%儓ÚYR^•ýÈ·Lú²{zc:ëGôHTv(x…3V¾.âï¢eÏ:»*!.|ÀŽî¸ù‚ê9Pn€ÜÜõ¢ŽU!
146
 
147
'ã¹>Ïa|¡³$R‘+ýRŸ›–î~RõbË_ëKé”çâ”N˜ÚâÑ£U6cä ¦þ%ïÅ¿¢;™ð‡}^Ûð¯Ü¹ëŸMJ™nP™ÿèêþG®RnJ¨¿4.N[§oÛ¥}ä«ÇxDϕšË<$ûa¿*ŽÈa-Þçb
147
diff -rupN linux-2.6-2.6.32/net/ipv4/ip_input.c linux-2.6-2.6.32_promisc_raw//net/ipv4/ip_input.c
148
òPݹ˜VPÍÙËE¬ßۖÒü6ð´Q&á¸ïP*R#«R2OÍÙfêÅù6Ï⡄ “ú¹¥ÆÊh–†Ÿ‚•¹s''Rxj€Üó¡SµÝKCÛ&ëálÀUÍ&®æt V¶T‡o’»qÏO:’§§é¥J¿Ì"VÔÍ¢„ÛÚiÜë¥ÃrQ?çÄt4÷¦¯/WŠºûy®±Œ¬Ü½uAOåÊ\m
148
--- linux-2.6-2.6.32/net/ipv4/ip_input.c	2009-12-03 04:51:21.000000000 +0100
149
R,cf•­
¾aJ®qgi£R[~tÆ\!‹ÒÖEl²¤ù”Aǀn[¤›•\“Êf‘QþW¼v?à­³eu³&öqËaó€esn⛙5l
pºì¶í=è¨0SÚ·ü{‡#þt›KÙ Uå²$틥FYÕªÍínnxK¾”=V5ŸýìBl¬îpõc´äsß]!íËé­ ŠdLB{`õªºQäŒoвL^kÐÍ?ªÐx\Þü¹gՙ»ÆC¸)zü[O’ûJ¤mt¨‡Y’l¼L’`ÐEx¶ýB4^ƒâÙìðÒ寏?º’.ù²ÊI‚çŠj]‰šÃÁAΪêÿ÷ÎôŠsÚ:ÿë»ÆQ	°9°AdՄþ”°éub@pm*#}z‰/jÍÞüæìQ{öü
ڛߢ÷?íûþÿƒÝ>MúѾ'ÛÇk{èØnYÐÚò õåA·—ÝYtwyнåA¿ŸšaŠ‚1ƒåf,^F²5g™oƇKN íJ­VÙZ4ŠfÀ¤µc³Æ£R©x–ã•Í„p[½\9Ý!K̑BŸ´öz–$zϪ}ï^d»%Âï9ŽX  ïۓÞÈÖÄèLji kö/®õô:Gô0ây9¼bcÀ‹ÿ½(>”†‘úZÜÇDmYÒ÷%k9r~qv¼n{6ÀWmÚT9§Ö¤O´e?À}±ñé@|±ŒK_7Z?—>UîÊ¢TºƒÅ¶ô‡˜ííÀV=áÅ€÷ã ݖ(¥"@G­1-Ó7 ã
¹Fùö`Di½2Ö>ap7L¨‰:ñ!C¹¦r£	^”è»L‹aùZ
º6üG…õÒõ[{Gz€ö¨Öiïx(SymDA¯宎Êö€k@10ÿ€¾ûRƒ»þu2
ÈVÏf{Z“ðiÞ
149
+++ linux-2.6-2.6.32_promisc_raw//net/ipv4/ip_input.c	2012-06-25 19:13:49.000000000 +0200
150
§R¨µ-yÇLô%ŠlÓf‘V¨"ŠÖé¨åÑt„Ï3ðž
0¤Õqœð½éÊØɦ/Õ÷åNnҀ0©lÀùxñå˜YHƒü€qÑuXIŒ†ì"z—átªAtŠD#7¦}2ŸSPN⁔æÀ -…’ÃÄ6+‡‰’<ìŠi÷~[ÝdgëÓÍÃ8IíÒøm•¶³uçÓÀÚù:vá@ Î)àpjÐ	.Ú4¿ŠÒ<J†ÿ‡3ØÕë¬sº¥ÜlÖkš2¢¸TâËz…!Š}¥p»qÂGÉÏnÕûÙ\ºãł™rš”‡™MH¾.Mˆ›…£QP
150
@@ -383,8 +383,8 @@ int ip_rcv(struct sk_buff *skb, struct n
151
³
151
 	/* When the interface is in promisc. mode, drop all the crap
152
Jųs¸º¦ŸreL?yÑùJáxšææ²
152
 	 * that it receives, do not try to analyse it.
153
HǬÒanQd6¡ûO2†¾Â°¾'Ö·:A‹bä€L’2_­&µ­­ãc|¼¢;ÅSŠKx闪V¸’7½ŒÆÅ[e‰¿ä=—µh_W‹e^Z–ÅÖ62emsžlqc8¤*V5å;ClÈ/´ÖÏweÓ§¯$‡[ÀIqÄ^>•»r©€7Ÿˆ¸uª-N‚–<:Œå4:Fp—ÿXN²1oCþÙÀÿ–·ÿañb§˜ÿw5ÕOgÕS=®s¬™‡¶ù`OÌäË2ÍÎ&9ò.¢|âlÜÒ: g&v½óÇxÏv¢2
xÈpÁpŽìl›Åb~=¦dÈÇVñÈX?²U¡<ÿÆ;4ð‘ZŽ£gQ‘—:ŸÇ”ö–jôÜ (Ó	¹£6鼃<;ˆ5¬àaƒ§â¿f¬õH£¶¥~gôwEžs®ðàL¥VËD™=Ho¤Ã^êÉ̆C_Kk@¬tzÍJ'ëØV¥êžÀì+`¾`OX0ðï
õe¾G²ìν@%ùŽD¥:c%A¨»‰‘Êο³™öÔ½ÿÇ5‹Ì ã8<yÂ×îù»Ã€ù&’Ï‘Ô*fëÕek/µ¥.ð0{a&2>xÇÄMÇ¢cÓ¹AÜgÛñõ›
³aùۏIzÆö)`n¶,òFSœ?‘ùæ%^fDz¢,èñtL^òÂ2gÛËã&ïíßV=ci]L¯xŒÃàN{ê	ÆÃä`ÍÛ6ZÈx|Íï•á¨uÑ<ÄWÖ
153
 	 */
154
¶å@m¿D–AkÅ~$بÛ[[Æ`S‚ÃaNõdNʧjkøðŸÀd~pr~ܖ@OF“a‚Ÿ­ºI‘hñØÚà¤ÌÖé:W— ×E­÷;
154
-	if (skb->pkt_type == PACKET_OTHERHOST)
155
ۘ°ùêEç
155
-		goto drop;
156
}fh0N3
156
+	//if (skb->pkt_type == PACKET_OTHERHOST)
157
hçmK9™£Ç»ìešó컳‡ýµŠ~Fs	ï“õ“71Sö-¢DF~t,¤Ï‘ò@Jw\ˡƀ7^ÌõìlƒwÎ*ÊÖË$”ŒíÇÃ~E„<ì—í»V÷u›û Ì±EÙðØ¢TŒʼb 
157
+	//	goto drop;
158
oGw¸ºdßGoÌWUœ¨W;ö~"ól•sol9Yi#åÍé‡Úz˜“	þ–k:Ñ»js,òÏ<4)¯”6f™t…!%Qä幃š{DÔ
=2Aö*’¦ð‹3lÝQeÛi¥ÕN¢þÿì„Èì!D–5,ÿmϒVônÖFŸn+S}­?ŒÏ8{°°šÄ§<<8p*Ñpt¡é‰ëüå²'Yy÷ZûОCÜFÄãpw<W5ÛÏõ¾Þ3ø/‡µnŸ§H<ÈÜoûµi>Ò~/aéÃïNûüY]Ëèò{;Rét]f”烩¡@÷óñ°%P¡úŸ'ƒ¨/2êÆÞƔm; ¶Îe’µ³‘, {98ŸCؑ"…ö®ò"šyқé>UƸ/tÀn%MVȗ)Ù¦*%7±„äõ¤·O6Š²5çlG9Pð¤‘DYòYr¾%§úuòC|lMF¯ü†€˜”=”Cdž2/ 9ûø¨’}cd‘ë,Kw™â†ûø1E{rÖ8»~{™îU\®àÓ"HûIY¨	6ø{Øß
Sé±ïö«Õ‡ý¢ˆFÐVø3£?xZ¼• L[ûïéÌꃭïY'‹ø©wQÖ7l¦J{ìYþ©ïàai&½Œ7hõ“I²·UÉ~҅[é«RÿÄQjY¼|‰z¹$É6	¬ÀnQ&ŸÊæRfȝ&¬¤Á(	{‰µõToYÊyЁʇ*ºjùêÄ|Ê÷"ß`JÚVŒJ%ñH=3NJo»Éõ>uñ¡ä3â8ºQ§”ï及ÈþøPÕØ3:–70+è°mk|~ôNŠFK R$y3,¹ãsæ‚ûœu¦™9Ï´sô»‚ÜÝùÙ5oþü3÷Rá¡»¤^INóôÏJAXÿ0⥏ìw4'ßLðæÚӘr ªq{%jøpB•™$
158
 
159
|’ˆÝ¢,ßŌu'cžTÌãû¡HÅzDâo0êw,	yΛ Á7.ãð£xÏ]þ¡"hc p H‰×ûµ—ÝNùr_<'n¼ÄÛ§—°bÁzâ¦ï4i îÍà:¤·þU“¨y¸3³ÿç!Á0¿8y¥h°2›ÕЭÞš{çê+söϾæ²vk!·føÜíw_æ¹£so¡`
159
 
160
Ô·ò×Oö͓œäÊÂ}<Ù[ò֗øÕèù{öy›vy^½Ôæݧ]âú¹QŸ}߬|%ç8×Esî‹t–ÅMÖMºBòÞ+-º-òÜY÷?™›ŸÜÝOx%s.¡¹Äs9åîB5¯Ð„/¾ùݤíñ¾`ë‚‹ƒM=râ˕,±úŸ~ÍF 6§ÓxŠGM¥å+lÜ­æüD•ØˆªöÜ_p¥Zxyš™=þ;Xë4c‰«UgM²vä4ý¾áÍ\Á]pyrïÛ±Â=•ºÆ¡ÓÑAD/@ð§ÔÚ¬I\¼¯ 2O†ÐxÇ¿ñ¤ˆ~±›Øoyÿ5ÿNSƒyîçÜÞ_λyÉÀ¸¡op¯ÒMñÀ8Mô~£€Þ~/u9罊!ß
äLæòºôÈöó³b]ù¸—o¢€}-÷Bsùá¾{H/÷A1IA‡±,Èa×ÆþNð&øm0ÎÊÖ!Íìo¥9ם¹6/U6=!,Φ¿ŒÃ2
160
 	IP_UPD_PO_STATS_BH(dev_net(dev), IPSTATS_MIB_IN, skb->len);
161
Œˆ*çz|™~š¨~š,ßO,„ñ_¢´ž»=ޕ,ê!®
–(_ó%Ö³‰ürŠ;aRØ	ÄGÌu9N*¾“2vü÷läÎJ_<ËÞ]™öffXzu²¢<Ëa:¯¡½°dûwÓҏ¾é‰à5^—¸)3tàMé0Äw…
õN]r?‡ ß¡pµj}VדÇô<'£Õ$¦æHf鿎©zIðéÊSج¿käËAjé“‚“ÉOëʓ'ˆP='Ôý#§?ۋdL£·ÜGrúÎ<ž„úÕ4ÆãÔuúSў,èÿuÞXEã+؈RiÌ«ØwðÚßÀ—U¯yð7«Ó18öÔj¡Ãbìî7Q¤b
161
ipt-netflow-2.2/compat.h0000644000000000000000000003557413213006644013774 0ustar  rootroot/* This code is derived from the Linux Kernel sources intended
162

TããpºÖ%gÓ¡.L¶:“±·1Óð7¦
Aȇ7*•>tv)z¶$_&TðÑú:uóîA©ÓÉÿZ-“u}[h{q
ì3^8Ô3(z‡™[FR×ݙH x.T>ðTý§*î~eÅ3¼'Ø®©ë¢ª¨Þ€\W‰uö`E=h|Ãýˆ”[T·¥1ü„œ+à›ìILîV¤áŠÉèÅSØÃMb˜Ýèº'Ž´;oU„æyÂâÒˌôG®ä
162
 * to maintain compatibility with different Kernel versions.
163
Ñ©@;0u·Ú©€j@Ü°ý’‘~(†¡„L)ÇÇÈ ÀNÒ;W‘«ÀÕ?|3b½c·ŽïV½mta	è/³ÜÃf±5¾¬ˆ’Rޟðǀåæ
163
 * Copyright of original source is of respective Linux Kernel authors.
164
º¡
164
 * License is GPLv2.
165
Œ¿.é8m”è.¾}¢ÇWÙ\z|éT
165
 */
166
ì¥ä$à2»Ãì#Þ)(°‡èV-ÓgA@‘=&w™^óT³Ž-vxÐ×µó&ÇAQÏcŸgFïn+eŸxœkþQè¡·.k(ˆ{¼cñæõyÀNÁô"þÆGm]¬3ð#é"´§ÑxªUêéMîˆ3Ææm4Šµ"ôÇңހïS©£9-ü"~¬Æ:A'(ÑT3{…<{㨨\ìu=HôRz@ÊÙø”›¢£‘?/Ôõïdˆû›}N”+b£†á"ä`±‚ßH)ÈîøCh‘'
166
 
167
¹8¢)Œ/ÈktäÀ4Q…ìêoJkcÞM•Å)0Îtå¹»‘Á r…¶÷ŸÒsǁîÄç–S>úä‰c@âx¥\—_ˆGO²ðV'ÑXíÂ)ÆQRÀ<DÍ¥N· p¤-ÖÒUIÔÄ\žéHŒb¡àã/¤@ï²4äÔå\G­h]Gò`u~JKÏÅîÑÆsèö‘;Y¹$“¬žÈ¸2P±ÍO|Ýt_vB,‹˜)_˜.1è…Œ%áÓòæ_ƒv§qÑ	:g?51ºvë’aÝ
167
#ifndef COMPAT_NETFLOW_H
168
¹™a‹eÓâçì·Äi1®NC•§f•ˆ=ä	¶`°ð`ÖÆK9J
168
#define COMPAT_NETFLOW_H
169
û%d…$Z”¶¯Wm·Ú£@xÝ)lY§Ý)¾ó¤³Mº¥R©$bôBXba8L(D5Ʉ$®ˆ–À™+ûpL¯A] ï•%Ôs¢AËRŠî“IˆЀ&Õì2´néÙHB‰í0@5Z5Ä^Ìý£Îª'lI9IÙ¨¢
169
 
170
ó‚Px´”õáµ:ì~€ <kÑ3'	?ìnbqV£ÔöSnUJ†‰V'Õ,šLdDˆô¼”f-”§«ÄEGB~ìNûL•Ù°ËÐrs-^dªà'ïŒê11GŸ[ŒŠ
170
 
171
å)F_›žšåîëßØ(«âî<„QºV‚@÷’în«Ÿ°§}=cöV^þ°§»ßûÏòI†ö'O|ÔgíÑ9Ë·å¥Z˜›ñd±‰¹ôáËv~$'ÍèÒ'LFVܤà›JóÁ
171
#ifndef NIPQUAD
172
2Fíٚ—3n¿ç¬ómÇ*¾e¬ÃW|›(´œŸ\¤rò»õIvÿÙwì®
172
# define NIPQUAD(addr) \
173
Øí~T‰×|GK–½³„)47váûÉ´W鑳…´ÏDÚ«PûBRCÃF®9†	lHÒHُ&[•¤ú7òòu<Y38⤒ö&ƒ!^'qxYJ?
 ò›KW-"MöIZVpaã»Þ댈®†Æ¨¨³®D*ýmÅë¤ÜÒï}o@ðiÏÖÎ'ñð“¾)×3W<8žžÇ ˆó^Y™<xà?b@…Þœ(ë‘2º|‘%‹Juó¥Øcœ·	âáu¿ÿÓ¶NŠÂjDƒž•ãwùÀǒKa%|Ó,Âéòõ²¹§úÉIþ·†~Ë4âë'›Ò§‘3'èÚYH»WèÅ?{ùûÈѺ›Sûà7±¬âª1®/_=A=t;µQ$P`ÚLâ²åƒÂû¦+Ï9Ù7&g¸Í" ëÁ'?³&­qŸ‹9?ŒkƒÕñÝae±O¡~’ê{
173
	((unsigned char *)&addr)[0], \
174
¯3.|æ5i¯¸M{=ÙëÇ¿E›4Á³4‘äþPùAÐÿÖäÞË3úŸ*êÿó\€ÒÛJëMäÖ̖"݁’‰ÂJ¾­UøE¾Ut<ÍØPÉD¾~ç$cG™t	ÎKEq>."ùÇ|™ø|­µ3j9Ù&ýwå…ðm9ðt Oö5]éÓ>9Ÿ‹©TÔ6j|¯ûÅu½©ïM1WõB}H93ºû#s¾b§óƛ&˜ÁNśs<1ãƒ2ŽÐƒGcìËH	èoÆ,âÍÓ³“æ	kÊP<ÐmQäÈ˓Gù‘¨dL
174
	((unsigned char *)&addr)[1], \
175
óM)ëZõÙ*¨"
"<ªÎùîxiÿ9› £p´ªÞvÒÙetu’žG¦\)åuà2þÑJ-¹\/o¼äÎãÞ^º	¥d1µí±ÎfyAò\â¨ðPežœƒûoæÕªÓû贜qFŠ>‹3žHmpy£)rh¬”éÍn²;¨–¸3½{k/wÖ~õ½WndI<ð
175
	((unsigned char *)&addr)[2], \
176
[u׋“'°Tq<Eíq”\—Š|ü½|‘õQ¶SÙAe¬9«g¿×WlýfI\èîõžß	aI©?oê¤ñ¿Î.ÊâÑ#a>qÍþÞ$µN!	ðÖ‚”ý&ÈÎCîÁ³/‰óñÊ(F¿¶“.‡ÎÁÈ-¢/²pnß0óÞ\–°ˆu:Ùì¿GgçÙ;eÙ¹;Á´w[òT\±º.àðí{ØìhxYpG†®É½ðñ4B_¯·¾‹”ëþã£àqÉl»Ž·ôÒ©²¼"º¹¤{ž~,.»	Ý:¿ÝIwŒñu`#Ô»ÁÆ#Ädbd0š?͏·+ã	þŸ¿²h
176
	((unsigned char *)&addr)[3]
177
¥ÕËÚxdPûËæør£îè,Ãa‰;"óNà-ÄP\¡†&ŸªA2nÿ'äªQ@„›”ë¡x.v‘‹è[QðÖ®¢*¢õ¥ëž‡ÑM8¼"‚(A/™J%ËQ†2g¾9lÊÁ
177
#endif
178
A¥q@¢ˆ7— !è9Ž\¶´Vh¢4v<-ÄւäÁ` …Ô^D›¦ZÓiwœPè	<â¸Ñ˜ŒG>‚eê«ÇÐ	r8J´Ô:?|E]T¡èîÈ"ë")ÀN#Þ×ÂG<\wDz[ÍÌz¼=;똓óF§túäWç,hÿ¼SÁLÔØA¦5ƒ‹³wÖé›Ê½¥©Ž0wp›_Â9Tq^Øà1|EPOѬäoWdÁd軺¢Hçû‡%ÏÓ¨?!EöþˤÈíÉøGÊ2D
-8ª{X¤
ü+…Ì\™pËíaѓ‘:$d2’‡®þAd¡ìÁgëSòÊ&‰Ñy[,¤†ÔLôøˆ}MœŒmU’€ @n˜¹	/{ãAU>(àÜTÑü¾7Ÿá÷\Ž7ð0u¢Ï-<Ï 4ñôÎ~HFÉÎ+ÝPjÀ±E÷…ý™•Hsäì:Ë×lƒpœ_ðàdÄ|:"uÏ+RKDmÅ#Ñzý:8>;;Õ8ü©L>ìé?b'·–Ã8ž\vñº°÷Ù,؋—†Œ,͑‰añ?œ0ez=¹A¾QŒfC˜hxfS¡aAØ썣£‹àä0hž7]8ô
á#ù×±uï:ooÞO¸Û̒áÛñu<@΅a
178
#ifndef HIPQUAD
179
Ø+7I‹
179
# if defined(__LITTLE_ENDIAN)
180
	s9).ôZGôMºwçªYïÌD‘(ÝN›¿vÞB½=;71ü“œö@4ൄÒQÝÅkâ"¬å<.ÿ´ùbÍՔ¾¦`ˆæIÊ•îÏHØ¥\Çxª‚¯eÈÒBÅcçxˆ|WSEÆ_-T_1ÅôÀ£e
180
#  define HIPQUAD(addr) \
181
ˆX`êÄ­ç@àË.۝†GÔ]|	2ËnàùeÈå,ü7a8Á¸
181
	((unsigned char *)&addr)[3], \
182
½ÙP)‚X8 #P	ÛÈ÷pÙa›Cñ©¢´Ê·…Ëê}r䞠ͩžÓ¾‚¥¢’êU©(•xx]f§Ñy_û@÷Úxº¾]ö
)9ì^
182
	((unsigned char *)&addr)[2], \
183
‰b)šg‹õ'r™+	Ñ0d'_½ž>ya1Šo6úûDÚ_xq¿F÷ÚûwÔ½|û¦úųiLž°Û”°T'æ0EQ]	¼ƒ£^+ÇæGƒÀ‹Ã«Ý¡|}n’^sÆÀ!8U>ë,˜H¡’êFS-Ÿ×)¾jvÞçA§ùªìX7…é5)|!—[Z©pŠ«YeS­¬@–å_ÕSfŒ={r‘n"€m¼¼æN’w€¦aª°8OŒ¢f>ݪ×þJ‡E¹£²Y\LÒü
183
	((unsigned char *)&addr)[1], \
184
1N,lÕÿ\àåLðö¸yÊ
¶ï+WlJ7^Póô†‘;
BŠ4ü¶çö³(‚¥Ž»åñY<@ú'6½Y‚‰{ˆL]e©6c4È'B6“CuK#E™á¸×$¸Tà[89vNCŸäúC‰Ì=zv4o%‹¬«Þt'l+"(Øgýë¶Y S>b/¹´K•ö¬ó¶yñö¬ÝÑ֚r—b°¯éHÅì2GZ/~ð"‡D+€äTg¾Pԏu­Ü•$× ´+cV²¬_I3¥g
®–I-;ÓãzϘ‰’}ÚÑmˆxˆ+«.	7‘Nܦݏ²$ä8ü¨ \îQmÙ®n•¹Ðu÷6DÏ:„]¤]Þ1N®ï`3I]DÇÌ%
I€#žçq’ÔQJˆ¨trÒ½•Q­Y Û¤½¨êŠX5(Tl6†z¯ ݺâ•+i;öÐX>ä0vW“ôÎ35¿(\ª„SŽˆÏIBV#@
184
	((unsigned char *)&addr)[0]
185
$×RLë	¼!<"·¬CCáB…øe¤×–—9eM¾ïNwŸ¡Å½M0Š´ß{!ö2ô|0	Ѓ¡ÛájE“wXi߆cevçœp`é`ؽ‡b¹F誢 ¯°^-¯–XUY%ioë²d­M†+m

†„²#3”°øÆK6I~D’qX"`øÿ6E/—ËWä‰<X<Js4ùšO¥ø³¸SÕ#}Š Íîqë°³Ÿc~G´·ÎË0?.§Òe/Ú[Xèç=(¦ÿta¼/
185
# elif defined(__BIG_ENDIAN)
186
¿0{)+	I¯ËJH(U™¡iß\)º'ýZiÅU@‹ü/ 2gož/÷9sù·_¬èú.Åí•L!³ÓœðêòLjvã°2à
Ɯ„,k}­¨W:É5ãòG]ÂВ€ÏÜÁvG”,c€(CË*.¬ZÉpy5ŸPùƒæóÀ}¯èRvèd$b•Õ”ëeŽ79Ð2qÙ-ÉPwÔVçY~4–ÕÎ_p	:ɹ³Ì+4qEŽ²¸ÕMv'q+÷³Ï·³Ýeó‘ßóWû·öa瘆û.é¥Cé:ÍMÑ}²ßk2…û
dÁü/ ÷b~òžèã4BO5¯š¯Ï.šõ½íz){§=©HR–fIÈ&ƒpªÃŸ­ƒä›»ß2üè0æݵ¼o×$ã8¦¦Ø˜D’Ž ŠD‘}3$VI~ã»sgÏ&'¾»
{¥GCjQ¾5Ü¡èe:‰¾».½c¡Jœç+öl£yÞ¼8±MÊí°Êôoù‡ý)©_Ú)€¥ÔìsYö—ý_=>ËÐY<r….2è~Íz—cÜbHcŽßqÛܤyÚáSB XɀIš±:7
186
#  define HIPQUAD NIPQUAD
187
š$Ÿè«s~ËoƪrqŸ÷•ay©8˜ëŠÁeY]âÛòì=AlÞ²ü÷·‘OZ§AûôèÕ»×Nã2y(¼raDËß6A¾¯WŠû˜^9Ë®›ï—>g֒¦™ÇÆþ¸€k—ÏžÀævôƒ‰™aéáôkqQ¼±G„%øü£¿âOY¹ðï6¬²ËôuYîòãõ%7d&vðù««ixõo4FØ·ôڃüqyM®<4‹ÒÃ~YKáØLpÆ' P®ÈªþÙ,!‡×"¸d/G×°ùW=çCÿµÃæhµF¡5ËáâÕΑóŽZüme=b{Ãóù³(ûJquyK£. \lç”/»”[dév’N]!©¼&ÿß2ù2ôþ›N<}EHŠå²Öf0£;î«×/Ó£àõñ»öÛ²¼¥òW\yKènwždŸwÉÁ²a™VOcU6Pý§$;ÅTFïjÂDO ÂèX¢á¸:)øÿ§±`—ƒ¨}OãÕ^Æݵ|Üë…Ñž¤%Ì×»=\ÖÝaÖß¹jÓJÎcºÊù²ô:—™•Ö›"{µal¼NÉ1ÙÿÍGŽ/(̬T	™¹)“=3Ô"ÿk§§Dþ&©ÕÏ)Üÿä°f†Êü”3DžÎ0­¦ö†awdÙÒJ·¤Ä?5XNJ2Ï¢'÷Æò)IåI·v‹	ØNš‹ÖapôúX¹Õp,êgÉõ¿ÅV—Nü»C9[ï¹ÒßR0‘o¶ÄÏÛÏÉç³è„ôr@zÀbmíÏ/¦†šò–æç<%¹fœÀ,ÏÉmw8MÊkJø-8kŽíᲄñÝ¦y„Õ9Ç(êŒù߇»ÈÌ2(¸/“…Ó“©ãz¨ÔºMØÝW¿žé_µ-üyŸÑµ‚4)³G`áñUXVØwIþ5`¬ýÊZ¨1Úg{îBÃwÈçáºyÑlù
»%Ô©@¸ª@	™£‚šÂÑnEÅiø7Ÿš®ÿĨ¦×ðP=‚yû¿l?xà”“Åü…Št;÷VÈô“4G[×LÇú2™ºúLÁžg-ÁꕽJ݊ñvŽ-Oš½Š(ÇÝÞ*}ª¸*†¦dŽg£KÜí¶¢?FՐŠ†(á:_;”M·{=Ä.ž<½áÉì#	`UßãNÁ3q©:ÑCæroÊB3½G‰ï?ðu
187
# else
188
³ª"q–-׉=<®bàŸÈÜÚÛÙ¡dQLx”‹“¶‚þ݁ï0W*B¨‡VT5ˆ¶>l}°°ÃÔñ¥â¡'ëƒcEžØmߜ&ÒÖB@ÿŒÚÕ]Ê"Ü8÷!ù+"ƒŸˆX¾.÷~§¸ÇõÑéâ~wNYýädb½¤yŽ¹™>Ÿ/éüD2çg‘{tè'9{¾è%Ùs‚*I–†92•»ýE4*¸G“ô§9ÉÙ=U¥t­?][V¡.ªÐŽ®¹¨šÿ„~¶{.¢Å	àù§i)ˆ2æ
188
#  error "Please fix asm/byteorder.h"
189
#»€8ìžtÙçêÎÄ(ʗ—z|r·ˆ@ë0ÐO¤}Z藋îqì‚YŒÚûÆ(Z(it”ª?1¢X^†·ª†ŸÒi·F¨ãqh’êVmjx ë=³¨Œ&äO|¡<rύ
189
# endif /* __LITTLE_ENDIAN */
190
:Ù=[*XÌ¡š#üAår„køO–ÜN&3ôâÙ4ÝKõÝ-/Ô
190
#endif
191
§qœÚJ¡Ñ;··Ë¹ÖrÙL[www)¡w
û˜âS<•l’Í($™óšªÒ•9Ñ×ìT<´Ý“.lºKÖwÊ)!>õ¯îUë»y/ŸXrÒM¯³Ø0Í«]MÜ}ÆNö¾µI
7!E‰îl54>Âi“rß`Z”séÀTd[LQȁ']‡d\b&7ìõ6 täñ„PàÇÚµ—‘ÂîTECÁÃXéFF:Ûòºcc‡¾àË9e‘ä"ñüaÿ%Ÿ¢±¤òÃ$õ%Ï:•ÝŒÌÀå‡DÛgо8ý„ü/ç¬$M `é楕>&—Æ1쀥ý8lϓY­EC~G¯£ÞµÀʯ¦Ý{@À(w""oEhNÞã!Ñ:<9£0¡° Cüc¢WS{è±Bn¤ãõÆVöDÛ¨_ÎRB¦<, dŠÏ¦á0¢9¹¡½ç±;V´bŸÄñ¯˜ÐÂ+Œ@s¡—{êMõeßÐCêp¬=“ªåÖç#‰Œùƒõà/×µ¼
191
 
192
òƒ~‹¦ØÞuüRîõx9^f$^i¦…»ub
192
#ifndef IPT_CONTINUE
193
ýYä…àᚆè|ß”5ðAº£hxWa³ £7“Šhó[µwGçè£LþuÙ`ÄbÎæŅ‡7íš$—J×2ôeÛvIG½èbË6’®çqÞ¼°^LdÀPYÝx9ãÖ±¤rÊäêþ:ê÷Ã1;\Æ“ß=:¥í‰N[n{̧iÜ1rzÑ|ý®Ý<ÊãÑcC¶cj^aižtú­	m	Ék¾Ù“Š}«3¼–höà¢C±dã¥7%6Ç*e8K¬—™¥ÔMØ1DYn¤X	¸ñ•vQù°_1*Ù+ÌÇx:>£×haÔ9Ry"¨fùz¯	u½ƒno¾™ƒ9Ž)yéLü¦ý4e
s);	š(³0ž•ºëæ
193
# define IPT_CONTINUE XT_CONTINUE
194
w功n]a‘%W4!-s6e@hÍs;lW…s}6ˆÚXNbf?†°.”—8z7‘¦”ùòrĬGtù@Tì|_¯O÷ ƒ"ä$‚°=LªË’¤T'”À+§IF!æÊd{­¼òÉXFd"
&Ù:ÿË^­H^œìç¨6\ÀڙyÖ¢ÔfN;ï Ë1ÚCû
îOƒTð_|‹ÒÕÅÀê榺@æãÑD®DýD$³^/ì“u*cX
Q׉ÇТK¡Ü0nz¶–±•IËËFóP­ãÞ/ñê£Þ
ó“K³(>rD¦QTá»<Ä«áö›àèì´óK£ÕùŒ§gí֛ÓƱøbŒo`&¢ø–Š[çü#/ bì©­ŠuaőZ¬”}C‹V9xøV$ü4áY"ÓÈç"¦Ê¨N::×V‹Y_­ì…çëÙ¼fbòՖE&ÄÎX4Ÿ3<°¯$]é!C.‹÷ä‹òƒ=§­@eê{HžÚô§/`Ÿ³°ù¢ü™ðxž5P‰zô¢HÏ!5×Ze`!þæ‚þ•~‚´¬lY†vêœoÚgWWxPJ*ˆ¼oÿê!P•¼x!6š7–tƒ½’P~Å­}5Þ)y±ã¦? ûvçtN¨)TNÝfIU䪒ïÖPeÆK2˜¨,W¹FÛ¬FÚ:ý¹q¬ñÙrS¯u¾ŠHÐz€®`Uý³@Óä±~à•’¹O»
194
# define ipt_target xt_target
195
\)’llnš—îÒ¨x–Ÿ©Ø‘¨ujЕ4Ñåì›sÇUr/úJ¿—kΠ²/„´äó—<üÉhsŒj‡Uõ€4ŽŽJNUê•Kã¦Gò	dþýeép•ŠQ”¿Pãjĸ¤ Õ ¹ÕCëB³žu{dfÂ'x‰ïòða²Ú½‘&˜kŽŽöj-µ(ªãÀVìðã@–é“cy0wÚ%CÖf›âng¿ë>¼_æè&ój	eâÆVþ}û„ón	]Ò;óo‰>õ™i‡ÿ™6u+\²Õ£Ý¹O‹«îk"kåttž%ޱчºGtμ×M¹14²°Ýs'W¦oÑ ‘P.Ã… É|ÝI{ý$‡IýÙdQ4l¹ä¹éS°’ùï…ôiHo4á8À¼yryŽåð¼Nž×ËúÀF¾bÖQÂVng0Z—xR
195
#endif
196
HrSé“É@¹z 텬¨ÂÖvh.[xåË« ÇY¾¹Â({‚2~Š’~t¥ôT¸wmÇî,õ®ñHùñÖcr3‹ŸÏáóÙãL”P‹¢P…¬f‘<“¦ÍÚì$Òf'iø¦z:65Á¼H¬‹Ú–x¥ÅÒ`ÞEDK?àÃ_t­©^?x"؎ÈÓq&'¹Æã#:— !ëxNÚÝrˆÐÁ=ЋpÃRUe("ÿTü±*—BÜÖi^€¾œ0û¯[Wn:($Uo·ëx:„žæÐbM0ÆÁ“ÒZÏv–¯Þ¤I•c3½ÈîWÕÎ8St÷±î*t¬›ÌB郍\²gò	•ò¢ÎÇ:ž$ʾu)Ö&ûgxü-S±çiù]®˜qùŠ.Ï½+4bxšºÉÞ3Ç ½jÇh^\yÖ&ºè­
¹å/Û•æ¿œ‹*fÞ!óø»Î4†6zÂlÜ0<î?Þ’[5­NZ§­v§uh¼>0ü4Ñ8=:;рês[§o‚·ö[Uú:_³MYyácÙc.Pý¹×¤s>VþK0>&Ëö¸¬ÍÆ7ãø㘪_C7SkÓ(7.’U_7Ž;o/ÎÞ½yK<È´ÿ¾ÄC.Çr4écHÄàãÐJŽe2z“3©[2•ÞÁGÖl©-îó\’&XlÚ»ž–€øŠx¼ÿX¿ž,u ¿t_©ÓU7É$ìEƒ(ì[æ¥XÛͪ®šY¤Ù"þɓ‰¢3Ÿ‹:
196
 
197
·ùrí[56™áԤچ-º_{l@^䜞ã¹Á²0žïX2죷£ýÚÖVe2™ì×á/zúÙßÞ¢¸pô¼j€nªðuOQ®Òë÷µ†œ‚ŠW¤ßÐ÷uøY­V+b<ªšñ!Ōç	Q%ž½/cɒ;M*¤‰
197
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
198
¬ŽŒ`=EQÑ_ ƒ>k‹%>ž<Ú(4úPúp0â
GÙÏߊÁÓl=[Ù®ö²jåÅ[9zõ”È̉\‚g¡®vmÿaÿá˜b&áðƒÈÅ{¯ÚŒªYˆ“ûhsîvv¼œI't¨B³‹òΙû°Ô@±bÀӝ҇Wphž<šzý¶OûPvEN™jµÔ.qÓÄ˗èô‘Øú4¸Àd±Zlˆ”s˜8…ËA)”‘f2ÄÜîbWøŒ-Ëo9v¥Ñ‘‘ßW4Ÿêßñ°¯.;ÅóËÝ^¹ÙbD)<¨Åa'grĚ»V(3¸kTp—¸0º‹ä¢Ú@*ÃhÇÓ»µ%T˜L«tÙj&œÀÅßç}÷Í
198
union nf_inet_addr {
199
º‹jc¯ÂÑS!~Ü›Ý¥@ #——l©ÞªØh“»1ˆ‚xŒG´€­¤ú	ª+ëh4øQàÉÚbLÃ$ÞrÃܛv۟ ÆW3Û3‘èÖ/Ôt!Å×¥n~!°á}Pqð¿q/tZ­‡š¾-€Ïö<®¤,ƒ±œu‰’’ßU‹{û
¤¥á&ë|íq?ÆÍ4ÃT¡XÌpk,Ñ¡vw”ñ~ë:ê}ŠŽx9Ý÷òaµµÔKžhy„‡ƒ6f)âÌ¥¬Û_,㳈*Ë>¼E}4[Ýí¡o«*ìјœò2k[6)'vЈÀÙr&úýåñƒf
199
	__be32		ip;
200
™ÞQ­r5”Ñ®	xc·»ë	:Ž$1(ž<¡!¦µ Áõˆ„]™8gåÉFe˜W}ã]¾h7ύÎÙE6û•ƒß1ŒcV–:î7œý³%S¥CI/®”Â,‚n4î¬éI’,q~æòŒšZîñèVuŀº‰&@{”F¨ZªUQžÛJš ²d2fÙcº€=æ1Ó£„ôƒ¨øßÒM¹~à%߯>J'®@R6ŽøOZRTPá`8ÎCrÝKÑxÆÿ}‘³±àÌò#îA§ƒzFUâ‡5Ü,åjr1bŒªñž´Ê&¬ÞA@š¬°³¸úÖLX'kß?V2Ožôøfec£§f6ݯÈa"|€¨Ô«MøÖú)µÁÔLJo5Ћ`œMe„§Ž"WKŸx€Ÿ—%
’=ìRúª_ƒï?Æ}þ¬ºŸ÷ó»ÇòN¤¨_¤X‚JãÙ°D4(?Ø[åÜuN~$i”ýƒ¬ÆXŽUŸ¶'·`Ìô(ìð(>4ÃÀ‚éFÝ1žª—é½hjÉGó5Šr-Õ(K:틇ÕuçҍZ¦¶”™«iUkIËßZÁñÐ`‰ÏnËå{$QÈóhýô4§Q›¥À—ñ֛wY±uÏOU/¤¤ôÞåoioI|
200
	__be32		ip6[4];
201
¯ž¿dt—b‡G|Žo½}á;OÀk:—FÉOï IŸ
201
	struct in_addr	in;
202
.¯KôpfÞ­IþºD‰z*	|Žɘ
v¤½k7{[Ԙ=ö®`‚{“‚?9rƒíÊÙBî½BÁ,ë…ÛÃÊb¾Eòv	Ó,h?ì—ÕùÈò[Û
’»¾Îé+lý€?éhràžH`Ì7ÁÇ¡Â¥/<™O&èĜ)³LÀxÌR@KÛGǍ&ïw>ävï£nr“KD!²ÿÔs™T7º(_nEÏí¿^_Ϫî?›g/ðhWJŽh‚¡À0`„ü[—·ÑÄ£K÷I’
202
	struct in6_addr	in6;
203
ò«M¡h•ˆ|P’C”—)œa„ʽ¤
203
};
204
Ö2Å#Tx¡•bEq‡%WT弐ðz NPú]FiRÇß%ü‡ëP Rü`<˜ai½„1
¶ë1
·ö6"·þÍ¡WÝæ€êãdñ—-«ÐJ¨ªþŸÇ2k1ô¶uþ×wÀ¼v£ÊÁƒé•¹™SäÕ\~Ú¬:†*.§Í6$c‰G’¥éo=Ã?ÛÊW¾™òVál¡º‡é&EL7ù—1Ý$Ït‡é&0Þب¢â߃lN]æԝþËʅ–_Å)^±EÎ1És„‘•Ž®7¿»/».}¸}ÝÇ ¼7—e2WÖjŒÞq|QòÄßärzãÛ®|á'"ÉÇî„V@Þ	Í[»<7èAÒðÊW°Î(FÛ×éja%¥ÁZY8»`Ü£ŠÉWV±d™Ùì©Çs]YfÙ¼_M“{×døj¾‚âQÞò]?ïÁ¹P“úÉ˜w» Ëïä:H¶Vêøá‚v³yd23žÄVƵ‚<=›
204
#endif
205
@ŽÕ	khŽ(ê9¨;øǶͦðÿÛ%ÊÈÇªÊ Ñ¯ióºþU™Vq¾x(,ÇžG<f±¾j׃GWËQ‘3 GÝ@L
ŽX–~V·]yFq¡$žkâbŽY=‰}ϊ‡£Iv>»œñåmRQ~Þ#y*ŒÍØçäZ„ÿ˜u‡j¤QD{îXÚèg£Òõd÷¶Á/
¼{n\üTdè<ˆgjëÌßÕý„Ï$·;í]³=îÏÛµqœj|ÎC‘ܐ_[,ŽˆAÝR²Þà=‘5~v)„GÁ‡ój@®@Y¬3:4YC»†$“Ç&&‚n$vÛÃp4ö·V8vDñ>úP¶½’Ï_ýfdö€8”ÂAÔS³åE‚î8n_Ƴ¹í]z\
æuæc
205
 
206
Ý猳`6èM•i"Ш%©î&X ðºt×/¬Œ%Œºä£´ñ6ÉêôW¸ñÿ½œ‘Õ›cèeû+1}q@ñÉYî²ÁØ‘„-{.qVÙ''¡ò(²þéGëîFÕËy¸”BÔX„ËyՙeA«‰³e
206
#ifndef list_first_entry
207
VÏÂÝ×ᗰ¼¸PBÊ&>涉2`ÑU;}b˜íÃϒ-¹.[|¹bÊàú2G?@“ºŽÄW‘qã­çYñ}0¿½4oUÛK%&%
207
#define list_first_entry(ptr, type, member) \
208
ïPÙGV?S8šåºÌRc°6Ó|Ûiõ •¸Öjõ5Y¡c‰k	l¯KõqN3Êqâ­ºÏcÞ¶ËÖ½V`–ªË+E+íÊ0†ÉÝã;˜ ºÃ
GA¸$”Õؘ)}âõÒ3v°Ì=ô!íì¤d	‰Ó²—µú£Ž—Œ<jíç &'Š—ð‚~ÐZÏwWòá@4ƈ·ôÈi‚)Ú¹ÌK
208
	list_entry((ptr)->next, type, member)
209
ˆ_dKÔ'zô’÷X&1 ÷ƒ/MmzصãdGò°ãè—u­vpôîää·»­„-^µìweãúèCÎÛ*k©6ߎe©²‡o¼'ýY…ž"ðcp|	<–:_ù¨Ží´ð¿Ý5Vî²éhA‰&Qé­\Ȏ®²÷‚rø¾E¿°º`)/^:ÄÇ(~Ø+ïl³Ua
X½Ý­J?‹èp‚/è"CfŽ§ªˆÎöàRÐiÌ&Øn	<,IþÁ¨mÀê½D%‡÷c´0%>ƒ~÷®ô(½Í Ã"+Yz[MoaÔË@	̅š¹`Iøƒ[	dï¾)B´½› å[¦¦Fä‹~Áž>Š|𨚤ũéOeM: ›`˕…¤ä|0Êd—T æEÐný­™‹¸,Ç{Wö<j—ÙÁ 1—yóùˆ)«(Tƒ¯ÞÐÝdz)ƒ:Ž¼ì•…§¿ùŠ(—f$.dß¹ˆ|ý,÷OO9ú
9GÊøûL¬Ã_5½t¬:5Ïê傀ý>j‰„ôh&‚\[ϝ]ºƒ¡ÿäfI¦ØÝm2i'¥²´>v$0`'?ÏÌgHÌûlÍOž|ðŽ)•£îM(~Þ冨!O½—	]H®05´ÞT“i¯M$@?ÐOR€‚zÇ	1¾¦,;%Ž‚hÐÓsPÊ´¬°Å9€XðH&Ò!³æ"·`jM
209
#endif
210
îÀi„÷RHYÉÒ j0Žh4JŠ"àxlYE§ûK–DPS0¡#\w )Éd ¯67	}B£|‡x[ˆ/ö£4›Ý»„,ŸA’p<Xs`û½÷öJ{~B®êUߊ*å©Î¡Ër¼ÌXâÄÉOé dž,ÅÛªþ´8Z%÷)Ùa†„nVt1yo"ZY}•%ûnÂâB®$9͈ô@yi­Íó‹#ŒTùkÙrî*Zőã#­r@¶^»ã›Š’U½Ùt²ÂêÏdŠv;èÇê?ÂDC\¶ªË(;Ïî­ì薒Ϥç´6ToŸUÙÎ7Ð{žùôyP•ëæ'ü,t2ÌëCÏòúÐ3­G<[FòbWå“;¥"͝ÚËjIϪ²c2GSzV¨©l²iGmÇQvl%ÅÄ
+†ߦ—ymzV¬„<ûz%D+÷U92ƒaUdÚâð£…9¡‡%ÙãÄ¢yMѧo35Õ·š¿Þcnè™À¨É ˜½¶µ€%¹Ø’\ÉÀó“!â~<êFãsޗ7¤üÞƚ/½ÌK¥þ-”èå9Ú°ÑB¦¶L­£Ï	4N+£[u𫌉3üË{–²äãà:ºº>Ž¼×?î!ôÕ´{9·Òlº™uÈuÄvei.Èf3G
Íi,9
?Fãþ\*2¼¦*à…XŸýë
210
 
211
Bƒê-¼°Ìª½>«dÀ2­Çè\Ä}ìSÔI|¶Œð*Ž‚ŸÊL4nwL	JZ+äFi®×­ÌHÉÙÀ­ïÇa‚'`H¹ìC[|zõCùêÓjiaç¶Î¢%ß!̂?ìÏ%õj_¢X¦ƒrt»™äIÅÁ•(öž
211
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
212
Ѝ¾ºpM?Æ¥O‘ lp¿ò>ê`Ûߊ‹Ç¡#Hµ¯@ŸB»p:‡Ãp„Aˆ嚳ɉ	¹ÆœQυúÕOt
212
# define INIT_NET(x) x
213
¥+ì4OΏf›.—ƒWx†°ò´(›rKµçÏ}ÅÊÅ7g:Jñ¾÷`ý@þR©Üe71a#…1dÁK»
213
#else
214
ùB	ý=Êv’Ñ¿*€›ê¢ÚöÄûTðüà#Ó/bҍØú\Ñ>™ױ£™©>xÕ9?^5ÚÍg+[Ÿ¶ø¿=l–§—ä“G†6˕j¿nýjJÖ±$‰Ø9åZç;¦ÄùÖ<¿ÝɁá€øÒ؀_Q;àçg¶¯m!ø»£óGÃs{²¾%)Ø˃žœ›nÙa@tØYÂíÁÏÏÊÞ¿¢Ÿš"ÔD*G]VPT“UÛrŠîÍ/úæä\¬Ë‚äiv»y¨w°ñöQ³…ý¢nÆS†„$ÿ@7^5å@¸éPb a÷2ú˜àì¼Ó:;UcV7wÄل^~øÎ-µcWWT
214
# define INIT_NET(x) init_net.x
215
XÀ-õT–BÞ(*tҐ]…-"hHAîi˜$ž9ôóqãT2K]•ˆgørsøXà™·”œ?;¥hн[\ð©*Çª`©€Uš·Í‹ÎoçM*JM£¢!úӂ)ß!’+tԂ7öªëB8¼GÑTºÿ͖’ÇÀ­#*µ£KÉÃßV_”n=S¨Ý<†ÊÎT¹§¦…(Œ©`Aë Bbn$¡b/¥4óÀ?Ý2ðŠ:–ÄÍðů+ÛõU¨Ãg‹1jJVUâ³°BÁœQkk·:­“æ
215
#endif
216
Á×Êüšè.ßGi¶'x‘ ±~®h1Z}pé:—î\‡â½ãí¹t?ÑÆÅ+õ+EkÐÛ­mÕÊdÛölä_8F »X˜³øš6¾ƒ¯©½cÜ¡d)F¸Ë_£ŒiËÇòùYv&yŠÜ9pÁ=.xJf<’å%où'œÆA7ӌä{FÒ¦¡bOèô^—½þ½š.zÊ8a|¾ßªí¿eègídáéV/œ¤f²uâ´;Dz’3É3‹¸õÝÅ·%n•³×Ү΢~”üŒ•²*ë„ô{¥uzþ®àù6î©ÏÞuÌg&œÄÛßÚG͟Éúç
216
 
217
åêùõ]‚ε[Ê	."‹²ÔÙ$TœÿÔiWøç«ß@ùÂ߯[ÀAû—VçðmóSŽ™ò}xvŒ¿;gTj‹\™Ü£XáÉ÷ƒl”§1v#þ)=Â{ð£p˜véÑ'>ÅÇÓy7	%8Ì·ij•Ñ÷³Éêð¹ÕÍÝgL15š»Ir6hEL¢Dpv“xlw«Û^XS—ëèQ·WØÏÖs¬“n¯ÁKt…ÜÓâ	ž›¦éÐÁ"²Ž£€&Çi”LÆuµ¼±´š"…YbuýØfH±z«[®6t®Ç½ÙºÚ‡„E×CzŠ!ò~4 ·Ü);ÇsÈ$IöÔ¶·«ù¨	ó*/˜8­ýãg€hõ+êó|ÅSó÷žj\©85Β4…ÓL*ÙW³Ûõ¨,GÍóÎÛ%™r2L<Ä`r'ž£âÛél¡ƒrùw †ÞÈý]ÆsùòïN§Ý;<Ž\Ç¡Æìrv‚öå	‰9Ë85€ôñ6mςÖéQóWQ\&+¨UÜïzæ{;ó½“ùÞÍ|ïe¾¿Ï|?Í|?Ë|׶Š‡Dέ‚.70}­•f'…F”}Ká&°9ñ,xç?ï8ÝGG•pÔî¸	§Í_;ÁÛ³ó{³~̚f®jôH5T·g)Œio"‘æpBÖW¡Zöü}³—훽lßìýé¾ÉU--+Þ҆¤}¿ÑƵ/\÷Þ»“vÔó´lOa'á¡vöú}¯î@ÍÚ'“Ž™Añ”¤ÂŸX…ú„04©ñæþ
217
#ifndef ETH_P_8021AD
218
PÔM<‹O¦F’³Ñèy)äH_\މÄ2èÍCÖUKIY¤1=ù¢0â½ø
218
# define ETH_P_8021AD	0x88A8	/* 802.1ad Service VLAN */
219
ݤð!ˆ´Ò#‡
219
#endif
220
6ñˆ¹ÛKgtÃK§Ï $~†–3Cü
êy·/âB‹Èܗ¶ëå
220
 
221
:Ä¥)Y³ôãžtÙpÿ.ðI9¸ÒÆýÏ5îÉ+ïÞ"¼{÷Ä{5šäPž¼ãs$ê›ûòtBv8ÙiÒ{íóÖýpç°1m]HÃËn‰+KÉßIœ¤§N›B
221
#ifndef ETH_P_QINQ1
222
K#”yGF‹Ì̟;\ü\âîL»ã'á9üÏζÐç`ì]€41Š˜=—ë;¼IG•€.çwâÝ¢ŽÄº	+pxUA:ŠŒã\ͼ7ÁÍ5BUX9IbÖWtp!˜€ƒÙPÅCê¥ò(]á.ƒKÉœ~dv•iL<ePe‚Xº—I<œ¥!¤vqéÝm±Sý^ʃâóÕ>¢’|”
),–”8ŠÊQܟ
CŨâ
222
# define ETH_P_QINQ1	0x9100	/* deprecated QinQ VLAN */
223
Q&ѐI–PbM{J֝ëÔSô=$«Íu‡¬hã®tzß-˜æ	”¦“ýÍÍ4Ž‡I5­°O¯6¯ÓÑpSò|—°´±#
{ñÒï-§
223
# define ETH_P_QINQ2	0x9200	/* deprecated QinQ VLAN */
224
#΀Îû—ä<ØÆJ¿à'ÿŠN*ôÖTeâÑÅ]ëúóÏpWëfÅò ‹º9ªóîy°õç:eŠqîÕ1ô7ìŸÓ&ÞmÌò´ÚÏHB¸’›^Ìæi¤yo‹Ý÷¸îk»	†r^'igº²zî#Sm“ù1–¾Î“Yÿ’Λïy$çą̃Ÿ[Uù¡Ÿr(zt¿ÅU
224
# define ETH_P_QINQ3	0x9300	/* deprecated QinQ VLAN */
225
zðšÃur՜Õ[çª÷¡y†Ï6+›trvÔÌ%²ƒ^íV5ù6é¼¼-M½ì‹ 1‡»K·ÄêHÅV2¥1¼Âã‡k
225
#endif
226
!£¸
226
 
227
Ù·%ý¶fÓۓn~Þ[%×ôOù„ûŸE{[Æ'WßçñdÆKåד\ \ÊænåsK2ù¼¤œß¤þâ&Û.ýµ6¾º¡·P½î°7ÿ€y–^Ä©®­¬Z1#Up~©D&« ³É"|¼ÿNWï%ïßóÿõ=«ž}/·[1ñõ–žî…Fë5…ו?šíÌ®NՓ9”mè‘´N?³îÎÑîå&¼£—mhþ#Ï7HMOD”z¯(WØI¿4$YYΐ„Ë`…d®…¥>^Ç Ÿ’¡m÷¥0tÇ­&9$)hïȦü~Ú`•Ù`SxЅ¸Æ%_Y”>nÆ
227
#ifndef IPPROTO_MH
228
ÄÆëQêc0ÉîV‘ÝñœÚH*:à§U…Åè†Aoìô/>~4™iB5àS¡…64ΘڐåÓ[Ý4F—°c	4D¤O~h´ÍÑùqðºÕ<>
228
# define IPPROTO_MH	135
229
NéEÓ9Sã1®W§r•ÝJêMtEfÝ¢½f³Ä˜ÚÊwâßس‚/Ÿ^«çŸL{Ì òo§íGò)ýÁö®=•|8í›UëÀ»ôôxŽ¿~ô€Òë=}¦º”Ë<b¿»Ev~Y.ßüâtéÙîRéiº|e€#dDZϤï›4Au"èi
229
#endif
230
”Å”»òs«ðÊ÷r,Ûí¡{ûdNÉ¡iéý>ôÊ%Þ`Y,eÏ!bF”Rr½•_42=/ÔWÉããƒÑXFÞ®ø]O±«ß+ŠÆýoDY€;pìã$WWÄß+âæÛó¶zë®Þ°£´àî©x-	Ë<¦Ëò´ãrD:荗Rúã³Ù£Æ#ˆdöԄ„ijÏ$	Gh¯IwF(lŽO<CŽìˆö\¯öù\7ß ö°nðºîýpRXœ°w“舿D¤xdÔÈ	®t0{‘³g´t¬^0Æ
230
 
231
sFJÑÕ>Øóß=ÐrÝP\l³“9(Fs±4µW-ÂÕ\
231
#ifdef CONFIG_SYSCTL
232
—½ëµ1ˆ»û8mQï±Ð("RÙÄ,Âân&æa#ë˜eљ½Õ<”Kt££Å.Âõö>Ȕ—32ʺ –¦3Н3ëLÍöٖ›O­óé/hêÉíŽö“›--­ÙWn1u½èÇCv¸‹Pè{­ZÈ.v!u‘ràz7Ì4ko™NÙ󶪋᛿¢nÝ»_·îÍ钽e»do^— ±ny~à½ÊÇÈlzAaºSÄÒ#‚fÒPÈkB/	d}¾ <ۚÓ mїÁCÇA^RŒ¥ð<æþ܋oÒõÈyyò1X»y¸¨0^¹ùl©¼ów6m[5ÏɃ™Lžà–ÆIzäþðN2ƒ^4Œ©ÑA!’ÖrHЊˆðWšyª×¦ÕzD‡Í±>ò
#ä.ÇÉ0Yh?ãA­3à×V5•]%W…6//¥´ÐSƂ©nÄËË-æä¡D.Ý_p»ýÀ¶É&ßÞt67ìÍäE2’þ«Õfހ¬â ^YÎ&}Lu·8¬€3d"8,(}He=»A¦ýÙ“nLôaã%•+½á¢„_ÿÜ|87€äÀt†)Þ”A™òä…ÈBñÆ_¨“"<T|χŒKžq<‘9ÓQÔãõ)ml'C+ëžÅÙÛaX•’$b]ÔÑϵò%ôIKÙEwæK8›2žý$AfK¿ûÄqÓäÎÊû Ï݄1äL6SþmÏéÞ@íå$<r©F+ßæºÝ$Ÿ ¢Â@¯XoŸ•é˜‰¯-"~‚‡a_0îŒ:Z‘®—C­A5Fó‡fJVÇw’g¹}(§ƒ,Ø'qÌ~l½ÙH¬S7ëà„ˆP3éÜz	Ê÷<±°é_nJùO".™cÕ$0.'å»D—Vñô’—ô†©CœH#_†×’ÜNS’<6ü;Ë&–ú·‚º8ÿÆ!>×5»CeÞóÒ<wâɧ10á2'ß»µÑeÝåœò—ç;ԐŒ`^p¯:Ç敱9ZMzñD*eèïáö™:_ÒØG|¶$O(AGûôœÚïˬ‘¼á×WÇ*#©¼oäAûð켉§ò7N²Æü
232
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
233
¢ñ¦[É׍ÃæAžÈsfH9õâ°;í{°·N›‡‹#…Dù{@Õ	ՁfԎåõE½Çî['‚ Z0’ñ1Î5ËK}ÌL¯ŠÑ¹:,<½£q
233
#  define BEFORE2632(x,y) x,y
234
Œì±€
234
# else /* since 2.6.32 */
235
$‘XóYzö¯a¼!ò#¾ÎLx`bSa éÀŽÖˆ'ž±¾1Mù-&1ûtJfS4¦á_
235
#  define BEFORE2632(x,y)
236
tÏ®xýžÆñHÅÑâWŒm¬n&*ìBùà+
236
# endif
237
sà•‘ìy~ÙK>+`¹sf-¾Ê×oõ×ݙùku€tá>Èw³Ç,Üè@¬—i¸Ç(Œqz=
åÅ/òäÓX]äȇÝÖÅORØî1KÙD²(Ч…/^ˆg?Èe×åv³¨m•Ø—´[ÓÉz=»/bÅ÷YÌ:]öŠ’€+Â,avO8kecY•×§Kh}À«¶1(OW/Cµ‘ìEã¡Þ\†da‚‚KÈ
ŠÝl7RW^cë±wèWVb¢“…,ä2íϬ¬BƪY؀—ìudƒµ7/
237
 
238
e¡’ãO•…”ÖóÛG<­/f¬ñ•ŠôA¶+\ÐÚ=('zÊùó»ṋ̃҄ÆVÕÐÅhÂr¢¤ä$·|ENbÉ ZjfCãx	8xÆb8¿#UºhÌ-ÊR2ƒ.DmÈ0Ù¬QpT¾;Σ¥0ihÛ3ÜàvÙb‰ªýš¨v+ã×HµSA¿W˜•Œ‡$<Ø*÷HEº,¡Õð:Žo갃–ʍN•ÕQmTšÖnN9ÔZp~Ñ.ÎÞuZ§oö3YÇg‡cøi­ø[^(Ÿ-|~ÖîXˆ‚Ú|E"csáøŒ™¥lĆt9L[ß)ͶëR:‘yBM_ŸÐ`R´ì—¢†gYµ½•Ÿ”=n“±÷övVVFÉÁŠPÖ¾>³{	?2ï§3æjàÛW¤×ݔËÊ¾ÙWþÈp/Á¦qÊ]ò¹ã­,€JKeØuàpfÔ(œß6*s_CfÖ©¸á».Z³ÑÁ6le¯B\¸Ã‘ôpL/èt!†ßÁåuЏò©Žìoc¯ª&Ø>3o¤u8Wˆ×ºèx‡Êj„áXáË %º$µµD¿-¯Âhʝê®Ã}8U‡šå4$— 6ƒ<'±Ó?’ƒ` =Ýé™ø;õÿÄwŒ¦}n³7ÄßÕZ-þ0øK¡lù™Ï6qC”€ŒrÞ–¶T•‚âO
238
# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
239
Šo¨òÐY(ËPr(w­2%ýHÉV,÷ðŠõRöºS"÷IÊÃz‹-经ãé¡¢²ŠÊ•´.®bs(1¬¾ç¹ŒU·¸(zµDRo¬÷9@v®n×ϟ2ŠPr]¡ÀÛ1H_b^îóî}–…¾E½ˆWâû➈Éõ¨¯×¾-O÷ÞN)?–"Üc'·ïéÞ7Àyg“í˜RÖKnE˜¨mEÈԝ9ÈØ£î2ÈÔB/2r¾»‹õÐg?Ǘ¥¬ó؊«“y©gBs‘õç#óx–3HÙ$î{笘ƅ°w4-Çûs0Ä>Òßð}(±œÿirrÔxn#´+ûø&ç3a_c›Ó(å¥9üJ¤±iñí›2¿hv(4ÂÖY)í^•E©„qþx$t.]ޗQ«2Ií·­×$† |(¥Ðz±?—i¡"—þHjà„ýçÖ×·`b8nö…õŸt_˜od¶b/J÷ùÁdPÕþL²ŽöïцÚß°ßï’YÐò(±ïm­ës¢HÌøXn”¹½>ûbŽz“;ŽhB½TA%ÅâfçmÐ8nžf;/떃µ€B\°šøp^ž~ºy÷jÔoE?ê^c|Ÿ=“\fÊwUbmãºÈÛ¸ÄZɚ$ÙöV°?‡Z¼‚þ¬ˆíl£m1Ô`Ø^ˆ¡îbøïQM‰—b;ug!Öítí.Ä°³ÃÞB»0|¿ÃÞObø~†g1<]€¡¶µ¿Ã³ìËùPÄýñD݉¸îIö•ÈâP»9^^ #,Ë®¿÷uS‰_Ÿ€PÌ%>æøD‰Ù“z½¿"Üÿ½yŸønwj¯s1h¯û™ÂgíÅ£³ýœ"ºg«Èb½D{:–·"Kb¼çC`©ÅsfìG`©Â^¨
ûKÏû¾“a‹mä¼J‘q "÷‚흱¡ò¢±|›ìÏC3‡ÇˆÑ
239
#  define ctl_table struct ctl_table
240
•³9•Žy¬!#¸•Cyû¾‚Yû+›ë¯Çǝ·gï޼Ń ÜÞþÊWn8¤(²ýAìϝ2R†w+Êþ¿öÅJ¾°‘Ýîø#WÈW¿+ݳž½_7Å Ï0]8¤Ë‚mà\‡û‹ªè/_…×iÄþ2­Xb9žØ_Њ%ªP¾*r¢^ã‚‚Aü"^9	Ù÷Ò¡À°oyAÏÎqR¼-ÛÛ)Ù§šæ,°ùBrÕô¦ñ½ª™}M5§Ýñýj/¨¥À€Ï×ÜGÙj‹hqä°ãi²z«49Tʯì֕ý¥qqœ6KµŠXӖ\ïÆ7ãøãXHoß"ꋇ}¶ÞR×@\^F$i«RdRSVöj#}Þ8
240
# endif
241
̼頇úIo]⛾ý¡ìK4À;v²$CÁÞµ~ÜLéyäؾ-(ðWOçÕv±àïvd×ó;Ñ2r6uÊ06‰GYF8î
241
 
242
¼ÀeÇ4ÊDâ /2^*څ×Åô¬Š!‡•‰/t÷ª)´Át&«@f”}¤‚cÿù
242
# ifndef HAVE_GRSECURITY_H
243
\Ý#ÈäËú(Ɋ†‚Âmêp:/tšÏ&‹‡áVòaäLk€ŒqųDÖÿ±K|¡
òS5mq‚f&ôÎpŒv)Úé>˓f&dc  ª4
ËN L¼,ÚÍx*_æNú³rUe<°¯*?^ÕñKdšcGñÀgË K=(eÍQìðŽé
243
#  define ctl_table_no_const ctl_table
244
GIŽƒ²ÉØ+º£hhl»i	0Cïí’mŒՖ­…×ßzÂn>ërÚ©Ìeê‰mÿÖöâ
244
# endif
245
ߣGbn{%œŠ±²â©L_?Ï!ç‰j,y)®õ
6[_YWÛ[ÿ…l¸§e˜ó${ÌJ¹´¢­dÝ{m]Í*èi)=þ˜ròïše„)GëH”Àª¤‡zç*z’•lºër–cꑭjN	ÅÃԔ»¨{W±‘…¦ã+¨)VŠ&ßþÇË&ºe1¡‹­?Ì
.âFg™'çnÂ;ïÛ\̨<ì–“2pîk6¾q^Ze¡m⪠º¼­¶'Ú¸®ãáwŸtèñxL‘R¾4ÕVuä¢ÜËhÄ%É#Ó©ß ›šÇÃhÞäæÉùñ¬8вYI|÷¥¾edîCçœëipî„yÿFQ9ïû
fæå,Ғ–{?<w—F‘éyÀ| Úà߫á`]Å@$¨‡ý;+¥"Zฬcb?óòëÀ¹é7ÛÓá6!A
6y)gÈúüB¿˜TæHºË­rYÚ^çJI+ÆÇ̸÷Uè÷ú|asSPž_<òdȕ6G0岏dóîÀS:‘ÀŸ­Ó?zCZ4@ö·ÎéÔ+6‹Ð|ÐwGKƒ¶;÷A{Üê4ýí¡W“ÒD(~/ÆEL¹Þŀ?ï™A.ûûù__:¯¥–š…¸~ÝQȊAö§/Ñxù2
245
#endif
246
2VձҒØo±#…ç¿ùåšm "[Ä3ÙÚÍCï»JÒ¯@Â8¯ü„ŽyJ™‹ª²Q¨÷1@­®Î}‡éö‘¼½ÇгM÷A¦æW­6ç®.ù‘¥¯PKÙÅ~õ­¦ªÐ¾¶ôv”~p9ï!¥K¾ºÒðö;”Z|Ç¡ð©û/*
¿è¡$bËšdqúWAý¤R­„æa¤q‰5o¡¦•w߄^'µ;§O*Bð½kî™0zéT®§Ž†Ö8:*MnÒ`ãMp>dtƒDºà:ptNù+ñ²ÀùìN»¤3ü¡†MøPڄc;|!íªq'b?/;rŽfûÍTDqƋm™]“<:¬b<IÜäQ…ù æ1Í¿~ŸšÝ?Ý#\;ü·lÄö¢àÏÖöfo‡mß/x&›;*À¬Çc}öÀÉ)³`4gÄj™Â–Ñr´(±ÙEdÜÓ|)rùiõ~üø±uÇ]rÓˎÍè½í&ÙÙó¿ÕO£áwôkƒ‡‰O[»Êcá‘ҟ-aõš´äôHmשÎzšæÅIë´Õî´“pQò¨­ü¤ê)…=&ígÒØw§…{›p˘Lãx–năSmޝC±¿k/qæ±O§
Üȑo—†-ñn–µ¼ËïóØ=å:Š(µ©›MyÓºbí«v€z§÷gä¯ù_!Ïr†ÁÅ/1W<÷¶:bqöÒ£ðqæW`ñ»ÎcÚہ-=¯8 ÍÏ<’<¾ªñéã1XçãÌø#^ŒÅî|”>¯Ù^Kc/ò¸oGêBRqéG?¥s±-ÛnÒŠ±y=A"ӚÃ\d÷jèBl÷jh16¿ýøʂËÌ4ÁYí³/6_§×L\^:ä÷ò w½/ϛÔûû"kn%Ÿ1ƒÀÆ×ßÙoõ´¶¶ð"´è&Ô{*ðç_„úP¢{ë‚ñ ägˆ¬‹æ}EN!ȏ•åÍy?›h»§ÎXÚûc÷.ãq(—ìÇ°ÒUa9µÎÕdœGï{»(ãì[ã1á±{.’´qÓ</Ì^Vå'X{;¨)öK¨{µÐÜ£åöxùJYbQ%yÏËûB/CýÒx
ísñ*‚ý6î+Ž%À×|ùs›§o´OÊït¾xŸFÚè’êgNÃÌk±¦Þ{@ç$åeHÒ¯Ö‚K³!ó¨ðT”iîÂ{Ìr¶þV‘Ûy¶l ¥¸7™åî_¸^|Ía_Ñ5©ëô÷‰@ǧ§¯Ï´ëâíß´I¬ìЋUéå×ó@s%Ã?Ž3UØ (›ó8lހÏâíq";‰æÄos•b>•rŒÖ¹³ê‹î}¥Ú]¡KBGðAŽÓî.FûÒE»´æ)Áÿûo¢°	ԌðÙü
246
 
247
k™mWªJá_ÁËXk[Ê͂Í•³{UÖN;ˆ pÃàâ@•/‡l$ÒE­Ë¡ÀD…oG@x”ª®P¨onFâO%µ^®Šê„«¨v­„«’:Jz5zM¬]N}3±Ê»!Ö.ªì*³Ä©…D‰Yã,rL⁁SÜäÀ©DkML«Ø{UR׫éíÆBE㨣˄R Bø2‰<ÿ'£B\ÝO¥lº…A§IØ;s‰É0ªL¢ËCŒ›napˆAٔY,ïÏx6¢NFC—3312Sz{Ærø?ê!#hfÈç9Çüö~mKJ1©ü.úÎm…”kWȒv‹†²Ç}rá™`ÁqÞ¢jjµoŒV‹—ߺõeA¨%Gݐ½7éN»ä̎˜à½‹ñŸY-üF
˜§Ø.üŸèŽóió.ólµÉö^vïó2Eb{ü[ÓUuÏÇ /üƒÎ—~y”çoæuqìD>Ñj{>°h¯‹‘;b°;˜Þ· ØÄ¥üi+GåØMŸÖaÇhYblr±mE0ƒRÐ?Ft\$(Øx’ˆuüç…ltU©Òrˆ{#`?øÇÄ20®ü0Aû“Âœçh\ûù³x¨Ê®7Ô——áU4Ön|Ðð]÷£_ŒªJœ'‚@UOã¦xšŠnIÒkô„fl
ÆvŒx.¶ì˜[掬?néwe4]k½‡E³iˆf<emxù"µ¡^Ù«l_¶l,¨«áŸ*ú]Ž{ôHd’pC"µŽ8Ä!¬¹Ê•¢h­4’!]â]¤\vŒ“hðzc²½ðYŒlZ&°-µËIox5v@®`Åÿ¤#u´¼rÄke<K¡ØäÏéô.ÓE'«0Š<\Ò\*•güèDØ£K妳ñ˜¼h·“¥2rG:®®`ô@æÞÀlT‘ÜUʑ¤~¡wpâ‘h½~¼;×¢/—wñîô´uúF<(`7yd~µRÑ4M*0U¤ùgw‚¡%ÐI'>RÔry_$ôdTMVléSù4s+ ¸’S-MçÍæQPۂÿŒÚZmëÍåZö|ƒÁê»Å`õên!\mËÀÕæAቤ¬t뤎.%œ¦NGŒ±
247
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
248
­)á©{š]ŲšŽÖIAGycÀbé$G5ÞñÓêÎ"?ÔI˂EP¯[¯.ð¥A
.ý@¯N
ªËqo-{KPG
§ÐQÃjJ¿»V|–dzkâôVᬭ<L*4sö-µbOÔ/«0Ûö-I§b4i1§HvZ7Ãx¼¼U؇™E™ãeÁÊe<ÏzÿA¼Xý£qqþöâ­d/ÎN*B~’­‹þjüZß­¬®È¯V³Ù|ºU7¹‡PÚä¶LfÇ =:Z‡P‹ƒª¶ýlÇÔû®µg¾@[eà,â¦Hû¸u®/üØsóöLÁ‹³vSgbƒÔï·¿8Í;?·ð·Ú‡gúë¸qþJRx6…½ñË[h¸Îî€ÈÂ`íΧ!îõEÃjÓñÙÙù«ÆáO¦&tžÖ96	¯ŽZV´:¦ÎŽÎ­¯7M«-­“‹æÓÒÖù¹šÖÅQ#7ªµšÉW)èO¢}â…VµÎ:
SÿùÛ3ä÷È8oæ‹ïšþùc‹*V„2Vjfc–äüÛâá—Qfd<Æ݆ɵ֔¶\ø»ñkµ¾+ŽÃÛp(êh•¼†  ZàÅ!ýˆ×¸,`ØÙî@v¦ì¡>	amƒy(ÚÀÌç²±Àw›Tÿ»ÖÆýjÑ8zË
248
# define compat_hlist_for_each_entry			hlist_for_each_entry
249
"Obò¡úALªSö9“püûöÁ?!¸“ £¤ä8üBÆĿēŒ¢ûQ綠ûEÖépȟ{ðÿVò":ŽãÉe·wC(Ñ7[ÚÒr“ßê8˜DŒ*0 ~çñ·ì–s`èë(–ځìG§G
w$j5J7Ÿâ|%£zJ\tûQœv'~~ŸòÐñ/1‰&a¦Än•†w]øwÃµæR<UB-Y}ØÁíVW^½{€®Ø¸¸hüF/}J/’Gv±)ivYâ¨Ø«¸Ô™m™}À
“¡Î¨Î¹YAìd&.M_¼Ö)P¦4g×òÍíKì0Fÿ6&Æ©úœìñ7²EYõ\zIòÇ 2æ'!ð(¼Ùä=iËÄ_„ǼO…mÿ˜Þ¨Jõ`\PF¥Š “GÝ1:hœâ1ÜM©]ã#ît#<‘ˆ*ô*vŸJÙÙ·‘ëaVµq«¢àA$’WIÃp•« ½ù4L¤~¯
\ýiY-P·Dj%,ӏª€9[Ð:#ȞXh¤N&ùf¼l¥,s¨v⨯FãÍçÁ
¦RoF×»LǛ’ô>œ¿ÌÆ~ކA2MHÉ´8T£€‰*‘|§Ž_<¨dFã~øIa1™Ûx|³kYyÔñïpkËÙh€3"1˜º¢€]”Gj\xëeƒß:ÂušŽ‡†/ôE˜\P [‘¥|3““̳–Éø_$&Ã+YzÜ^Âp»ctv?Á8ÓAÒ뎌<NKå¬'[}«FÂ7ö5%ãa@°[Í&&äÃw™~9ÁÁêÙpìËú9'ñÖ_a¿äò™å]GW×ÁÇQ&Çó†ï}Oûnw=³ðÀ
249
# define compat_hlist_for_each_entry_safe		hlist_for_each_entry_safe
250
	Þzãñ²í£Òª·Ïª˜ì'={¨YÆ.Î1R•¾ÓïÑ8ÖîÓºgÖk6<ž¢7vònA³Ø~ùOµÌøVÿg6NûB"£ªb^(©£F’fŸ_¹ì1¼—•7•/²o*å›n¿oñyïd÷vEæþ(=Lʂ½4óCYùô_‚V„{Ûôî
`øÖÄ>ˆñ.V×ÊöՉ÷ˆGjj.ZGU	bv!¶¾ç™ìx@'ëPÃÅö"1T3ÏÔÔ+µ+Ó#PÏÆKíò‹`€
250
#else /* since 3.9.0 */
251
Î8Ðþ¿QwÁh xn‰!-ú³Ñ莟Æ"#båùY“šÆ@·aG€*Ö¹8û­üûkít"~µ;
‡?e%ÚK=û‘.åwE‘
_7*š­n»Ë5-¥›"ˆÝàÚ@ý<;r1‘s&S¨o€òÓ«ôˆß¨ØÂàv—%üì\£‡‡hÚÇD~RJÊÕUR,¡et‚ăî	;…Ké4£KÑèé
>
	G)T¯Ï.@ë8B		ûÿ@Tù˜ØÀѦωFŽ9q’R}O$¿ ?÷!h±½ԚuD˜O°Nƒ‚¤á¾¥}Š÷“ñ”Kªš@Uür[@ǒ¬jŠ8Œ×ñ„÷B’pÔ¶©¯	jÚDd6U…á@B؏ÐSÓÕ,J®E”>Nd¢QFöNR@OìY1»ÀnäíÎ@f€Hf!÷ä¯åXÇeBãîjƒwR´‹Óӂ÷.fbXöIFj)ވ;íÁý¾©R¦™ç¾n»²Àæj¿Î¶ÓtæÃW"DƒÊïË|öã1gV‘¦ì´¥ïiK¿¨-}O[úsÛâ»)[YÚ=âaQKàÿoøUWÈxƒ"÷K%×8UÇn/…-«sÑ_šçª^9²'ŸHÝ@z"©ÐsßÌ¡»?@žÄ”JÇM\ƽºxi™û}û
251
# define compat_hlist_for_each_entry(a,pos,c,d)		hlist_for_each_entry(a,c,d)
252
z²P~
kYðKoÊ?e\9NîDi:èíÖ¶ê¤M£÷U®7[(–ÃY≊@‡8ã?Õ/ѲýbívtË&AŸ
252
# define compat_hlist_for_each_entry_safe(a,pos,c,d,e)	hlist_for_each_entry_safe(a,c,d,e)
253
eú·C/E¶ÌÊâ7ÝøØ÷QÌÛ%Ç+§xd/½ün]_NÚâgcxòÕØ¥d}Å2ÐØ#˜2üŒ-êµ/†å.{ù-Ü`P~‡ÊÃzЃZ°jŒBƒ~'ä°*ÂØ#¨}°öG·°Y—‡þQ¶uÇÒ×mf2Ìð1žïI/
253
#endif
254
¸+4µ@9ýÐR|ôH•ëÚåx£+낾¬S_rQ=Q…fq²ÖÙԌÍwåÙ+‰º%Í"h)F£5
254
 
255
ždìǍî—a§À’–óÁlLQnq>^ͺÓî8śhö'ñãñôho6E+Èbfýx6º>–ԉHH=Þ´
Yôö÷Ø@ƒ;‚ˆ¤ññ4´˜~±±oMó³xû·§d×*閁·Ÿ›Áñq«ÝÑ'"CŠ9ÆÃÞuü×òᨩ%ÿR™(Kˆ„¼®–$;#žòÏ›Yz=¥ØòĺÀ–.oÔd^»jâ>‹ðbs½•bk1ûÌ,s¤Ìõ©^py]ztâ&-˜~Ä߅ÃñÙáOl@•\Š¯•&aì3½CÓfüÂ-­DÊ	‰
255
#ifndef WARN_ONCE
256
bÊŸ'Ñ8p:òyÄhP	•KyüäÉÇq Å@íœé¢4Üúԉ*‡®@#B܂†4«a¨Èà\⧀ üP…FÙªJ±ƒRs2ò-#Zli!_\+l‹´Kä
256
#define WARN_ONCE(x,fmt...) ({ if (x) printk(KERN_WARNING fmt); })
257
ûZ±ÓŠ$YçXtXÙ ód³Ñ8ÅeM7 Ù§àýiÚ,ÖÇF(ÓjÞkÒK¨nÊþ’ºÑ þ“¯¶xuªÊP”b‰eʘ-äšec¥8`VyçŽªò¦Ï½lç›Þc6ªÎCwk%Ý!ªG Õ@k	Þt¤ì}Pa„PàƒuxœxˆPø^•hÆR%X–‡Ê¬Þkød›$
_²~0²3}ŽM¤šæ¹])«`ŠXSâ,?3¼®2ˆé—ö”aCGs&¼Xí#=º+žÇ8ê]¦§Ìã:bU§$ÓÊþ~«ZUpeŽµ¾²¢ß·Eã^î
áÊ6Y9{Ë<Xót–¾
´›4אye…›F­dÓØUâCÝòƒÌ´,2~–¨&Sòc̶ëZ¹ëÈâÑvKèWÁ2àV‚€Ñg4Xԕ,ŸŠü›¸B‹úz]?*\Üëæ9Ÿ§×}¤w‡(æŸ6²ŒÓÏ─“2è“Ñ$½“ùÈَTr#ù¼!Ä>´å,YE)aL„UɊÐÒĚM¸Öé–4ÎѺ’;)å½ðʜö}Y‡Ru-n:Hså…#I)`I4&ýU;b……F{Ô¤C+´%y
257
#endif
258
pœÆi¸/f	ž†ŠKÚp	1™M¯0èœÔ•­ír^ÉDÖ3WmeÄbÓϟEÖJß«„P©ì{‹&þ‹‰nœ—r½=urí»ˆ~Þ*{o¯ðv+ŒeLY:".ËKÔyà’eèSþ6…i°ä¶
258
 
259
ÕdB¥ɶÌ$Ðjg>{“ÞT&Á„}`Àbõ©Ç>b¥Ýiš‹ZʧÌþÅÑÙi'x}ü®ý–önögC÷–qÈ.gɝ©:^Õz`{ѾhtšOJÔuš”c#J:]ÿ*kÀÓw'Û.@Tá&Ô/ò9-6-d¦\Ð(ÝVÄ€o1q©¶U߁¿u/Ù8ËôŸ¢_Õ¶V77Å'
½)îd:ên—a/<E‹414—¦íg?º@= ¹Ã»/ãWátqá,â`¡‡ãÀšÛ^Íȟòw<F…5Eµ6Vu#t©RøqԅíùlZº0
ïΡ©½Ï@*Ÿ(€hoF–>Í_NÚ-ûñPšœr´Ïh˜£0ÐC““^œ±°ÔšL|MÉÊ®¯¥xHƒÇeœ’ËlÒKæä'awŠlçÏ¥·—þ,õ2Sæ’ë'&eA2¥ÈŠ,BÑ ›—þþHØlË0-×ëYðüשF>3ý“OUW}¼y$²hy3”¿ÐWjÁ)/í%ƲábÁ&ÜÒlÐs4a„…ßêû9¥$J«á‘¹êóxPÔÃOzqKš{êdè׸’ý²U5&÷bV6ÌI‹ý
sa„ïù-ßn™Iv݅•wDƦùP@“–F<%ÜfJRl¦'Û`8!¬†[pº±Ä–ÂíÎî ÖiÐg 3»´üã¹-6¨«¡hKf!?™áCdÁV *ÐeS…JŒã1gR‹ˆu±‹‰Þ'<QÊ?€´ÜB	Ê
~"œ\¾nÂ>‘Ì=†Ä‰gÒ+<M*‚ã¯gûLä™Çé.6+pØ(ÛM"ÇMS=ìKÛ³‚XyÕr9Þ1MI¼Ë@TÈ*b·œ…òQ[³âԙÔ|©È+Ysm##gqý{ºˆÌKCÁe!™y M¦#íiNê$Íhè¡MM32“@ÍÅ×6ï+Ö·Ø>ÃòYî0x3La°xÁBeG/ˆð
ÎP´P#¦F݄á„×Ò$EW™Ô@)þüäÐÇÚn`Ïü[ˏVÈ3¢9<Ê­÷Æd¦Å_ôÉ¢>JrbC]mÓÀÂ_RˆPbŒÈ X:#î³Qzd4
259
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
260
}p‡°ßþM¬ÛJÜb£“û=¬•3±àǃ '7^8î‚/κ· ×9µw)¶›Å	Ý+;Ïñ<ì¢aË]¹•óŽPFRñÔ/Ö£4eöó°+’ìà’vë8•Ì͍ª•7.hÌiv÷îÁ‹v I¬÷Pú#ñ/{©¶*õB•²©QAŸžù·åî³ZY–»‚®	¡ÑêbŠ¥Î:­×¿°‰iü¹öåyCý’³ã|a„è¥${1`ƒ!Uà…@ÃÛ>ˆüoÜK.w•3~Îe9eãÉBˆ’`ÙêKj(‰YLϹøЁgÇ­—oAéÜ_¢`Á¨‰çÏEëüçÔ/eñYX)Íc˜‡G™TeçT.DßÃuXxFo@ÏÛ4e)R®¿„&Ҙ¢L}ß:°ºÖEpvÑzÓ:m°ŒT†Ûãو^m°˜1x(ÂrÑ<?þmŠ²~(ýK8VyC<û„v^´Y y¢;¾ûؽ“4v«´wœ%>PºÑSŠL´ÍèåŠxóú\ž •=1š™x°ù|œ*¼ˆ‰gùïã5;´…¢F̎1
260
# define IPPROTO_UDPLITE 136
261
£±—ÍсeÓ3¿“‰Œ…óŸö)KŽ£BeÙëá#k˜E”ƒc ´ÝÁàèͶ«ÑÄè[ˆ$ Í–†*tŸ‹Á	0·Q6[±ª0
'CZ)å%Û䬍
261
#endif
262
µlx
262
 
263
ÚjLˆò¤fM{ò­EÆ4À3¯å	œkãh›8ÒLe¡ûxÂN¡Ìu˜·øáEäI®t×ò)U|î©.v¼/³Y1Øm׺/.>]u¦Å=O=ڃ»ôöÐ|ÞüÐU
‚–ց[f1_ýrà.üóÖ _=°4,®L«’V!Q¯îU·kôDg±ÑÕý^ñlã;ñ;Y—,ݹ»ºs/ãx˜Ó‚ìøKã>-¯ªCÚï¦d?¤›OöæÀɬ#ÑÙ¿J’ƒñ)•h°þe.€)üHªˆDog՞rœ	םÄEOTËsPS@{½ãþšÓZ«
W½ë¶R]°;µ¬F2]‚Í.蔐UÃr½a ñËUM Lo4)­Á\Äw?ª‚2Y²é5·5¦ëp\ËøÎû£<ŠHÂÙö
263
#ifndef time_is_before_jiffies
264
CÚÑ=©ðm0ß³ƒ¨áS’ÈÕ8·x>LS¶¯v0·ÝaD7"”õñ£$R>©Ö¢zø¶yøSðºÑ:6rT±Awá.A«{8</X<«ûՖeË/ûÈ…]ôÓ1˜
IùÐ螡õSm‹z©šYú³T:Ég?9'óí0ýõU”–>•EiëÓÓ-؝¾|)à“|œOcìïË(¥ÚéكÀc®i5o–³Úžvˆ\÷§Ês%ä<Ò
264
# define time_is_before_jiffies(a) time_after(jiffies, a)
265
’GóV²v0oüíg’ÞaòÌk4uFŸmÛ,qÊQƈE#˜H}WMÛ:È <jwÎÎ;í}¡Ì²TŸl•³ oÏÎý µèÅÙ»NëôMt7zòV9¤Èb­ç`›mé¯#»ƒmâÝÉÁžHÄYØ<½¯/oNš§ºŽ~Û÷ÑÒ
ÅYàWµÉ?šºã`ð+ÀkØJƒFT5ŽÿÝhFž‘ÆÀJÙd|ŸM;od“Þ\äJbT'ýÊR%×;ç8LÚÏÆ–¬rHéöê–3ËT¿ÁppÈ»õUËta¨‡
cOæ~U?]§£¡5­YMv`ü€
265
#endif
266
:XÀIõþû+ n+8( pÖ7‘2À‡ê)¿Á¥n·âØ¢1z_ÛÞÁr5*w›¹3•¾éuJon´›‡œ¾÷“·)¹ÓV°5LÜ¡Äãö…JÝÂÔ]JÕå	rÒNÏÎ9à¾çšÎΎ%à.¦>åÔSZd9}§ŽÏ(ãçV»ÁÉõ-‚¯q¼nžJp‚®qûN:ïqDG­®’%%5"¥ÆÍû[ûj	õmØ6
Ü£dÙÂ֑"œqs#ÎU'í2nnçi»qÞP
zFÜÔöÑ+•Ì•rCGGÍ_;*‡Æ .ǺsÑ8–9O©±unlG‘¹C=S—CÙRMÝ¡¯s[['­Ž¤Ÿ‡­Î­jþ*ÁŸíøRk»O}ÉõzݛL„l3ÝÕýB°ÛLô»‚•W&ä^òÛ!Î82èN§xH‰†H“Û•Êïéæÿfm×Õ¤Axut‡VKOPq&9“h¬ é51®dŒƒl¶²±#y¨m9•É<h®
266
#ifndef time_is_after_jiffies
267
‰ò +ñÆÄ
®i0hY¾¸Ø§5yKÚÿ`ݟ|áÝ œã­Â:ú* }•‚NÕjœ6D?î±ê‘ €˜Mp}íŠÞ´ûŸwâc÷n_zŽ”dضhxÚ݆›ÃK³F.ó›£äjkokëi•DX©¾U«•%¾–臽¨Ïf“ƒ˜ŒMˆž ……$€\Œ»=á؟Óxä%caÔ]ïöÆÖ³ÚSY»DÖF
3¯ô-¥GZW¹‚6ž|ÐOh(pk]¶Øy@û9fØRI~@Óí­²ëÁB­>5c¸ÃÙ¶\yÐ	ú y.c‚º8©Mt/Œ0ÄH_ò[f©2‚Vööè"8iüJq–KhTZÎÊc´MDN¦ý…C“öœeÎýÌ­sΤŧî¤UÖÐh•2ˆõäæÒ;yɛƒSpŠGè֞È7áñHåzãe?Fübï[ó4F„#L«1øÞí¯z;eɘKŠx%
267
# define time_is_after_jiffies(a) time_before(jiffies, a)
268
hNÀjD0‰éj¶D-d_^:*Šî
268
#endif
269
‘âñØRÎx4bìþB+ÍK-ͦ)Ý®[âÆ+i*´áë^Æ·JôL(ِÅS(]v¥_1‰P¯%jN’×$Å_1µÐ‚·ìX=v†WòeI¤tGq‰’Ý)Ý/ʙ`]!wDcÉ ‹'„¾ҎP¥Ý÷nÙWøÌg†G€æ½áÿâ{œ¦×Á$¸vÇ¥€‹PŠvÍ$kQi8ü¨¾Ùyœègì¯2¾ø<˜Æ‘~ÊÓü„_)â×U§!…aÞߔ ?a
¡ívÙ4zzßòâ¼BƒG|ˆ¦d¸Çˆ*hŸÿ1ijP™{2ZJw¾Uù®‡µ X¨Räb{!‘¿1´d5ë%ƒtñ`X_bø<fBê*ÿ”åÅÞ=BiÚé&$¦±£“°ÇõœW)«#X<™MxK%ò´Ì­Ô•} Â~8I¯I@Ñ	"–Ç‚Âú”ŽÒ®¼â‘Ñþ`pðDG³Ø$/®ñN'±fi/Җ¬œð)@l҄‹ZFA°¿ñÔë꽬$Ÿva—¼
269
 
270
e)C7›Ó›þ{Îà—~Fje?Èóo›§â¥áZÛL¦#(­ŒtôHRJÁd+4ç c‰"J1ñ7?ŠÖ\¹dÚ˗KâÙ´:%íQ¹ß°ë‘†TM=^aØ}“S·ä¾Ð0’†’å"ӏí‡
270
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
271
rÚШÐR{Íþ¬o¯­Ûi“].9½¯É³<E¹—&çíuE`;‰|ç*;n’­¹½Æ6Peá¸×$d:Ö4oû˜zEž62[? OPNÐi¼iËH»iÕ×9lQÚ¡“éxX¤4í´¾
271
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
272
iOŸï`~3£ÈÌÆÑext΀8¹ÄüVÜ(ɞ¸zÊ*Á×
b¨0ñþá"åBÓó\8kº›‚k8îqLÛxIw	¹^ÖU:½ü dxßÁ“þ¿-/Ñu׫‰¦ïpî1ÝÜ˟?¿T˜S-yH?
{!y“ó!µ-[øœ»t¿Ë²|ž]×'8®Æ¹™D|Սct-R,'`Ѭ²=Àf°Üµ0P…¥çÒ·nµï½¤yî¬é¼lËkÏ\ôÙK/ÎãTPŽ¦˜Š5™1ð•3´Ží\N֟JFÔ¯‚o˜¢±“ŽïH(~ܯUxë8¯Ó¬[2_cx—ž€gÀeˤˆ-ÛZ286fl-¨|áôb%ë.˜Ì†ÃR4„;4ۏw¨ðÉ:hԌÏùDSÅÜÔÍƸÛp&á*Hv&év÷è¾?˜
272
#  define prandom_u32 get_random_int
273
0ô•3Ún×a÷Ÿ[փvy&܋5uM^qÝ`I]KÊOßst]šŠ£´¼ª­ì=üÔÕæ_û¦È¾©l¼ysaû$ÌÝ««i0ëü÷ÀŸ?‘ùC$U•È@g}ú›=A`ç¯ÔÞi÷
273
# elif LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
274
^=ïú(†M8–ùr'k½c€F¸‰sžœçlº2íF&F½(ÄÀ Él*ßƐG"½icu©nSó¸>´pf­å°ËGµYu
274
#  define prandom_u32 random32
275
(kÎ96ÙªhO"qî·\þA« ·W£	™«;){eç¤”˾(÷Šú
t=õˆ2—­£?ååж¤ýÐy#ÚkrÝ:ïÀÌ;íÀTlJ3å@‘˜Ø6	ãý#¹ÌøYÓÃÎó·¿µš?g?«ØEDÚx\N£þUøÿµ÷æ}\IºpÿŸ"]vÉ-	ml*—ÇPeÆUxéqûÊ))ÙHJ9S‚Âs=Ÿý'"Β©ÊöíßÜûšéq”yÖ8qb}îïü'Õ/¦7(5Ç Å*?Õân<ì/V?jÑHŸk‘8qß¼¹úêâì›×_9afÓoqã…Üÿ&ÿØFh«0ÂØÓ¹¡tÍGgCÿäþ*ªçL?²€åðçbr°‘‡Œov;Á¸"lJËÿø‘
uZË8ì×çöURݞøê øê,Á$Í×ô—ûÊÄxß{ˆy†_Ð×öø™çð]vÐOUã==zu‰)?X×
¯Ùøf‹ésME"Æ·Üê†Æ_0Þò§ËmÍŒ¡B'БsæP¾Î¬³Ãš,Ù<›ï¡ºôÍŸ{)ïÖl›Lڝ¸8¦å-‹š¬³ï.{m‰a·`pUuÆ1oßÉ>b
¹
275
#endif
276
ÉåÁöÙ6h¢7¤*¢Œ›ìº]ÞºÍQmñ‰Aþ‰qîÖDuúêE׃Œò:¢fÇQ¼¢®c¹kZª¨?,¤€ßÈ°U]sÏ!ŠøÝÉ÷W #Ô@ßC“]x­`´ðB\”½ŽÙ7„VºÚþFªË{䳛%G_H­¨º¡%Ùñÿý¢‹ã†!:é#NKy]¡¸O»öUPÚ
»ž¸´ªCAù.’úDŠaÈVÓ±`4Ibs–Œ£ÙM<¹6öýÜNŸÔð€!úª%Ÿp…£AÒ5/eŠ^àã:âŠ6V…°ÈÐuµ™§ñfm÷¹í°|6TûÑÆðæ©Ë8äuԊԟʟÒÖíä×óñ¥ñצ©-_ÁvðŸ§KÐ0YZº
\i³kã•yP­*U…·
àÖu¯7ì뻹ץx”maY‹ílä©VѼ‡tôÌS¦K¦þþÕ«Wû$‘qw´L͞€ýçK`qc¢r[O»á\¬‹A7¤ÿ’NNuo=Ž>zZöqDB¹hd+.¢sy~ZRY+œV¿È¦q¹0ì>׿þ4Ëpu5Ÿ
276
#define prandom_u32_max compat_prandom_u32_max
277
BÁ̹;œ¸¤béb#üüOØNúéÃtfcáž@[Ëéȇ}w30\Šþ"¾Pöì¸ä‹àf*¨?¦~—Vlµ¿¢\’×¹ñèZœÉ;¥mÄ´,C%ñ̤æÓ|SOç5MæìÜ•VªpA Ç{Y9oKPä&)Ãáô•bôcîºP/uWˆôfê
277
static inline u32 prandom_u32_max(u32 ep_ro)
278
2*>ÎÑmÃÇ-\VÖ›$–ýçÞ×ÿk8ôKÙFe>À£’ù¨…@)얽Ãe%8n×xÕ¿XîÍ6Ç*§“úanž9"´‡Küë²¥Ö¨ÒeŸkââwN˜ÛŸùàwïϺ=Oœ<Â/ó‰ûãGf²¨æ(2'7ÿäé6Ýt—Άõ
278
{
279
¦
v_ÜGF>è°'ÎðÛÝÅ9²=«+¿Á”Õ|ž»Ë&÷Ÿ4Qéhý\ã>	œx®››±ûøƒæýzag¯Ç¿Ÿ‡<²iº[O#_ÈR8À‚.¿›ó#fDqoפ¼¶ÄÂK~`±M„k.œä§áýÂr/ýÿÒ|=8À;¯$t£lú„5è%³Y\OX†%“þ ôáóÑÈhQ(i|,ðé­+¹pKm¡ÀO¼¾N£kdÑkàE¦X®¦öͧlù4)a|/nà-Ç¥,‰U•f&¿(Ü'Žm¯"s}y˜è?åÍêœxƒNÍl„)°kARÿô…zñì£ø—î-F§ÀµEB†”œ°@lÃf¾gôò2Ùðµà·è¬õýÑYþ°Y›dÛõ˜Ñ&žbõStÏ?á)ÜøOkBƒ2eƒC
279
	return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
280
Y¯Þ®©Ù®éÚíÉ_MÞDh:kx`ÙËÿ<ÿxs¥ÈÁ7“yTþE+ökºz¿þày>lރ§Í{ðÇÏ»€¼šgeèQÁ8}÷šñ77aäEÐíâãe*YÛó†PJ®]¹Ù0̛¬V¬ÙŽæuâË|E¤M†õ›·šåý³Û.ó¸>£®<ØN’î[Í<ôzÁÿ°ª¯¾¤¬wðWì‚`su0ë-þ(·L|¤t¥–¯“qx×ÉâòJÜdnùS™c1~|î¥,/‚ír.8ƒºK֒=Îx2°>t°›;æ1+ø3­‘{x¾$Ç/‚:ƒ¬ubº¥Oý~Ù
280
}
281
ÇGƼâÅäiâøì’Z˜A) RS|ÉšvºQš–Wî±óm­un©wɃ¾sKlšéív~Ý4pÂþŒ~Á˜…UFPËé%R1@Z^u(¤"æÿ€I„k$Äßð[˜ëŠ¡]¦Ù=@ç8_HܒcK,,Õ}C.‹Žã	JÌôŹõM#³DÊ̈́Ð!àøýd2ÅD¢½‡@
D*zb­Q“}>”ÃÙ-Ki‘"Àî‹Àq[]
281
#endif
282
A¦UröÀÖ:røùŠ/|½|™¨/RbKþMÿ-ú×¹A?ÀJ-«#4×÷êG=GhñÒðkF.”ŒÔÀ	8³P+’8;þù7.¾YÎÏÖâq±„éëx³ªÍÙ$EŒh¬¨AŠrÂ4|\F“$keRÏdŒ¦¸!ÃSëkZ¥ð´Šö•
)Z›Ýªžó|™¬zUŠ#.ÝjŽeÔñ›CË2Ù«ŠÒåÜÓqîiöpWÄGíèxq[á½¢[N?}ú`̳š˜°'×fq¼V]cK2íé]R4€­Z”™xþØê
&ÌåC#ݵH‹‡_I­a&çõöŽÖÓC˜v9Ûº2·uY¢µ³Ùó¥±n»kjå®#Ñ®¸åT1–4.(îá®<kBósaj+êxÅ4„ê=ä+
®ú;Ì®=!‚ŸIgZ^lZëM¥3Ì¢
é>|x¾™¯­°ì­É.ڕÞí"¦ÖšD[»±ßچ¸×páóËǽÑõakkìíÝvŒ%O6~´V¹%ß6Mzö´^”6Qo~M2šJÉk:vŸ»ô×y9øëÍ Cÿ\^½øë¼fþ×ùë<8¾¼*|$eí‘ýG½èAoçSï?ñîôü?¾9<ÎÛF*Ë´ËÕo©m¡²L7ónò_¹ä£ Ï@A¹ÒZŠd+Þ£|‰©Üş¿÷ÿwþâç‰z^%ùõùe'Rx
¸¿ ¦/“óùæ
282
 
283
)‘¿öÅD{mr©’Uá%.	Ž
283
#ifndef min_not_zero
284
€Æð‹¸ÖÊż•Õ–kûx•T¬í"¹­ú¥VÊô*-j›+ÖÙàøòQ i”ndU
284
# define min_not_zero(x, y) ({			\
285
"	¯h¨/
285
	typeof(x) __x = (x);			\
286
ç.ÀæÌ°VVpáPþÜ"ëWð¹Z[æe´´LÈHªŽ˚˜XršFoÞCgfÜ£rRîGå¡Xk”øErÊ~þ ¿8N°]OzÓredu’ëIú³ ~Ï`Ÿs^sŸÓÜݓæsÞFÈôΒdyˆ\7Drˆ°MðöBQ'Á‰wL$ƒ$ÊOÇQ ãyÿU­²¨"íŒ	~ôž¬¬‚`rBURê¤B	ÆÑ8I¸öÀ$Á­-͔äy ¦£(›™pê~RA5÷ãäy³Åã¤ËaPµà%ÍE0O•Úq6ótE›ñ®%ZY ‚r¢ç
286
	typeof(y) __y = (y);			\
287
&,5&jøub¨Zð´ú
©Z!òég¿‹†~ù<á%âº9³³¹¾¤PΪµPLh¹ève2@<*ôé¡©ÁtÃ5\“­£µÈ'µC:kUš•ºWàäŠØ÷Å7GW^ºàKg¹G/^㋊ý0fjg'xïÏjK¿5ŠÜbÏÐŋÝ6àçGLŽÚ+¹r•í…?]ƒqºtàƶåÞó7›Œè$r•6[”ÖkÙÐٌÆl(™%ý4‰WÎWZ·Ý}ô¢ø -SùQ”•oy`ĚË	/<õ‘{lA¶c”/Í
287
	__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
288
	ŒÖxÖ	þ:Å{ôßRñ%Hjs’Öʾ—ï§ø“eUJð¬'oéTV®Ô£p£vÜA8JßÚ+(.<À üšKjžOþ'ÑÛ*(n¶R¦è
^ÛóɇP¡e¾Oß Etàß¼Atqù;ôëoànsÎ>ZΆòH•SÖ¥»ÀL	EÎSz2ͪ4Ï`ì9ª B¯Eïù›Šqø•k`,ÍxŽO^‘ºÙ}ûÍÕÉ÷Šrj|,¸!à7%;3Μre:ÇóÑ,žj¡×Åô|»ó†N3®Tþ- Ú—¦÷¾î¾%Î௲BJ?³ÇCʲð‚/ºcW÷D€¯õ(hý[ãòåR±Û+sšÇóYô^}ùEüm7óyUzm±²u>÷7‰-õ.¦Z³ï›ÍJ(2£&ÜÄÿÄŽüÒdi0V“3Îô“
*Jí’/ô4Ö²˜fd7™2ñxñ˜aÉîpÖùÙZHßÏ|"pŽ?Ï#Ø
288
#endif
289
pПÌ‹KJ’Žºk$þ…ŽS8ŒØ…¢Èí…%ç™[§<âùôÓàé3qï±R¾A»ež½úŠØ·gÇß¼9©¶ASô”‡/‡)èP|+˜ÕÖÃV²ª
{:•eó^ö1üož
9}®x1ùæ05£õX¢¼óìh¼bŽÙ҂="¤¯œÏw‘›1 wj×ÅF¤šW+/ðv¹hAºÇ
L³‘ÏóÇÙ¡¶èm½†Ë=ÆLtPÂM>œq~(]x3z*e`ã?îZµ&ïø¢Söñ”ísK.ù¢ÔÆBE¾´•4$Œe;^tǟ€øœ¿Üã©M#÷m‡4À~\(ñ_ŽPƒ=
289
 
290
98ϔ>X–­I3œ›“Ëþç/ýˆ£A¾0c~JLËhBMËü),Ò}¸é™m.Š&wzÞ=¿81`¬bÜ]öЛ³£Ã7Ôäê'^]|wxq¬öáÅw©‡%ߝŸ‘FozçÑÊÒx\’cå_¾p»ÿϬܯϋæ„ó‹³£î«Ë͜¤
290
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
291
ŸåPÀìÙd÷Ä£Èd?‚7xª
291
static int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
292
j,vqjòžùo´ù|©À¥ûѱýÓ­ß	¶ñÖ6}·7·ÿš1ú´BM?Æ UiԙÏÙA ‰ƒNä,âZ¶Š)&xÙ=½øæõY%8}wŠã~UâG˜)қeÏßç7Ç¿K›Ol¨•Ÿú@GÙFW@`#Ò(I0ÒÛâ"<©r¸u¿þž…c÷_¿;Uÿ<ÿm`­B³Éý„µVh½•yÁDƒGèŬACØ{ÁÑïSýû
292
{
293
ŠY6¬‚à.›#r¸ëßᮓT¼@¤Ð_Qç(í»?՞; qyè²UüµábúÛõwŽÄš\w5³6ëOxÃRþ{›i—ÿ˜¹GnœÏ‚%#¡Oÿš=[7žÙtԍF+ÃcÉ~ 9fÇ	»ïh[riÉÈÙeÊÊ[J·jV3*KʬôGQ˜v‹µK6Ûü#8RØnmLh0«7¶¹ji2TÃy%h¼S¸]ÄpOûÑxô’÷bg˗‹¢×nu‘K“ù¸‹°€ixeàË燯OºR›5ØГC³ï}”v¢-¥VñØ­½†ßã›É8É<¸]ÈŸ¬ée‡½o_ü܋Î+ç[t_<TŽµ¯ýu”þ:š͖8ûqÅoù³ÕÔåáÝòâ5:QBõÄ6q`¾÷¼÷†1d}$Ÿ=•y
293
	ASSERT_RTNL();
294
Ý0Ù Y£Zr@Y”¦¹Û>x€9¢ñ`dß'ˆ„ƒ·¤Ÿ…{#‡é-r|Q•ŠÕv©d›‹	Nä h™TÌÕºyÜ2»â
f3ghðû14‰ÜðûqðͼÞ7$þsÀ£÷Ñç´ø/áO¥†””ìÓ:|yBÿ¼<¼<!"8>ùžN¦{ÿǂÅÇAs„Fÿío¢ik×0ã,FÆ?ÖlÝo¾8ÙÓóÕÉáñÒG3&W¹ƒí¦\S*Ë_ær~æ=÷̤³Üíeƒ~B?uÑM>,Ü¥¥™xæe'gD@K¹‹ø0*XŒèE‚
‹ÄÌõ컂:äŠo対ü꟒º•E?ó}Ïì)ߖå¸ÔçóGÛã '4Š×5kłÆe'ZoÝSšm.—¿<ºzC—ÉlÔU×\D\½´üCf¿- l`8
294
 
295
íX0P75¯Û+¤EþäÃ:lª#"†&“’N÷i(¼×GƒÉ“£U½9îjGër=møÓpv“
V‚U+éK¿K»Yq¬ØÏ[…àáæחK­UŽƒ5¦4Œ©Ôô{éÄò@žÅ€+³¬ƒðþDHžû@cJâþ3-<d£ÛG@-|YñŸ¶’]±^‰ÇF¢ÂB/¼/3¿1kœË¯ª,ÌóåIk¼(&¹GÅûSó›ô/oQüg>Zx(¿(…/+þÓvQŠ-ð¢<6Z,ˆ÷…ßÎb^J1€\§¦™›Pñ&hܛ±ùî£Ü—ù™z_TÌSûÆ{K*@¯èíWÖ¤›7](ï’üb¯ì=™¦ádŒÄ^Z\j-k¾ŸÎ'Ù¿06û‡¿Š–$÷]Å{Ö-LþuY›µCÐ}wŸ{m¬Üõ󋳷§—Gb¦Ï{â8ã8닕¿I™yû)ƒsàAW?-¹×ÇÔ0Ë!åy՞J!˜z*8Ï!*k¨À-í/×hÊHž.«0ì~G¾>pâžÿÆrÄDXQx+×q˜/Ä®¾Ÿ9€˜ß€>”³˜Vòe8rߕó7;Ê*Ê°ž¯–7·-úÊ6‘+~ù©^AÈûð-óíoæÇÕ¡
!ÝqٖH™PÝO|N§Ê„¾;î¾zóÍåWxhts²¤Ñ¹ÍÀ·Ì€ϓð=-BšÂëËËسÏòäᒟ‹öV>2íæCé
295
	if (!dev->ethtool_ops->get_settings)
296
Bg… åYî—Ê=ùû±uw‰wVØ47d˜¾o©Ü¸ÚÌ·Dpì<ڬʸÒjãÑVŸÖ /»ª\ž¢H“‡ÒEÃk|žFt‡?TÖ¯;O8Èb_z.ª'ïÎޞ¼]p¦u»ÑPHø‹ŸèOS-@²´¿?–ÞþO‘Ö廉ßC0Kóì½U¸‡êž„NœÛ[ÇßÄ»Ÿ ^êkõ†ô–³ÒjЇ7i2,w$†ÅÿIw‰´uËg×I+Ñ̿؞ÊŠ,àigя¥’@1ôMæô„~
P*2ôÇq<î *Èî_ìw ‰þåϟýíNUw§Ú¬5·/NßžÔ”Iü1}Ôégw·ÍÿÒOñßݽ¿4š»»ÍV»Ýlíü¥ÞhïÕÛ	êÿŠ˜ÃI“d¶î¹Ç¾ÿ¿ôç«h4J*››§Ãà!™÷1œ$‰…ªäŒVFl˜U’äßÆ1‚uÅ.®Ành‘…R½n“s¤ÏD(ôžuѬ³¹‰šÎ—ÉhÎÚy£ƒ:» ¹ê
¢~´I"ª?4‰&~̽Ñ쯣I”†£à‘-£`R÷ül}?ÿl«Žè¦¿‹‚ûí$÷N%˜£¾r ²™tWÿQ†|–û‘¼Ÿ-{
296
		return -EOPNOTSUPP;
297
Ÿ½Ë÷¢(„NÆ´l¥C®n…ÙC­Ìo%ã)ÀUMˆ 6à§Ú6ÒËãk€…W«¶XÕ3ºeW‰¡8žPž æ~҇^l™mi9I«—ûð'Ïf¸ÀVZBU@¶ÛJ¢’Ÿ[‚bÎVk£öb+JM4T3Œ£ìšKœ…×–TB|žÆQWø*@“unÒS•4•¾\ãÅáÊtŸBxÜÍ4Ì2;Cžt©Q“ç'D±%iÔMã§4¼ßR l$QfšÂ­Íð¾EòbÒ8'cFZ'ÈtxPýF¶åÃu{&OŒ‘p„R]¨ Eÿʧ¦2WP=ÜȃêŒ4ùû £P3¨þÓʖ·͗f÷^4´Ý¡ŒGÞÏ
„ä‘©9EW»w}+UßóÞ*6d¥êÄe6+g€S´J;a˜…‡­¦ÍPfÔÀ„3"t*ÐeJ”v&²ÕPEò47OæµÇø.€ô¬ ¦©9Fô
297
 
298
<ý~î3‹Fˆrü&çlM®³ZŽ¸Ð58’˜/ُ•Æð™”âìia€”)‡‹BS{8rDÚ}ñOfÔRP/&ïm8Sª,ÓqâÏyæ3¶Í™fÊlL¼ï GћáxDêÜ8µä£
’9ZWÎÏèÄÿŽÞFD¤È™ K]±•rdøî¹h”Ùyëݧ¶’1¯À$™T‰¶PÈoÀèÈ2jnx¦átʇ-¨òô°uœjFÓèÑ ê4Hæќ²Á—€S y8gŬÐ̘È'‘ºRFH{Éé–Uà|m»
à¤O(°œËW5#LlfŸ;7æý(ÑÆƈgu|›OºWš+î•-t¨×lj¶\.	¾Qîj<.Ÿ9ƒw̖TCÆ4(fdÛó,Ýt5Æù{|(s¬NÁçÁûü`{¡Gjä
298
	memset(cmd, 0, sizeof(struct ethtool_cmd));
299
¡ê@ý‘kK’FÊà,Mʸ©ÏfkØ«X ²‹þÖÐrðl¨ŸÄˆ4öM%¹:<x:†ý(xf³8¨o·šøÖ¯œË”ϹF¼r\¯½‡§¤qþ
299
	cmd->cmd = ETHTOOL_GSET;
300
µ*nW›/’YãçÂsÌtøa|ñÑڑ´x=å-ҔhæˆúÑæf«œäoUÃÛ\Û,¦Í¤p9vTè‘Ù­,Èv֋'Û>ßoXF°Ù®‘¨aî'^³Ì¼ñˆŽñ[¹ÓF³Ì
Éz-é¢ÖÞæÓÍ͝ZA–‘æøÒChÏ$wõmîÖää<Þþ{Ò} Žq£žš€’]è¾÷ëE£¹W«Óÿ5:ûõúææ^-8Ž‰<¥F¦¹8{’Vvý0žrGóBx×ôæ·I<
300
	return dev->ethtool_ops->get_settings(dev, cmd);
301
‰æ§™ýqԋ©³ËŸçQôKÄ+ Žº%É-òc½F*=žïfòü®9qOá&­ÜäåCpHܘ„ÑyF#û‚‡ïËqÆò©5Ð ՈÓàH°A4Š®C(
301
}
302
!§(Óa™ „ƍr ¹³ùµ@LƒB•¸!ŒÑ‚ÕåzœÇuzŽXÃt>“/8«C÷‹€Î¨0žÑB÷Òº·ÈςT“@4à6(MºYqe„#ºièÑ㋳s½u!x”yPµZ
1.@æ ¡à Ñ¤‚óͧÌÈ`7’Yk¦Á™àXÃèç9‘X&Ò_Ln)ÿ*¢ÝìCölÓ^\¢H2±¬Be2y‰Õ-öRˆ|$8“P-úK= ÇD˜ÃÁ¬5æÕÀD¨Í'èÿêuªe7œŽ‰C¹··³Jÿoì¶ëEý¿µÛøSÿÿWü|üÑ6Zv³ù±ÀrKZ´(ÓKƈM†@67ϯ¾zñ	þÛa¡ÁàњüÉ¿ÐÎýè¾&–™-Ά`x×6ßj„Ë‹ŸP[ÙöÿÒÁÚgKÂTkŸ=ûG©öÙ?ÊÏjŸmÿ£±=ÝòïƒZÿ'ôùúôÊDµ*Í¥ç
¤¶IÞAÕ}püˆ8:V‡ª?û-Ø'žs.1Óeƒ6yÞ‹µ-ý´9Œ1ÎkÈÖ,œÐµæFºrµdЃ †y¼]ˆ?¿ØDwÛTk~ñiCüƒ†ûÚ7×_µ:ˆÓÙ=mßü	‚3úxö‰yéY𣝷7óOþË<ðñݯô͇cn¼ÞxŽÚZãYðʹ?6¨<Õ·$ Á‚³KÆËlUýD¥ràø›2&Ëx:{¨=6•¨“ϖlÛ?ž}b¦ùgÏèY˜yuGĨo’—¸6 *¶ðP8¯¸·Ïrõ±Á†#¦¾©Ûž±xÿjûïŒe§ë)ÿßkì-ðÿÝ?ùÿ¿ÿ_$Q6¸j”?°ÏüÃôù–	P\3K’N»{DÙþ됲½÷ßG}ðà›à“ºèUD"6ö@È$َ~ت5µ¦~¸k?l×vÝôŒ>±ç^k»_½OÜðÀ²q<B]-U½4ªoO_ÖÆ››ýáõ‹Ry“gJ\ýJÎ2:,YÝÂRðì“/Ÿ=§SnøËG`ÈVsþäÖL™ù
"zŽ3¯ëG­>>¹# Îþö¢ô,o*¼%–üÂkìYysL"Òæ&Œ;1^•JkÁ矟œ½¢ÆÀËÙDSelJ
302
#endif
303
'3þXmžßÑÿØzeýÝFÿÓqØäy”å>…ÊÄ«[E¬¹ÿÀ€®B·”¶ä£Ðçüύx¼ºÅ´\òQÕܨ›X$¥Ì˯Î.®|ºÆ:Ò>èe&’~2"å…Ö¼„ˆ4³wÝèõVë‡ÆóVsüɗüûøÙæ¯L±ÐÆѶþð叿ÁWÿԯГÿ´Ë¿ØÀñI|òÏü÷üQPýŽñQøèÒb“Š„D67ÿÿßËcÖúÿõz»Ý.ðÿV“®„?ùÿ¿Æÿkí(bøC~_m×ÞaFÿÞCðyØë9#•ÿ6×ÒùtÚxÛªMRâÄTýU|}8”!Äà3¼‹f¯E`§ÜTˆç¾:ýÞÃ9Sä;íGåc%ŽX(Ú‰YÃùHRº¨3º€$8A‡ÏF÷´œÎœ‹Í¹Jæ™ó9ÊæØ«~6_ÇàÉèÕW4ðç7@è{±æM6½,¬{ÛHÐ
{t÷hÊ& L Êf¹u%úÞ؈‡l«pÃFè±ÚovMìŠ]DŠH(K¦v_iJÀõ×½Ø÷[ÌnÄ¢3£‚ÆÎ`:U—Ø$ºÅ×q
çé]$ˆ—>(‘šr¹Co¼<R?ÝgÛ.åX°õ0æ£ÖñCÍ§2Ly).å؃î¶åq[2Ñ.«Ç†m&|A[z’†¦£y5.„•ç.ÎÌkp^ʄ+ðíðۆáÜDO¸¨H ÆÑhIs½(cìžžû¶c6*ÁhG3¢4¬Ñàá	Ð7d¸zj´¬sEËô:f%@mû‡å
¨U1ÖfÀ¢5•ŠÄ“BžoÃÃõöð(Л9Ø?݆WPyºØ³?‡WXŠI6Ò<oEPXAKbeu›í<ad•7Éõ5>-½;yS®É
n¾qìÄ¿À÷Äq©ÝÍTЕÄuå3,œv¤=~m—"Ê"$)iÄqdÓ¨³Å»ŸÂ†7¦Y4$U©3ò;ÎA¸—²‡l96‘½[UØeG#ڝ—•óCy’—ZDBgöè?œ’ì1Mcè£Æu؏ØyŸyT[¤v3Äp,‘Ñ
303
 
304
Ó̀q«Ìó„;
Ðoá„á„A4 .ë,ý,8S„Õ+Ÿ”ÌʖÙW©+ª,’£1±á¨"S1bf(D.np:֏´`{;íÚ×Ìñd
304
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
305
Ø)˹ÆöV\å
N›·Ï(VnÇzÏ,MÅzmL–vøŽÓíãá1Ì\ŬÄrao¾£‰_‹” Îð¥£wÄJB@{³[	ö*ÆðŽS}Ó#’˜×H±!pNâÑ(”[Hjæám‘®2Ÿ`KÞÚRZ”d(Ý§ñL½ŸP<ÊÌï,§4'¼™Ê[9ÌIa𕵛OªüG‰©žûåü‚™÷_yl¡$Ə>”K΍¯aˆ…Ïéˆ{3lè…}ög‡%YQŒºòŧNÒðe!Jš3+ˆYyל0ªµï±£@3<008]73xp'4¯ÒgÑØž#‰r	Ï-ƍáhÄÃSüZÆfñͦ-àhH
305
# define ethtool_cmd_speed(x) (x)->speed
306
 “+ÉÍpNÂÌÞK|4ûƛ]tfä#EŒïù;Y½Øå ­ñE5ÕC†L[¢sßµˆ)áãjxŠQ†»V<	åìåÕáé;¸ŸÞ^\^Ɔõbý›â'l5쏣E¿u¶·é¿7ó^6u;$ioÛÓØàèý-
äc_–—†xúîòêð

où°x(¯™ñòÏ¢)ùgŸÁWtžFS,È×"ŒŠ”ß8õbàÈ#Þ£7^E%¾*q”hdž©Œ¢{g‘xÏ׭߇‚5ÏfSZ¬’”ÁPD7zÒ±|èZ[mÂ#bÑH[ö}Ý ˆ2QHȁNƒ„éKxSG à¿?æËÇϏôpÌLù˜ßVH;øEڞ\¼U›àžž¹'ÇÕÀiXj~¿_ÎÌ2UL˜É ¹×HàÅåʔGИ®%”K¬·ÜEMýäC ôóǙ,0»œ‰çÌÒ¸ÇÎʭ̊±§84}Pa8e1lSŽ{°Ý#,P§xÊð)¢—*~œaౡj–öaŽØþ8èO¥eŒÕŸæ@	ªéOf´ü¦jÚKø…XƒKÉóµë_‚/ìËüÚa–Íǘ-Vo>awó @f£Vh~+£I’>Èå+aâù[>v¬'£A®ëæĶš¤NDÝk3P’GFZ<<ҏy]ßéú¤ƒ ®NpÌÔ0äêŸü—¶°Oz'/; nê2„’^8É5í`
306
#endif
307
¨‹ÝÚÊô®ÙfT±fµÝjÔ¢i³û»ÝÝvYyrf±­ïÓDë{w‹0ž¦c<§ª0òÜ^
307
 
308
€ ¸WgÅ\þÞDéì…ôr{]UúG©¬óÓÿª=ÆÐ8TÌ4hTX]¶,OÞG<ÑÕÌÎiÀJ€–¡­fcrEñy2?¤ÿrœaŒ°Z°Åíé¼gÃ"¶ŸÆìò¼.?«õ܎~+0»E^ç·çíÁîÆ"8ñ³âÂðAà‰€‚µm¡‘–£#ÎÓ^èÏÁ¼§©kʱ°ˆ’€$ÂB~ÀçMB€L`®g€ÈÆ*ƒHeðþ›i™®j†\LÃÙm<õ+óQ,®,3»¸4Þ²Wí“«ùÅmX¯ì¶<e“ð>,7=Óõwg±[¦Âûûûš]	"?ސv
Ñ©•\`”ì!du]fŸ‡þ·/Þä"v—?°,`wñ©A4¥¾\¼2‹ØùÝ†Õ/KuÐm!YÒr¤!?7‘r\fvCw Ótì´SùîÅÐâcŽŽ^\÷ûՖÝ-êD]UæNä†ìÈwæáZKÛ§­\‰®±ùLU0Óòi-ª)œ­QÎLh*M—om¾óâ™nÛÏufZÚðO1C,½.âτ”;ÇùX‚·¥%?ZRß3F'¢6Ÿñi†î(?NUܽˆÚiRš³®2Ö»Ÿp
308
#ifndef ARPHRD_PHONET
309
óޝ›h451˜7RBD6ž#vo2ɯ㔃+ú	âôçY2…F«'l!6HÉÌRø’#—ÎI
309
# define ARPHRD_PHONET		820
310
Ø1Núó4&é^¹öDhù^Ûû…×
310
# define ARPHRD_PHONET_PIPE	821
311
ؔ:uÐÏb.1y’ÍŒ$8gëŠí˜Ä#´Mgw§f…ŽÍ„{ny˜9+ÊîüH—ð½»0°ÀÀujD£9bµà2³~2}»J±rá‘Æî²B£Ò¼¼~͐V÷™‚›¤V·¶Š Q²Í†-õÊé|ãA‹‹ýÍZö‚¯Ž”ÅnÂÑ67<ñÑpµ~5 Ïÿ¨òóô¸‚.{ºlìï
311
#endif
312
®ìGâߨĦ"—k	îª œÏ¶Ê	«Ö
312
#ifndef ARPHRD_IEEE802154
313
¤fÝÒâ*CÏ1PiÒ5¥”ºUqqÛ©w´ìËÃBÃì7ä@d:ç
313
# define ARPHRD_IEEE802154	804
314
£BãpX¾ÅýqîËÂîT“|[{¤ù˜õϦC›äÝÆÁjߨ)leíÕ£;‚-<³eÇ`[Zê6Û!ß©ðÏ5Í}+B‚ì¼5þ¸Z˜^¹Ë…1ûNäÂ2yv1ðdÖì³nÕ\C´|®ý…®sžêB×9Ç©
vJ·UΊ.=ÓÀcì0äfÍو%6¦`|®ùQ^;Þ]Ó*¢·y™Z’iyÙ¾"7g~æ}3gÖÑq=,ÌX½ðëæÊþñœ„Qœ§qƒåS篚ðŽ,`G›øµ"ÚÁ¶?C}1:²¤íeD9µM×Ô¡æÝH{œÌM"K.o-?jœs°¶k튝$~!ÃRsg·¼°2~øÁºåÁ´Í³¥ÝFÙÂ÷ù.>ç&¹I¢žÙ煃³àÝù7W’˳„¬¿HúšI†AJõrÍQSh€÷êìòÊ6Mc÷Ÿn”+î2Ô]3!ÐÜ+Ë6¹šŒ;®rÁ`ƒŒ04wv–0:RXDeéÑŒ…ö^XÜ,T.œZ".ùb!ÿÁÔbËÄ?¼{ù‘õE¡o~Ï57§Ó¡Kµ€m8¤c«é`›ŸÞ6éêƒùØÊj*¥\êÊ;ļ•¦æÕ"³܎³6+rÈ_³ÅH
314
#endif
315
ÂÑ}XÍÛêäR>þúíe0K£hyÕ¼>î8Ù(ùfm{r·f3P‡Êqv4 =טÓa}Ã68[Yâr6HÝ`Ciü¥VéÖ?5›I'·Yæ5ˆV>ÀE	Ew¡JÍØ-ƒÜ¿=ðÜn*ҧ·Å1™Èe F¬øɁzÊ3^–9yMXŒÐ	d¢¤Ì(·:Ĉ,ë!¼bö]^6ó|R;Ž’Å‘™Õq“nÔýEñ>o/²9“ ±¡™C†-)wó2%mÚÓB>ëͤn°¨œG𳞱úóŒ­u!!׉š]ÝØr[ndìÿJ¤—XÏûBÐø’ñւҫ¥Q؅.›}·kgš/«[‹mr‘×[Þ­¿)µcé¥\±š”É€7J™ÚMü‰¼˜°æƕýÐ6µ¤P®¾=	 ìKU¯Ÿ­iršÙEXA
úxû
315
 
316
¨Q·™Ðœõ‚Ü-‹EÂë”å‚ÎBšÊÅ7ïØ”ÓO8Wðï4 ÀÎúJ“܇¸ÙªDŸ3š9]X¾ñ¥ùÛdEjU³¾³#ŒöEƒ8KEŽüèÁs†”|3Ús5•”1’|ïKó¼Vw.`Qä¶#ZĝKS[b†`#Mñ<Ú c>f7B4ëÛ§…AÓCùOÛ¹¤z-èRÎídì(ž4“ÀÀ½½8pÚVµIÊ«ñçóåfœËSµ§¬ËùL¾²§¿Ï8El~J‚»8ºz’’É´®ŽäJøÉQÒ&žC\g2"ä†lVwftÌYšŒdᝯÛzpI,f¸¯þ¦fS[ͽÝ}Ï-û$'UӈMQ9ý+8•ÔÕ1À›Áf‰urx#ËxàQÚȘ®!ù@¯˜i«OP2P½a‹6Ûâ¶Ø§Ípçšl$z¬£Õ $!:÷¾ªÛ§0ŸM«žo	€]s<ÕÌÇâ¿H~pyHPP;“àŒ¤°‰Ž§VžÌCŸwý3*ÔúɑvƒN™/N¹º’@3»€"kʖ9vîwþ–É[€L‰Q˜Í$&„ï7ß-Âùæ´ Ò$dñŽN
±w€6Ì[’
316
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
317
dcRÝId1A°¢îHÒéÄÊ ÕRQc>–´]Ówi@,sÊ76‘i?šòvÉNû³‹3_4(C'Û…w> æj"5…–¢P.f„ù†&ímǛ :¹{°Ç–-©ÓÛY¶-Å¥EMI3{n”íïƒŒáÙLÇ3ài¢¾”>ÀôuÍ:Ý}œ@—ã^mÔñí>ŽwŸBÈ»O£äWl7ù÷1*{6»,ø;?-..ۅ	þä`G²V‰s88³sFY©q*õŠÝAԟo;\»Ž¹ëGg%ctHµ_°`יeݙó×t¸,I…6¶ìg‰Ésæ:‹«ðuZCµŒýÿt¢'Œ*ÃöK؂þjñ™\D¾µ\÷FMžê£•ûšMºɎ~{wuqxôu÷äۓwW—ZJ1F"¢PT#_±
317
# define for_each_netdev_ns(net, dev) for (dev = dev_base; dev; dev = dev->next)
318
*r"r#mãû4¬DÈzªÅ#±”¡Ô’Aÿdwh$A{<ÌB£ÊX’0sãââ7²/c	óÒÁß&òŒx,t	
318
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
319
™0 &²h½	ƒDB{ÓsÒgÜÛF£ÛüÿjE¢,á/"®ö¡¾¾¡Ý1ޜäÁˆ¦Þ§ý9.DX2ç—Ó
319
# define for_each_netdev_ns(net, d) for_each_netdev(d)
320
*9¸+.‹9ä£x¥cÑN¯¸=(ˆªdŒåá«‘½	µ —4fãÖɞ‘€îcZÊùanÓy˜}`e·ßµ@
320
#else
321
Žî¢\üPdؕt5Ýeq®Êú½.„rFž‚H ˆ\D>¤7£¦w˜³uG	°áŒË%éPY—ÿ½]ãIŒãžz÷?s¡ñ‘cáL4w#ƒtä­§ø…îãÛxÛ8Tˆ;TÙZ,ÓÝT©Ôóú1Áfž–qф&ÀN&³‰Ÿ0šHÃ(¨Ž¦zzT¯X¨}'ã¡O7Wï³d>:Á’s3
hx\[2TÏ¢ÎÕßÓ[0?ï’qއ£Û zGêvµ¿@rËƾ8æËÜpAABtAè²M’™·t³ô!?ŕC¨5j-ÄÄÖÚøm¯½·[;¨×éúŸþ_[ûÎOÚÕÁ\^]ÒÚÉAM>“EÃÐèðßqÔ½#s¶NÓ1G$){ڌ	p+§˜®Vë6¢$B!ÁQÊÃ'½/Ê´•|…«‡³ã]´:VáΈ…æ2ëUôÁ¬ÐÚÈ2‡¯Á>¦ 9aã›Lí<Üï]³›ñ®0ÄÓd"œJ£¼ˆCÊiӖEó¥G±îsXGwÛUd‡Xù¯t$¿í¶ËÎÊq‘Í4ÍdÄJ´A­Fþ³"»ìV«éw –Å4dﶤ¦ð 8G@µjmu6d—Iň½þ¦Nϟª4û-LŸ~kmq3‰sgÍgtׂ³´¢¦iæ]Ï«oÚDÃoU^£Uç3ŒOøµê-³j¦@¼zT¸+hDw´!|Í9ìô`„.£>±ºÙƒ„¼{¼A¬rN“œÞ¤aq„›‰˜ZJ´ÃZõVT#ø|ÌZÅìa
321
# define for_each_netdev_ns(net, d) for_each_netdev(net, d)
322
«êßP¢—“_5!éPàƒ’9oE=ÀgÞá»h ¹å쑻¸OLså?Ž›ñ€ttp.Tf©ÔZå‹Ý_ЇH`ßDγ|êؾ@#¡¥«¸€w_"tT ¸óÌAE¿?nf—<ÙëQÒŒ	ÆDUWë}‡*w¸)äyL­NÊÆÔûŸcò{kù$è‘žÄUB·G¦“8ÒêÑù7(ˆ&i"eû_ÍŽ)Y·[9g“š(B™¤£®lþæ·
ïh:¿r™¿¿½Kš†4X4Н#Äý²hˆ…ET­€`ìÎÍ4Ñ#[9as	™®§‡I8–	´^¢¬!P9(¹ÓYJgV?ÞQ+½äµyº©±’[MD´(НåzÇQþ׿I’LÃæw*ÁAE´|Äï‚KÑoôš˜Û­‚:õ¼Ö¿ÑŠ”Ô„oÚ1gÂ¥ ª‚f2UL0zf¹Æ²l—s°i‡•%Xú†ô95^ûZpή®Ì†ùTLˆ„"}‡Æ冴(©FøŸ¨ƒ6f$Kæú ˜¦Aþύ·ÕÜÛk{òÉåÕáË7§—_sVn£3èíw:sóÕiªMttÞ;ɗ©ú]Â4òf
322
#endif
323
'šµT˜±z[8ˆFt¡Ì<ø½­)ßÖ[3:+µ:3Q+«·¥Ò8h.Ù%IÒQ0v†.£’9¤•ý,É±»ŒCf>3Õ$&èÍ2|3ð³
323
 
324
;fËÿRR	‹ŸrÍýŒ×U}RùDCh	Æ[«î0|AŽ·|’*<®=wEµ1öƒ8=“Ó҂‹WGÁ^½Ñ.WXb›æÂ(ÜÃç¨õRvá
WFÝ@£±ˆÐ#à ȯ
324
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
325
x\±ŸVi%-,†÷d-©½@š¼X®â„(&—KS8í>wmèFØ¿u<ò1©ÍH-I‚ïŒÛޅ-b¿¼èËø¸º¶»+ìËU‹ Xž&SãÜä*˜ï*
325
# define CHECK_FAIL	0
326
=Žb
¼ –Pmì¶ö[v4%V8ù³@Æ4,I¹sÌ®Vv³­`+·C[|oÉd¶Ü¾ZäÚ4Ìû,RH®•á7ìíeÖ:‡]d£Â˕ƒÇLÿΐä´Dså›æÔ½á§!JÇôþ˜/
ÉÉ¾UbŽ…õé[–aEÞç¬x;Õd]LbÅϙ|%¦yäÃp?tή‰®dÉÛÔM€ê¢8èß(¿¨Ø슠_qÂã>^G¬Àñ}Àµœ¿lj…™¦¢÷ðo0	Òò¤0“Fa¡5«Ä´óuô YЬÑñµ#c–á-ࡋ+Ò3ùú.›˜Åæøq®×iօ‚JŽd4™-ìn-ØújÉvô"Z&”¡äŽ¶@-~„)}§Æ–Ï–qՏ6&n_€X	r ìÀ7 +û?’ÁhÔý§‡o¬ó4¯5)÷f¬Ø';Oov&8šJ{«Çm§íIv$Q‰ô.„W~oÎQm’§ø¼2hû"¼î%ºÓqt™öi¥*ü/KKèø<å¸g“V`$
÷Öq6ã·ð¯{‹Î¿æ—@\|«%Àõ$è@Çá€nٟ‘Ò€#à‘èŠ)P±F§1¶¹wÑ{R§2‡ÃËüXòSàº¤­f»Ã’&0!ӄ.’ÙHšñ‚ Î‰N9ä2.ÿþîo—G_ósbsgrª—W{uúN¿H¦ò¹×ÌùílûJåm¾ „~‰Ò¤,Ý@CQHÔDM±páî
326
# define CHECK_OK	1
327
´î!ƒ¹üdƒ!+ž#¦èÄØtaÎK"ãm!€dYz{ŽlgQÿ†
cN߉4F¸GŸšöh³¬“¬Ï9n7³ñh{à‰*>«ö"˜{ªñt¿Ç¸ª#9¥Õz{SìE Èe‡H`xÑ(Ê×,°‰¬ÀÎ0óïTcÇ»œæeùwC£4‹=åx}~ô´é#(µê$@Oæ3®xpœ×X\¿ôŠôœFC¢JˆE³èEÓöšgJðwÎ7¼`CÜâ	GZTevh+/YhÊèø¬i”E_² ðyo (̆¬¼¬Ñf]™˜®‘¸õ!æ¨o˜ÉÈjPrÁ’nýÞ%őÅ3£Õ PÊvÏ#I圐h©£Í&ƒÞ|øBbÍÃ|6a¥ºTè¹!v—ô¸ík¹0*øÒèq†J[*Š8ÑJ”ÆÈnL
327
#else
328
²êB2«EÑ1aÅÔÙm6]8ûÆÓáÜ -
jtÒèkjk.{ÀÆíä§
9@C½9
328
# define CHECK_FAIL	-EINVAL
329
!½D½§¾Él6Ÿ8ð’UzÜÉ ´å+­$öС°i‡‹Aêzñõµ8ä'r!øŠ¬ÉBÆÙ}× dÓ:/»Pu¢"8Î5žCŽygW²”wçE‡ï¹S:TücVá­F
329
# define CHECK_OK	0
330
ÊÚ8ùØN4ÄØ*dŽŽÏ.vúÖ݈^¶•Õ-4¦•Mè핳°Që¾È4§C­¸28W{ÂÍœ/æûrýQ×ÏÌëu·DÎi͌ǝ…Ζ‹ï´R~^
330
#endif
331
åƒü¤‡ Qo¶åHTüj7:_/•Î=b…úl–(o#°XÙC’õݕyÁcäšt,%p},÷J:Ð!±
331
 
332
,ÇÈ5êzµ­¥qš‚/bH¦¶"JIa	l6ü™J’i¿\x ‚×e4s,…?@¯Š@4³[±ÍÒ5áIJÞJfÖJâeM«	‡Gîl%ž¬C—ð4+:uƒ¬“ïxYNŽÿµ36„epêâë6V00V¡úöþ‹Æ®yKœS%¦/u¶º(séïÙ¼‡4¯
<¾mí4+ö¼08×ù~½ºðb¿¾¼Û4âÒ@rgØHºÏ!¾û²†ûuOfŸÖF@.ݙù¹Vuÿ/3–J«ÑÜǘì±_8g‰2YËôbFÑh!ö†6Þçˆ&àÖe%ø´F>s\–)ä¸Âš,±ÀóK
!P¯s’¿Ü"þǜ3¦áÿ”'äßtõ^ºÐÒø€sH83ÏÅ懡¿t(žÑI_‚ùTü&@YÉòÍ19·	Jwº–ø	7"†L©Õ®kÁt:í¯%ãUÅÚ1]¢áq.E®Ÿ¤DæS’ï°ÞÃ܋†å²<¥àTla/¹³•Ûü6r£5Ø#Øl4ü©Sÿ!™¹-ó3ŒÅi.ia;laºEet;‚‡–B!cžyæK˜D1d$w˜P0Ԇ1ÃÓ%¿tïØ_omU@j$	+͚±²Ã0Ì8AUFÌäÃêî
óeü+³‹³\®	ÆÔ`”U´¶À´];î¼ü.ÕÊ÷¸øª;ÈתPvµJB“3k¼…Žd§I’¡•™ÝCRdAÒàüÑkHÁ¶°ý<fŠ7*5¹;žKӃŽÓL15}k¿µà[–.C‹ààP1mmsxå3O?x¿ýÕ%Heï\é4LÐ$®øå<jOH‘ÑÐ?iU¦ÑŸÎÒí›ÁŽ˜ŠÑX4˜¬šGÁ`sØ2ŒWobçé9ßÉuwÆ	§+q&RG.˜l<íBÃç ý‹ËKñÌL9&ïð¬‘3Ž@C7™±,&H›à
332
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
333
Œ=v#¡"gÔÉaÿxW¯¥v#Œ HÝDB2 ôÁÂΉe<odmYgC§
333
# define use_module	ref_module
334
€è¿˓‚Æ&‹7tZÊ!Ś¶*6«åy†Ò?Û%-…o,Jòà|ŽÅüÑ	<N÷±@D«tþ…äŠ1ØÏÙvßmK+`6__}\1™—W‡W+@0Ž|~G¡Ó
,Őj)xž
ÇÉW9B…¸Jߕ$@šX¦›ùXC§¬³^D”‡ˆµª|àW‚xÁ畨N¢óawë úŸ"c®‚»Fm¿Úh6«×Ã0:ìHŊ
334
#endif
335
„^óÌn£Ý8Øm4vš/Oêǯw›“Wíç,/!øŠË:ñ\Dß¡U«N1t1dz)¶‰šîLL™Åç‰59>0úó£j ¤b],u­ ÓKâ–З™ɨµ}ѵ¸J@ªm2õÄwé3ðmÙéC½æ_	F$ÆÊ~òz<à‡y‰:^vÅZiy^RdFŠD¤ñXö„¯%v½Túæ›Éu´˜/\n–¸,žãlôÅ ߯éݓN«Š`œ)²§£aƒ¶Ááâ£/¶[\¦?i”]_ùäµ-·7Mú.ï¹ö+ìƒÍNGrÚ}Z1p5Ì	L†—Äï;qš+j¢¹9b-†€ŸõLh¤BWr&ª U¦‡535+Æt×Dš£<IJ•~¸SqÖÃÆÐLŊ`TsPáÂ`lF3è–C<.ü!q¸ž7¤Mçw¸Ë¥Ûrgönra\/2>œ¿þ÷—Ti,’¨\Æ3“êäÄ/ï[äÕj`
335
 
336
¸.IdțHƒ»0±?\fò[ºwVÚ§
 hÎ
¡¸OkÿC…iŸQwğÂyþ)yÆVÎ 2XLUêjd…Â[½‡eãµ¹q
336
#ifndef NF_IP_LOCAL_IN /* 2.6.25 */
337
%çêÂY‰³düucª­x.K5¿Ú‡è<é•"þÉB³¨ˆF”¢±Ñܳs(˜>+ZPV¼Hš…WÃhÐUï
®›è×.µ‡ôÙî97”sÛ›"‹Tþû½s×Ø߃™:¼
ö[õkE«ê71±¸PÆÑ8hî·¾®ˆÍ’ሸg£^ßnh½ÔÚÆ´lõžìv‘=?´~”¥s4Z<IJ1ë"4—Èl>Î)k;ó1K^¾®c,~j&v57ÎÖÊÖfë†AR„k`v(r$	¯ÕŸgbÃd¤Xšk,MÐÂ|oåïXŽ|ª-ÃÜ\ðëû¯½yÉHÕ 3µK!j`ïa¡¬ã¹Ïñ0ŽðÎnPhм`#°Õl+¼30k†ÞÜV~OjD§èÚ°‚/”c®•ºžø
ZBŽK’5*>ÜbLp_qP
337
# define NF_IP_PRE_ROUTING	NF_INET_PRE_ROUTING
338
÷¼ß8h"´r´š_3]ÍRD.Ö`{ýAþqÿý±FJ¼¼Ýh7ëHí«­Ýv@tx:9?þ†h²ìËëÇњ>ÜÎñ£"ga
338
# define NF_IP_LOCAL_IN		NF_INET_LOCAL_IN
339
XÎOŒU?Ç÷ÐFQŠ@«ˆ^ÈËè…`Hj«q\
339
# define NF_IP_FORWARD		NF_INET_FORWARD
340
P$˜àÃQQ¹·ô _Ûw–Qó£©4˜ôûói,J·;7¦+ï$q@ÿ{–©~áRΛ«rT35S­¹P£îí÷´±ôÿøߏ23#å{II„£˜Q ¹Ux¾ld0lӆ÷îâè8æ€%¢۟ys@Aöó<:8‡pÝñ¥¬ëW:ùîíaËèÚ¶â‡Sbdv𪱁Cœl¥,
340
# define NF_IP_LOCAL_OUT	NF_INET_LOCAL_OUT
341
S@öÛ¼OàñÛtN„]7*sÐMcÇxÜ`W„$oB¬iê°jši÷s^&ô¿ˆ‹ŸæcY·Ö‚œ[
341
# define NF_IP_POST_ROUTING	NF_INET_POST_ROUTING
342
Ž-d~¹øåQ#¡Ú2ÐôÆ/ ²1 ¨±ïå$~ø4UH’Tû”eðДò4&'t±¤•Ø°AÝU=¾ç²™³\„Hi֛íö>IÁ³l›×z¿e.rüýœæGËÜ	vw÷Û»­ 7¥+ê ÅÕAž;ò]«yPoÈwm¼?å€p›L@?×t>3ánì€VX‘.æ35+¸}Å(IAþ8Þ>"¡—çqTý ÇäÇ
342
#endif
343
aî÷
98é[a狊-A|Î+ϧ>†´”ÿLº«m5[σƒýúNÔÛ{-ø¾wé®›mQôS/üÇ먱¿¿·KÔÚho_šžš{û»-úŒ¸qð5cÒÔ:6~SÄh
—gvçÅÇs	2^†ŽÅ<q·H`êZ³ÕèT2k¹H}Ì\_yÜG†!.¬æºEìˆÚ«3Ût<Å&:9	BŽô "ßW´þûL7ùE‹ÙÇ_Ù²ýA)º‡eËZ¸ee‹˜:­^å1çÎýÍÚÇԋQ¦þžldlÚГõA¯¾»Äfžžké{gIº}–x@Ú_ۊÎËy‡ÍâŸGM0š7bü9–6ӆ ‘FÑÄtljKFæáLrÔ·5	]AÆ™sš»òp7žÞýÐÞýq3‡âgªðz’O喌‡.Ëf§.—Ec§£Ò|›³:C'@MãÜfíIGŽZ0ëOÅVVi”]&´ÔÖD'.eŒ‘éÑ[4Èô*æ/ÕgÉ%†BI[uˆG:Nº÷·Ï°MÞ%·}ÓD›Ø» ïΏUötíé^¼aæÔxÃ-Žs“UÑ* œXo1~÷,þ050XÎI—]@™1¾eŸîÀMÅznj£ëPä7ÈpÕÏPeo÷—¡Ò€ÆD(ç†`‚"žÄ"ß÷fàªD™ò©qzŠµ©>Îóф(û¬3“‚㙞?‰·Á«ù±?°enۋLÃĪ!\ÃÅM8‡øþíÚ鉱'ˆ+ΞЄ¥ÚÐ%U-V «7B¨ò`ζzg²…uåւ7({Ï0F`ìÁ\¢$Uñšaá@å:,ʱM’‚Ü¥M†3^K¸±/dô<8‘q°J„‡ý×í;_k@H݋òç~¾7ýt,©°ëì^=Où#¹*
ÙêŃú^;øžE
È¥oƒÞMƒKÛB#R>Ïg-^äª,‡u¢ÒånÄI¼`ÉËö‰‡ü¤¥ÉéF³È/”Ã÷L&œU8l‘Ÿú¤a¤[†PÌ-T8ÇڎDq‡ÙäOâ%Ý5b³å*C)„”oœÉC©w
ŸhJҝ0IÃ[i v
343
 
344
©8ê<šñs˜“÷dA¦»ÊN<²q†+ò|ZÖh´{l†¹Ú\˜éœÏé­”$ö檞¢£9vgó¾0˜¬ht!}ºÛ>Ø­ Û\äW¶ÌÐÇûíýçX§ŽyÔXp`2Ðñ/)~‘t
344
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
345
¶3£Ïï;,¢ùq̸‘¬û}ÿ¯ó÷Nî›ccŸÔËKÜK.,¿ßÔ 3ø¾xbtq1¢7Pr@Yöä.µéÃF¡”‡£4 ¿¦%&È Úh”œaàIL¨&‹²O3‰'ùXÐL‡&bŸ#\ÑìöX÷aæË&ê‚)ØÖ_»¤
345
/* net/netfilter/x_tables.c */
346
Š3»:^& žãߋº ŽämÝ$fEð\#TA§°¨ß/é¹Ð«¾!F’
$$SÝÛ´nHÞoö‘cŠ·øt¬x'%ýÑ §GoÏ
û§K$Qؤ\æ‚@jJ#€=ŽBbD7ŒždðN³d8cÌK‡¸ƒQ1v°Ôœ`
346
static void xt_unregister_targets(struct xt_target *target, unsigned int n)
347
WÂY™@a„/¾bÕ3‡ˆˆ‘ì6N+4%1½4Þâ9%ƒë¸YW´|¼íÀêqù®Ü]
347
{
348
#Õw:õv§~Pkî7ší=hh¤©‘BÛ8h“®þEÐKz5p¹NðÍñ9ŠÈM®g7¤Ïח4Юï z…^äf:20|‚[Þ½˜²pÌ]£;ˆ2ÎG›\ /ùÜ®ŒwëÀ¿HLYÂÝð½¼ÈÓ§ò!ÿeO\ß\[:ÎD½½+\[æÀÆ¼Ñ 9B¤¼…ÐÕ¼	”g‰ÃIÈY¨6v=áï·Ùñ)ÿ­½G:Ú3ÉgÂl[, 2Î9¼Ì"ƒÙ¸¾‹WGàêQplEÞªD»r*6·MŸ…ézè¼ŠKÓ·õV@òzîR™‰DY
348
	unsigned int i;
349
Î?ªÈÉ	<;Õ£Q;sàvnì¼Ö²ÆaæVÀ'2:c>‰Èf¥ÊÇxâP¾)í›äw©ôúÈk»æµæž÷^{Ùñï䓰ý>Í\§OzÙõlG|ut¾M§ÔZDù܈¯‡Ïy[Ú+¾èwlÞö>Ë¿M¬¼bêEÂi…±N.éx	³«Í{ës•Í§$Gi©í½wuvÙYžã<=Ñ9^J‘ßҎy‹õ{“ûŽcbú%j‰È‹)Òè¡+YìΉó﹬mÅCbb/qTÙ¯
0ƒeŠÿþvNN¥f»UΣ˯úá·´¦À½×¾$&>þ:Â
349
 
350
¼.ó‰9¦­X;K¦
350
	for (i = 0; i < n; i++)
351
òŠ¡é×v
351
		xt_unregister_target(&target[i]);
352
;åÇûMó¶7•G–Û¯ù°nՏ=rõÞéy²}öíá¶Äw)g¤øšwV¼×vð"(öâhLaì¨n\ý\¾Ûã_¦*»AFs6¾ºz£–~3~qiÙ K9€Ô¾J¦o¡}‰..µÃ^½l½Ïxhá‰F½´w •*ù`'¯IG‰#¦71).,–çÐ^ìÒÔ<UT
352
}
353
\Xኟ@°]Dd¯Q±$k;Ξ»¶ÇФ»ëW—<õ2¦íÀH2`ú—.qG©/|0ùd¼xª\ ÙDŽo"
353
static int xt_register_targets(struct xt_target *target, unsigned int n)
354
Qh&Œô•à”Üx¦2çyŸ,ëž=Ñ‘2V à’Ü%<Y{wȵäœk?ì`7·¶†æ\¶ãJpnÛ4ò Å>‚6Ã%
%–
‹Ûo}žr‚-’¦ç<aÀsjhç¤$Š¾=;}sèË@›ùøǃ]¬6kÍíw'ß]þÑ} ªiw·ý‰oªÿÝÙiîý¥ÑÜÝm¶Úífkç/õF«Þnÿ%¨ÿ+`ŽÈŸ øKš$³uÏ=öýÿýû`ï—g&²ˆƒ6v«õfµÙÐä»Ïôÿ´"sýêÌrÂñE»jÓIªtõ™‘Ü'ĤLðGi-/mzðZ:q‰Í'“Á›Ï á=È!k}
#©<Mî„gxÏŽ¼_š÷BôȽõ6É՝fljÔtmß{üÈËÔX‚Þ¢uäµ~mî½»ÒŽP>#ŽhÂÎûf­ÁÛÒƶÔ÷í¶,08‹\òK¤”M±ò‘\Vgé¸Þó%Ú¨ä4ŽŽ³àà"¶1 úÃ4BM‹%€be§|{P1ƒYØ\/˜Ý"ÉUœhU±8/w´sžkÍ^Ô²[¥x(@‹ñðˆÚÿgùG¤Ùzɧb‹ã=0š”y‹õ´œ«Ä‡šÞX‚g¸×.‹BÉ`Àöý·I!™g	‰¤QÍ(‰T‚ë4S„Hû™Îú5ª·&-YÑj®5)"d¯
354
{
355
MԖe+OÏIÄú¦†lÉ(½raY'¸ð
i
ml@e¿=¼øº¼œ_sГrOßg¦ %Pˆºæ½‡2ÓuÝQöAµÞ.2nDFO:6ƒ÷Ì[ûÕúž}˃‡ÿLlH½‚WpÖ-êüE–Í,Ž¶Âà%Æ!E*úF5¸Ôy{´ˆÆ3¢Œ›u¦V`½0¤?àÉê¶jH®Tžÿ¶¢ÂÛòh\ŽkBr*ó¥äìÙq)~ŒÖèBB½I#ðܘxæ(Åœ•2h:¨J§¹÷¹Ö«¡€ŠÑìóö¯Ú#Žµ¸=¼¹úF~›$O>O@Ôޞ’IƒhÄ'“|‹¹–´ÁšÃÆNFÏ
355
	unsigned int i;
356
¼Ø­é´QmÕ󝚨z!~¼/Ÿ÷¿jw®æ:í2§ÿñ¨ðGs¯¬+;GõÒµQ®s)i“v@÷.{ [DÓ$‹X3mõkÚÚË£·Œ¬€æ¾½4èçîiA"žJY£¶#[ãÚª6ÚO]•Q,€
‰=D¶Ü®37,Y2[gü½bý€ú}
ç're|8WmKK³22×,ČÿbªÑQK<$ëT›­53„£0–PàÞlÅaì\cßðçGYL­¬ä Póì(Ží	6³qÓùà«	]h¾€†ó)O­i¦Ö¨6vÖL-³G:šÜ È éϽlÚÜ OÏMrBÇlMÚ^4ãðg;7HC‚ÿí.ˆZ`ל>Íݲ]ë
356
 
357
ÏÀ:1ò”½¢¬¸9,·bŽKÕÍÐöˆìÐÄXfx‰²F‘_s¹£É]œ&lç®mþ_«ÿ±máMrýGëíUúß^so·nô¿Vc—ô¿v£ÙøSÿûWü8½._Áça¯ÿåŒý6×Òù››JöD$fñj³¾úHGl	S[®ñºßH­ãÄìsޒƐNø;8áñ½Fj°‚¦ihÊ\À¸ÃyOHÞ6K’½¹áR¹ñV÷øäüê+.	i-Dñ
àÏA<ÒAt´õlÞÓ[!6™UòEªYðCõ;þ»*ÿHms6‘MZ0³BÊH8tÀõu‚÷é8¸l‡šnnˆ›J¢L¥Ku*–Lt‹jp>¸,s|ŠbÑÞtqKT„×Ñ·À(½ãg![àúªFN8JQ@ËÏÅЈ«Ï9T—ÆÎyµ!'ˆsÑ
357
	int err = 0;
358
–ÜXo¾¢ØíÈ®äwA”hAª”ÜŠF
å!žFH¨Í¢Ù{µ&&ÃäÇ;Mä̇“Û,ørüK¼·g’’ÃU{¼Y½µÛ$Tð0w 4öWóTnÂà&"…Lnp`c˜JD¨ïÙ

ô±ÃrsÍsÃvDëÑ\¿KÖàì’ÖÀ¬€¶ÙÞ÷`Iˆ­Ö£v4Ü
Ûõþþ îôë{½z¯×îEÃao¯¾¿³ç
£¾³zԑójO€Uƒ ]¯¶*ľ¹ql2i$֐qtz4i\˜:7”.:ŽÑ8f¼“ÇÞkâ½·ám„BÚFýÞK¸‰´VOäÜ7?=&§³”B'´áºÆH›Ú€‹iÝÍÂ2°úځ	ª„
358
	for (i = 0; i < n; i++)
359
A毛ûDb Yߒ4	8Õz­7MjÍj8ì¶yñT ®™¨ÉôÚÙÄöA¨óÅKê¿ÆæpÊææF2‰HéÚ«î«G‘m{2o’Y<øRK¹Ù5~;+ð[›Ûù-')a`{ÃKöö¿Ì†^ƒƒµg e·öËF†­)”.ͳÊ%}õ¢‹ ªÙ}‚ˆú]“ϒH¸4aÞ.ÛᏪ½zTß0G'ǧW—z·ÒaED^;õ5´%FÒǬ£`„æÊý¸n²ñZp>:åÜ¢g†ç'šžäêþæ­&:¸öZ·½®µo»@¨V5Ó2`q£P„X_ÞÁ}׆{À¹öŠ{Þ¹þ°q·…ãFû—ÆH¢ßÈ#&)V5iw̞µ[Ìbpe RpþqJ%W èD—‰ÔS½ó¹,‡yÑE
áÉdÀ!ÑÅT2H"®yœjIyɌ¥SY¸'Û’ð‚§²Û^õcÓ-{»µŽ$ÁëyÉ0–i’åÜqà{;w˜ð®ýêO PánçQÇõíCd‹¡„à¼ª³¯P…àJáÈ ùIö‹Aš¶	AƑÓÚ圀9Üâ(£›$›mY¬SAσ¼xËEkªuÓµU(×-8
À(5h÷Û	ÃÛÈ¢­[Zã¿áœål&‰ûóŒup¶ìG£©·îõƒÇ.-Zo58À#[×d*f–
q= TÒú]'Ü­4Hiíµ$–ì7ööêaxÐê·÷Âa«ÑjПû{ý–Ò¡ÐÜy=ZPÅaYKb¾„hg»ûølß"ڇë›Þ|2›Û—[ÕæÞ㣺B¢ïËÂӸՋ!P‘Œ8#µøD
359
		if ((err = xt_register_target(&target[i])))
360
8­È4
360
			goto err;
361
Òazi<¸f8Ú3¢»I2©Ê'‚˜$¬ÊÂ_o’kŒ`k	&ÜæÆʪ÷`{Mô{V@´Ø½ô^Ù܈'ŒJeÊÓr¼*Å¥Ú¹‡L¤qXçº2§.#šõ
[4Æ®Ufrë"îïoÎ¥«½zG‹MÛ&šŽ´Q.ìlåè…S/ÿŽú6œ‹“	<™5ksö¤ÆÛT,Š`nÎ(%ÏI‚Zòì-¿‘HœÄõšÓ®Uc*`$#©n¼EŒ3˜†œÆ›~K­Ç(z¾£I˜Ý.Ýgð
uI ïfÑÜ,+‰ƒ1«ŒãD3ˆû°ÝmÄ﯁	(“èšdLp|zê–A䤱 ÐX<@è4Ã+Gôy|öÝ;D£½;«^\œž\ˆ¯» €œýãëy@BüDËAln8yÇdÂôæDÙϜÝÆS­÷Ãö{o²Á¸\ RcŽyŽ «4ºõy—'%ŽÍòÛU'Õu
#b?vž‹ÒÜ$ì)q%r¸aIž«Ý”ýÆwŸ*d“ëòV҅нC­s'¸·j'w#Ãd&î%$&Ü8]až‰Ë“ÿè^^^\u¯Î¾>yW[ú)³y¨2"̨.½N+ì~ã4ÙD³.IªÑ,/¤|ýöð͛³£îÛÃﻗ§ÿyÂhIt耣÷}¬¿$;¬÷£q‡ØJŒ`Ķ]}%ü5L£èv‚³bH/‚Fñ~LÚ*†Ù¤Ñ®©)°ÖnÌ­GùáÊp‹
ç·ä‚²
361
	return err;
362
w>	øBÁ¾G“A5V‡¢DÌԛ\Škt¢øúº::—ÕÇñÌP¯ÇïÕé;®þŒcÂ5Tl©š+Ë8
~Þ,uÓ¡¢b ý&;š›Ï¾n¾œÈFÍAÆ ©èKÎNWà–@årãBèÈdF¼³1'ਝ峇ð£ùÔ$õC2нŽ¸tHR‰ï3Æ)l8zÉ4Y˜€¤Rp‹@‚5X±Ðå!©žŽB™-(z N[Ö
‰ éÂBÑè
å“ù“ñ+/U681ÎSN úåŁµ&ç”t-ÐÃÛZ½;§gÐÝJKškŒ
9H6cíh^¸*[/‡Fô’U
ë¬0îmtgý8à*‘,U+>k(6^àGO

r,$ð77zÜ—ÄÀðºÄ«{ŽŽì¨²%Š‡PÐ)Ä`ÃÂ
ª%§
362
err:
363
^×L¾$ØÝ.wnê}eG”‹'
363
	if (i > 0)
364
<:Æm#†ëh\A…Ph¤rvÊÃbŇ!9’“HʎʬŒyÈ_I3W´WíÏÔ-¯y6Ýɓ«¯ºç]b«4õ³‰ÍC
¦_:v¤4os¾f^…(€ªä÷IéÃ9k1ó,G¡ëìIÆÑU°r0ÕS|!%ҏkbw;eUÛF¬F—öB˜iy¾–Ådr˸ܘ¥n)æÑZ…K³ظB
e	Gْª©ë«7 £råŒH˜òŠ°¢ñLx$>¼Q¬>%4—ó™Lï”YNËþFhý#~N0¹¾ûuÃØ^2bâãȀ'»¨ÉYµ‚@ÃÕ%ޘ%€õdÛü헃vo¿Ñ¤#B›@b¸=ª±Í¿¨Ó÷â3z$úœ_gžuO77}•Üù2”ìJ7$áÁ“c‹Úâ5ì.D­€ô¦Ý½¼8ꞟ]\ɕ‰Ü2‹éóíAN)=EïCè?Á†·tå$w¦$€öÚ¨¶Öôúüz>
hq„¨…†ñ¶–°D@Gm,ï@?dJLd:r¯É¼Pð‹‹Å"rhPÛ®Ü01EnËCƒ)Íì켆ºtž’Ä›Ì3†MeH®l¦Rk¶v8,À6—¸Z/{‘ø6kS4=Š™g‘Ê—‘Òµ¤‚8Ûôòèa›Fn¼
JÒ
ç/7^ëd*F^e8¸a°óö‰Ûr„`øþÌÓõ™ô´XͶè|"g*Ê?ܽúûùI©Õ,ÛýK¯R˜×B™=ƒ._3@<5—Û`äçWG­ƒ¶¤NX®;KŒÒB7”Ô÷Sw9ðŒ†ôñå4§SÙRtßî8K¥V"ƒÿ€wX¢2¸Ė
ÏßòRýl]U̖Ž˜j
nkXÝÝ.í*`HL$\Fäâ€-üñi>
364
		xt_unregister_targets(target, i);
365
Ëyuiəbª¤“ÍÅ"á¬óEN[âKVØi셻{†5l4|A
365
	return err;
366
81—²G
366
}
367
;	>nîvyQŠ5ëᕧï¾=|cbFRÐ	ò
-å ¹øOá±
cd³øÒ2¨6¼—ëî#‰Âì0Apq~XpÐÿÏóhù-í<¡¥é‡íývúÞ¤53°7Ì
2;Îul$:óc,<¥÷Y°<ÞFm[ƒI«Õ)®Ë4—E
367
#endif
368
1}#—knƔáøXL6«ª$Œ°hI!}P}?4€Uh+žÿœ%5WŠ‚-¹Ì•FÙÒÎê…ôr†I€APÎ_åö㫺hÑûÝÀ%ýY†~ñÛk=݄ã^j¬Óc‘ÃK”šbjÖĄyŸI‘	>ð>ÿf1ÐÄAWå;>bf|üȘ¹heƒ«äišÁ$ŒYyû¸ÙA‘Ž”CÄGÐ9kvY®wø‹1ꬆ%*M˜ç²„§BpÒ£{¨±/KFw|vMo¬ž{¯Ù@Ù\YÀ²
ڙ-¶I²Î¹F?nT<2›ÂÛ
󏆠o¿4u£úRA¡ØFqOOâʍÏ]÷!ªëœztÅÈyŸd.PTÄ’òü°:oÄÍV-(êÆ°Œ‡­BM&;§½Ž³2ۆï]g‡°7ÈæÁ:9Š¿ÄžL’ª®‘Úœ0@»éùTKŠÔ˅S.N’_„&á55ˆvæ´ûe¯ï5Æ1ŸÁĆsŸpÁ4¾VµêõbšW‡Ç	l„»$xs_wÈÌIWÓ¸}“ÃÎÛ$Ŷ ›§ó),‹G`3™Ñ·!\ºÂÒ#­A4”	
368
 
369
3ÈpKBbøÅY’˸·Á宦é«ï·/¾·œÜïDíoÙ)Ö×únõ½Åú_Þ2º¦Ö™2qzlZí«7×o¢½n4&uÝSNóϜ­K¥”ÌDñh„Wš†çd,h!Ì¡Í[&i«WBà9FJ€{\sd_qª&w÷Ò:¿Üáœ8RšUõFpCl¬~+û¿3ƒÔ·=ÓÂUÖl—”TA¾È«Ó×Ý㓗߼{u&ÑÙ"Ê,Ò¢D›!Ž*vÌÒE&EÇ·±š¹ØmÒÏç
¹NÖĎ\Šºa²™ór–OÍ U¿ŒgE„ù’U#fG¯ÃùuÔjbDG‚ùQ}üñnÛGãÑà³d+¼\^pT/0O8ZÑþQ7IH^³ëD˜#Ò*'¤J!æ¼T»!¹E,+Ð(›µDu«׭£ŒoŒˆMäP7Éj*œ þS˜Ãà
@ÁRFd=JJû‰û<üá·³•EQÀaÝ`¢E Û,º~`bPW~TUPÓµh¦/'l&HB$	TÁŒìÐö×*›>&Ìp4Ïn^0‘Á`"ø[æj.þ
UjWÆS „ÍÑ+€4ƒ—š&lrÜÐ,:/ HÆYz€›„º!*"HÀÅlž"Ú‡–“Ç
j±‰œ5PlåÚ
µøó¸.Œ!úâ‚#üs!^à%х›±éH
369
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
370
T©=ˆEAڜLÀž­-μɮ“aÞúÑ\çkEÅ'vÉFM”½õ×2DÈ«Dt‡læêCpá!„Y
370
#define num_physpages	totalram_pages
371
&¤	ûÂ:ÁŒæÉ5?vž8ás’‘µ³yX/³|é¹cW•™¹K>/í·ÊÆrh–Bvµl*ŒÙ"ât‚žÒ5ý^JûHYP}_25øÜ
371
#endif
372
àGž·C-—ò¢ö¯’ü({ڔ!˜jêHáÅÀ'šBÇÒTüc$WÞ&×{™¼¶m°»jςð"šû»HEÚ85êe˜ŽâЯf×6³=ä›nÅSöoñè4Êpm
ÕèÖc`ör¹©u&˜òYIA˜™dõðî
©¿$Qw‰:-ŒKyÀ¬ƒë.¤‘¹lƒÏï֛$™Âé³U	¶ŒÜ¹eB=,Ñí?&-³rMûvy“¯.'EZI¹æ˜³‹‹Ë
372
 
373
ŒåTl×׺àáž9"(M§j2>.„SƒqÃèºð¤öcT¶G	
4µ¹á› ƒX^QsÎYaXH4éÚRфc¥?½5ÎWz3Ý$SfxAREë<€¹Üñ¢Ô±¿6ž~e
373
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
374
»¨Ã,HU‚4”Ú
°¥ÃôÖï`mF‹ˆ^j˜kaã]ÒKÒVÏG6ÝE‚0“ï¼ÞÏ\ԕYY²¹Ñg[®ø"gq”œ¥\C
ÁóLYñp“Q
ó}ÈÁ@°–úžQ›iL¿RLã^2ëuzb$HÄêÎ'!4ÿh ±46Ïè’z'ƒá¬‘~y~j¾!¡Uȏã!qZ#ÿ{ÕEö÷ÕÅáÑ×]Î÷Ƶf»/aÙ#Žäl6á<6†qYä7µ
374
# ifdef ktime_to_timeval
375
eN\9’*å¼S®Žd¾~¤©*)Å¥ÌԜ9ÄÝÈV
îZVrÒõª5'«P‹LW‡ïÕjnëkõŸA©Q‡†W¯«=G‹Ê0Êþ‚í=Å	Y÷^ØYï2,1?݂atgIwž-ì%cµÆҁ½ƒUZËde‡ˆÛ“ch¤.o0­õÙaæÔa'-¼@i·ÁŽ¡Å˜ÙÀ‹xeoÀ;ð~4ä(®kÁMÅÈÇËçg—W¶±LCñÌs¯Î.¾;¼8–F9•t#7F.‘göĈ²ÇÍ'í­—|9d[PÃ%š~3ÄTê[lL‹ìææþ:Ì1e#~Lz>r¢â,ÛwÞø׆vD=	g'\YÞT­·/®™¸…oÀ¤æ>£]âÌ
375
/* ktime_to_timeval is defined on 64bit and inline on 32bit cpu */
376
|YÝâ L¬Ø¤•¢]§ë4M¥+:»0¯0;I{óñÔoh
Õ2–½Ç^û|¾=+Ɣ‰Ô"ýQDÂíû¦’‹†yÓËÒ`f_4O°Oë>ÔO½ª2“­G¤r­¬Ú†[ÅÂÅy&Fž6÷©÷–›ÛüUh>
376
/* when it's defined it calls ns_to_timeval, which is not exported */
377
Æc>ø/­ó†“fq¯QRZғ\r 5Ï$hMeêy™LpÝß.3
377
struct timeval portable_ns_to_timeval(const s64 nsec)
378
í®µ×¼b@	̈́$
öWã!¤Û5›ØHp¿Á5”ü.ñ†£cÔ]3!7ã)€›DÍ·P"LY­ùQÞN=¯»ÂÏÄÌq·D"µpvi•º9“ºü.4ÉG+žÕØÉlOº³ôAêùº0þ*"nµ7Ï$.…­¿‡.òb)v5–YëÉêŽÝŒŸ”ܳ¦|MŒ[X*¾ÂåI#t~öùfó]Ö3ÍÔÐ6ëlo¾"±ËëÈötÛ˜߆¸ªYu*Å«¶wö·Ù±ªýàr~gú? ôüÆPt~ã7—›ßø}…æ7þ€óO¬.¿i’È~gYù…‚òãðiÒP§¹¢¼Dh%„¾l sÌ'_êÞ µGeÔ>‹EÅ`[^€7Xaú½Åç½h
378
{
379
u‘î2	¾­§é· Š’Ÿ[	¡²ñ%é;ÌZ’°$UKFÙg{O‘žX)1™Êµ,W9žØì<’œSËiW~´	Õ%J49ÑÀ¤©n¾¢®šä~"ír‘>ڃôÛHû69ðr=³pC÷Yb,øâòv+?"ê†ÿ•ô7ůGI"@a„]aË"ªHë@P8£¿n»ë5€±ÔŸ&Ì9ٗÖ7pŒà2‡Ëë’qíJ(˜G%~z¯Á]YJ"›%}Js„÷%zÇd¤t–g®hÇü —™fxx)?Û§×m~lۏfö¦ºF[Z¡ÄŸf*?©Qæ`ÎÏë¤#lež$£b\þ'K¸WÜgŸú‚Ðh–\³¯Ò„Оx¹Ô­ÁºƒDpÉÈßêG249†½vãÅ«c
6³[-(†gڔÒ'Kê3g,`àC<'¢ˆœÚ’öQöå
nìSâ‰=^æÍ
­œŒ°Å̈7Z
379
	struct timespec ts = ns_to_timespec(nsec);
380
*Ñ`TbX·°r²­GYXÎ2êÈÖlÅ?qjbæ9e‘n†_d﫝o%µ,Ô§½•6‰ý‚“¬_Ol{08ýB_Ӛ3Aî¬õôHŽèOK‚FrTK6ªÞ†ø†ÔçA•´¦åÌË)%[(f*ޖÛMm8Ɖ&ZüQèI2-?GW(ü Â¥)Ñ)0&ZTÊ֚bO¿s¢u@lµµ‘¼Û瑼¿	çß¤§C¼å×Pû”L»½5Xa³‘"ü
380
	struct timeval tv;
381
ÃGÄrm¼Õ呜ʾޒ‘½7GÑPlq\h…Øú3®ý,Д-»‡õµÞº5»†ÁØjÀ^‹ë,·çÑí…»îM¬¼øÌMdÊdH™Îa“.¾XFÈý<mً­¶0c§ÜÜh74€œ›WSÝgaڃ«Sêk®ˆD?›o„l{¿ìÍ|m>.]+(sWF˜^ÏÇF?3h!ªdÚ(ÙTÏ+c‘[zÖ£èÄUÿM‘üè)Ñîa‹NÅ"fééíµF¸•&,Ÿ™Ôâkš,ó,ÌñLåÁ…ŽIL’²q+Øl(
381
 
382
Ga‘ŒÕç~Ä[ßÝ©3SH:.çYèù§±iø]àæÚ´X„æ!®:ómÆ Îyå4<òRǑÅÖ±	ã;>9{vüb»O¶‰à"j´ôŠ£³úÉ44:¸	Ϊ7ž‘Ò©fÀ>L“ÀÄb¦ékßÔf‹Aý¶É¢ù ©"Ä=
˜rÜ
ì»A¥¹G.RvÌÌH¥y¤u3ÕØeBSԛǣ+*èwÇK»}ɐßu?ł&öY£ìDMLÒÐúpÃGF%DŸ³é¹µãš\çgày)ôA¿…ÿBró²œsçÝ	Ž‘¹ëÅȟž\½
382
	tv.tv_sec = ts.tv_sec;
383
i8œuŒªoj×äÚ5ñ`›¨â“j/Â)­rùzUÒãa…#R­ÍÞÏ\^?r$ÞX¿Š7—ÝÇÌ£,$;#™yq…Är»Žò"XtQcTMy³ÚfۏúÈ PMàÛ»GRflBË[á+1šJn+Ÿ ×gYΡ£y¶"Æå5›8.—‚³ñ{¬2{ííßÙ@kûɳ÷A=óáˆoX•Lˆ`o8•6RçP·ôô×{Lˆ69Ì4[³ÁJD®¢E²ð’ÞóïÈòqFÝ4žà“šÆHß8­S€~4-Ÿ(¼H·wÃW6ô‡^0®¾NØE‚§»*@`*Rk>q’œ+›ÆC‘úºšxæÃ{Ég.UO(ëêèܪhêLç삭Y®C$“øÏGvYëk9×#Qp‚CZeÆU·½­–çZPR>¼Sö†Ñ\kû`GÆÉޘm“æÇóÊ*ëÁO$Õ+Èn»}MǕ·ÐWœnÑõ‘Od;hã(‘b'ÑѐŒT;Ÿ0ÌëÀ„EÊ_¢^¹Oãߕ!j^㜯‹¯ç2²Mfšñ=
383
	tv.tv_usec = (suseconds_t) ts.tv_nsec / 1000;
384
2ƒ¸íµ—dFD)wɔe!#…IÁG#rfž^«f¢ñ®Ø¶•ºý%Zàèx2FƒU¢5BŽ—,”B®1r½À³‹ÙÃ\ZpAn6îéùÄ·kD	æ®+˜ŽáB>>¹¼:>½‹ßÄHbHçeÓ¡‰‡cú6òtgÊ»Hä`¥s7Í*°¹`×_¢æ#TDb3à
384
 
385
fù4
Ï£ÀƒÍØÉY r÷øO¹†í»þ¸L£A9êpA`VÅ	´ðOÖëb]ª×Ñ*	GN?s‹f[ؕEó.ò-ÛÑΣ÷4‡Â°ÅÿÝáÕnʼnkŠˆmbÓù·þ‹¬æed2ìw4^K›òí¹/9úÂÛc–$Zƒé®B¬™ÔGw~ˆ›88ô'›å£5{ŒWÀ™g¥»;ØVT
385
	return tv;
386

386
}
387
€l‹Àí›iV¼[I[^"ÕÖ×Fœû£Õhw)ù2¨72Ûîºãaï¾%è֎w«»”ŒQ†_àbq!ý
ÙCšp-ô½!¬ss^y»%OÄDú7%R6%$‰ð=@œK(/ùÛW9'îµkҕsMü9J»“Dªåy³NÜMYÈ݉sP¯ЅwVÉZyk>ßØ
ž†ø=Z?RF±÷÷ʁÇ/¤ÀYC
387
# define ns_to_timeval portable_ns_to_timeval
388
oV—es­b_¼PÝG΄VÜb|ß8aAΦðî#ö÷
hƒtîc6,ø²a#Ú~惏 W1ùô`¸RY×܈µb<¸¦€¤‘{Ái¼þÁ¬ï<.-­'g¶òґ9uœÈÔ:lùå˷羯?ÓD`¬û4o¨“QÄq“„c`9$Á;ï½@ÑLð‹Ø~‚öƒ·ót<OnÙòÍÈÿd+Zéß#xØĦæ‰kíÙ
388
# endif
389
G'9¿ª¨:v*9_ÆÇ Ç»ã™ð½—d(’`-WßÅ΍ä]ô~vƒÀ~h	ëîAÒÄwžtp©.Ý®±xý6JaR„±ü&ØóJnaÂj@"Rí„Ô¨¯Ë!>Xòé5¿˜±ÂÁ6´”pà_IYPBâ×xÏsM2kPiSÞàtHHnJCú”?IÅ¢ïsÆFÃMs@ytu^A‘âàM<‹Ìí‘Eý tøU%8¹</{%“¼X˜âT41юŒù ú\ˆÌÆéS'îíÎ:KÅ"ð"lú¬1Ò*t!+uÚð€µ4	ÖÀð…ìaš,\îhÒQªr‡¾¤
ÕLޚ¢§gµ0³»ô,WÞjoé¸?ž"­bð’ª8®Ë%» ;™nrR¯;§zÛv®®9ÄAe½p,Z«P}z6žöo`½e¼S•|M˜~’!ƒ¥¿líµ.bj0'Gœ® ô!oOs5}¾æ͂N孅+̕l¿;¨¢¨ðn£‡™ÄE ¦ŠÑpXX¬?ƒµaÝS•»®‚WrAEÝwhR	 eÂXp«¯æcç7Žæc6áÜqA–ü¡¯U6#DÃ(ÛJ±³mÙ@Ù8ÓÂÁbôÚRìm…–%‡úÆ¿Gi4~ŽS:¼µßiÍjüNsØ.G9=™¹B>°'ýIw¬í÷Gð'ÏÓ=äáùÊK§c6u{,(fÑÒªk´F°{&½‚°;âv±ƒ,X’b“1§ÿ3³çe'…Çw™4¾ßÈ}kö_z°ž	bM
´²"ôA}õôþKZÃèlÝ¥
?£­>ïˆ?ž˜eÉ]͋ônÔöѹÍ&”(i	Gɛ/“½[æ˜P>x7‰-©„ãQ´n
;9Xqdì‘}Uq›¹æ ƒ€éÔJî#öB{ãÄ;ë#§F!fŒÏƒV¾Ê¹‰ŽŒÃïq
£U["ǃ!/bFÌ¡Ûh«4»y×A!!¦ƒ¹È}8cx?\š#u—œë<
389
 
390
c*¬ª5¬
æSZ$¦½̔?å<üfÖjDç
gKÅ@Sc„Ñàõù1K¢5žÍÀßZk✝ÞìÞ׍ñ¤ÌŽaŠ„Åͨ¢f-Œ5“ꤵu×öD|öWÇZ=M#¼ÿpÄp;VÒ8§…Í3ZÊ߅õf‡Mê÷.,Ç;*ò({oþ4a¥m…UEoÕ/äÈw³h2g×6e˜¾Ï‚®hŽœjÌេMãMª&¶mK=ÖÜ*fðZ FGڇŸ1„oàæÍU©A	àkl›Txڟ˜Ö¶Lز99«dœŒ¹€5Â.¹X
ëFÇWtꖘ"ðHø%Àjq>ÎÂ]í ‘˜ðŸb6ÄÕZ{¶{)N-I'$ã¢ë^Z$ÙDËí=žÂú<K†w	ο;vw(îñͅX.mók£¹‚ªi]ùÔòzã‘$(ëúƂAŠ6…䌞íh젋QˆãJQÈöÙZªã.
Ï¢ª•âÜP¼0L­ZÅÝKê¨ÅÂUÿXôœeñ4¹ó:_ÑgAÌÍ0¤P,™Äp3©pb>ϐø%Òº¥éj=êçYÞ®	ÍŔh{M:”³þ£ú·¯š:ŠÍµÁxr7¯ð»´ö‚´ûÏÊOx•KïNÏÿã›Ãc‰2¨s²Rs}÷˚کy»ÂÜu
Òxž™v[k-ÐýÇ]J­œïYšª©Ö4ÝØùð!7ý!K‹ô4´/ú·aßfÖO
Y˜ÇL¿ëNÖÔ¯‹#"þ'¼Ì€kÍS:1÷¦€í0’Ö’Lª$j@H³6WÄ'¾|
êÏJÔ —£&Emù£kwÍÄQ\Ä¡KyÚÝZsõ`šûb‹¯%ž“Y !QQ8^ÜݘFž><Îënë’I$ƒ-øJ„(3¹BÔ^3k֚µøMW=W(FàŠÓ¨—$3ÓàΣG~EÅO®ôÙ2Í´ÖÊGF@F:Š{/*®º«îç€s)6j;P@Xf1NÍùx
390
static inline s64 portable_ktime_to_ms(const ktime_t kt)
391
NoRN5Ãh®GßyÕ=}wrÅ&ùeKë°6‰ŒSöÜY{Î`Ë¢Ÿ½CbafNG&“`'-J-Óu‡/I8žèMãmÕ0âÞ_gÏ­]Û{gÝ,BŽ$àèp6Žz¯µÖoª5ï¶Ù·“™Wk³ÊÝde¶ëꓪߙZ²¤íúäX0†åµ[³| $¨|ª¦q`% ÎÅ?üŒ£Ø1l_¥¡€Ø=‡|çq¸n×ìºÆ€¨Fƒòˆ­•œ˜æ¢
LN;Gsƒg!Èö¹+ M[•|Ó÷“þMJ´ùKÔe9{!ò{
391
{
392
;zQI}.Öt/~†%|ÅY"¾{òÝÛCÒk˜Ô!hBŒ]–‹Ü&‚OŸçª×>×Bƒ$È+.æEôÿìÜ]G“˜”dôÞ&wåç‹5pŸ{U™› L\x7É}•du;‹uWí¹	©bbx+?ˆ;TL³Zuamj³\owu³+ëåâJ÷šh¬__ã+æ\K·Â¦b ¢>é—=¹¤þÉ 7ý”³$Ùçß%bÒËò“}?Bv”~IÒz¢µt¾ü,{ñ7tÿ”¤ÿòž}üÃõê{k1JĺlܗlϮΧ¼ÖRÈ1?µfSÈ_ò‘ÕGS„‰›ãú[çE>EÙPÆ\Aًd²ù—?þüùóçϟ?þüùóçϟ?þüùóçϟ?þüùóçϟ?þõóÿ@*ºx
392
	struct timeval tv = ktime_to_timeval(kt);
393
 
393
	return (s64) tv.tv_sec * MSEC_PER_SEC + tv.tv_usec / USEC_PER_MSEC;
394

Generated by GNU Enscript 1.6.6.
394
}
395
 
395
# define ktime_to_ms portable_ktime_to_ms
396
 
396
#endif /* before 2.6.35 */
397
 
397
 
-
 
398
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
-
 
399
static inline s64 portable_ktime_to_us(const ktime_t kt)
-
 
400
{
-
 
401
	struct timeval tv = ktime_to_timeval(kt);
-
 
402
	return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
-
 
403
}
-
 
404
#define ktime_to_us portable_ktime_to_us
-
 
405
#endif
-
 
406
 
-
 
407
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
-
 
408
static inline void put_unaligned_be16(u16 val, void *p)
-
 
409
{
-
 
410
	put_unaligned(cpu_to_be16(val), (__be16 *)p);
-
 
411
}
-
 
412
static inline void put_unaligned_be32(u32 val, void *p)
-
 
413
{
-
 
414
	put_unaligned(cpu_to_be32(val), (__be32 *)p);
-
 
415
}
-
 
416
static inline void put_unaligned_be64(u64 val, void *p)
-
 
417
{
-
 
418
	put_unaligned(cpu_to_be64(val), (__be64 *)p);
-
 
419
}
-
 
420
#endif
-
 
421
 
-
 
422
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24) && !defined(RHEL_MAJOR)
-
 
423
static void *__seq_open_private(struct file *f, struct seq_operations *ops,
-
 
424
    int psize)
-
 
425
{
-
 
426
	int rc;
-
 
427
	void *private;
-
 
428
	struct seq_file *seq;
-
 
429
 
-
 
430
	private = kzalloc(psize, GFP_KERNEL);
-
 
431
	if (private == NULL)
-
 
432
		goto out;
-
 
433
 
-
 
434
	rc = seq_open(f, ops);
-
 
435
	if (rc < 0)
-
 
436
		goto out_free;
-
 
437
 
-
 
438
	seq = f->private_data;
-
 
439
	seq->private = private;
-
 
440
	return private;
-
 
441
 
-
 
442
out_free:
-
 
443
	kfree(private);
-
 
444
out:
-
 
445
	return NULL;
-
 
446
}
-
 
447
#endif
-
 
448
 
-
 
449
/* disappeared in v3.19 */
-
 
450
#ifndef __get_cpu_var
-
 
451
#define __get_cpu_var(var)	(*this_cpu_ptr(&(var)))
-
 
452
#endif
-
 
453
 
-
 
454
#ifndef MPLS_HLEN
-
 
455
#define MPLS_HLEN 4
-
 
456
static inline int eth_p_mpls(__be16 eth_type)
-
 
457
{
-
 
458
	return eth_type == htons(ETH_P_MPLS_UC) ||
-
 
459
		eth_type == htons(ETH_P_MPLS_MC);
-
 
460
}
-
 
461
#endif
-
 
462
#ifndef MPLS_LS_S_MASK
-
 
463
struct mpls_label {
-
 
464
	__be32 entry;
-
 
465
};
-
 
466
#define MPLS_LS_S_MASK		0x00000100
-
 
467
 
-
 
468
#endif
-
 
469
 
-
 
470
/* sockaddr comparison functions is from fs/nfs/client.c */
-
 
471
static int sockaddr_match_ipaddr6(const struct sockaddr *sa1, const struct sockaddr *sa2)
-
 
472
{
-
 
473
	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
-
 
474
	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
-
 
475
 
-
 
476
	if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
-
 
477
		return 0;
-
 
478
#if 0
-
 
479
	else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL)
-
 
480
		return sin1->sin6_scope_id == sin2->sin6_scope_id;
-
 
481
#endif
-
 
482
	return 1;
-
 
483
}
-
 
484
 
-
 
485
static int sockaddr_match_ipaddr4(const struct sockaddr *sa1, const struct sockaddr *sa2)
-
 
486
{
-
 
487
	const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
-
 
488
	const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
-
 
489
 
-
 
490
	return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
-
 
491
}
-
 
492
 
-
 
493
static int sockaddr_cmp_ip6(const struct sockaddr *sa1, const struct sockaddr *sa2)
-
 
494
{
-
 
495
	const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1;
-
 
496
	const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2;
-
 
497
 
-
 
498
	return sockaddr_match_ipaddr6(sa1, sa2) &&
-
 
499
		(sin1->sin6_port == sin2->sin6_port);
-
 
500
}
-
 
501
 
-
 
502
static int sockaddr_cmp_ip4(const struct sockaddr *sa1, const struct sockaddr *sa2)
-
 
503
{
-
 
504
	const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
-
 
505
	const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
-
 
506
 
-
 
507
	return sockaddr_match_ipaddr4(sa1, sa2) &&
-
 
508
		(sin1->sin_port == sin2->sin_port);
-
 
509
}
-
 
510
 
-
 
511
static int sockaddr_cmp(const struct sockaddr_storage *sa1, const struct sockaddr_storage *sa2)
-
 
512
{
-
 
513
	const struct sockaddr *s1 = (const struct sockaddr *)sa1;
-
 
514
	const struct sockaddr *s2 = (const struct sockaddr *)sa2;
-
 
515
 
-
 
516
	if (sa1->ss_family != sa2->ss_family)
-
 
517
		return 0;
-
 
518
 
-
 
519
	switch (sa1->ss_family) {
-
 
520
	case AF_INET:
-
 
521
		return sockaddr_cmp_ip4(s1, s2);
-
 
522
	case AF_INET6:
-
 
523
		return sockaddr_cmp_ip6(s1, s2);
-
 
524
	}
-
 
525
	return 0;
-
 
526
}
-
 
527
 
-
 
528
#ifndef IN6PTON_XDIGIT
-
 
529
#define hex_to_bin compat_hex_to_bin
-
 
530
/* lib/hexdump.c */
-
 
531
int hex_to_bin(char ch)
-
 
532
{
-
 
533
	if ((ch >= '0') && (ch <= '9'))
-
 
534
		return ch - '0';
-
 
535
	ch = tolower(ch);
-
 
536
	if ((ch >= 'a') && (ch <= 'f'))
-
 
537
		return ch - 'a' + 10;
-
 
538
	return -1;
-
 
539
}
-
 
540
 
-
 
541
/* net/core/utils.c */
-
 
542
#define IN6PTON_XDIGIT		0x00010000
-
 
543
#define IN6PTON_DIGIT		0x00020000
-
 
544
#define IN6PTON_COLON_MASK	0x00700000
-
 
545
#define IN6PTON_COLON_1		0x00100000	/* single : requested */
-
 
546
#define IN6PTON_COLON_2		0x00200000	/* second : requested */
-
 
547
#define IN6PTON_COLON_1_2	0x00400000	/* :: requested */
-
 
548
#define IN6PTON_DOT		0x00800000	/* . */
-
 
549
#define IN6PTON_DELIM		0x10000000
-
 
550
#define IN6PTON_NULL		0x20000000	/* first/tail */
-
 
551
#define IN6PTON_UNKNOWN		0x40000000
-
 
552
 
-
 
553
static inline int xdigit2bin(char c, int delim)
-
 
554
{
-
 
555
	int val;
-
 
556
 
-
 
557
	if (c == delim || c == '\0')
-
 
558
		return IN6PTON_DELIM;
-
 
559
	if (c == ':')
-
 
560
		return IN6PTON_COLON_MASK;
-
 
561
	if (c == '.')
-
 
562
		return IN6PTON_DOT;
-
 
563
 
-
 
564
	val = hex_to_bin(c);
-
 
565
	if (val >= 0)
-
 
566
		return val | IN6PTON_XDIGIT | (val < 10 ? IN6PTON_DIGIT : 0);
-
 
567
 
-
 
568
	if (delim == -1)
-
 
569
		return IN6PTON_DELIM;
-
 
570
	return IN6PTON_UNKNOWN;
-
 
571
}
-
 
572
 
-
 
573
int in4_pton(const char *src, int srclen,
-
 
574
	     u8 *dst,
-
 
575
	     int delim, const char **end)
-
 
576
{
-
 
577
	const char *s;
-
 
578
	u8 *d;
-
 
579
	u8 dbuf[4];
-
 
580
	int ret = 0;
-
 
581
	int i;
-
 
582
	int w = 0;
-
 
583
 
-
 
584
	if (srclen < 0)
-
 
585
		srclen = strlen(src);
-
 
586
	s = src;
-
 
587
	d = dbuf;
-
 
588
	i = 0;
-
 
589
	while(1) {
-
 
590
		int c;
-
 
591
		c = xdigit2bin(srclen > 0 ? *s : '\0', delim);
-
 
592
		if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK))) {
-
 
593
			goto out;
-
 
594
		}
-
 
595
		if (c & (IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
-
 
596
			if (w == 0)
-
 
597
				goto out;
-
 
598
			*d++ = w & 0xff;
-
 
599
			w = 0;
-
 
600
			i++;
-
 
601
			if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
-
 
602
				if (i != 4)
-
 
603
					goto out;
-
 
604
				break;
-
 
605
			}
-
 
606
			goto cont;
-
 
607
		}
-
 
608
		w = (w * 10) + c;
-
 
609
		if ((w & 0xffff) > 255) {
-
 
610
			goto out;
-
 
611
		}
-
 
612
cont:
-
 
613
		if (i >= 4)
-
 
614
			goto out;
-
 
615
		s++;
-
 
616
		srclen--;
-
 
617
	}
-
 
618
	ret = 1;
-
 
619
	memcpy(dst, dbuf, sizeof(dbuf));
-
 
620
out:
-
 
621
	if (end)
-
 
622
		*end = s;
-
 
623
	return ret;
-
 
624
}
-
 
625
 
-
 
626
int in6_pton(const char *src, int srclen,
-
 
627
	     u8 *dst,
-
 
628
	     int delim, const char **end)
-
 
629
{
-
 
630
	const char *s, *tok = NULL;
-
 
631
	u8 *d, *dc = NULL;
-
 
632
	u8 dbuf[16];
-
 
633
	int ret = 0;
-
 
634
	int i;
-
 
635
	int state = IN6PTON_COLON_1_2 | IN6PTON_XDIGIT | IN6PTON_NULL;
-
 
636
	int w = 0;
-
 
637
 
-
 
638
	memset(dbuf, 0, sizeof(dbuf));
-
 
639
 
-
 
640
	s = src;
-
 
641
	d = dbuf;
-
 
642
	if (srclen < 0)
-
 
643
		srclen = strlen(src);
-
 
644
 
-
 
645
	while (1) {
-
 
646
		int c;
-
 
647
 
-
 
648
		c = xdigit2bin(srclen > 0 ? *s : '\0', delim);
-
 
649
		if (!(c & state))
-
 
650
			goto out;
-
 
651
		if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
-
 
652
			/* process one 16-bit word */
-
 
653
			if (!(state & IN6PTON_NULL)) {
-
 
654
				*d++ = (w >> 8) & 0xff;
-
 
655
				*d++ = w & 0xff;
-
 
656
			}
-
 
657
			w = 0;
-
 
658
			if (c & IN6PTON_DELIM) {
-
 
659
				/* We've processed last word */
-
 
660
				break;
-
 
661
			}
-
 
662
			/*
-
 
663
			 * COLON_1 => XDIGIT
-
 
664
			 * COLON_2 => XDIGIT|DELIM
-
 
665
			 * COLON_1_2 => COLON_2
-
 
666
			 */
-
 
667
			switch (state & IN6PTON_COLON_MASK) {
-
 
668
			case IN6PTON_COLON_2:
-
 
669
				dc = d;
-
 
670
				state = IN6PTON_XDIGIT | IN6PTON_DELIM;
-
 
671
				if (dc - dbuf >= sizeof(dbuf))
-
 
672
					state |= IN6PTON_NULL;
-
 
673
				break;
-
 
674
			case IN6PTON_COLON_1|IN6PTON_COLON_1_2:
-
 
675
				state = IN6PTON_XDIGIT | IN6PTON_COLON_2;
-
 
676
				break;
-
 
677
			case IN6PTON_COLON_1:
-
 
678
				state = IN6PTON_XDIGIT;
-
 
679
				break;
-
 
680
			case IN6PTON_COLON_1_2:
-
 
681
				state = IN6PTON_COLON_2;
-
 
682
				break;
-
 
683
			default:
-
 
684
				state = 0;
-
 
685
			}
-
 
686
			tok = s + 1;
-
 
687
			goto cont;
-
 
688
		}
-
 
689
 
-
 
690
		if (c & IN6PTON_DOT) {
-
 
691
			ret = in4_pton(tok ? tok : s, srclen + (int)(s - tok), d, delim, &s);
-
 
692
			if (ret > 0) {
-
 
693
				d += 4;
-
 
694
				break;
-
 
695
			}
-
 
696
			goto out;
-
 
697
		}
-
 
698
 
-
 
699
		w = (w << 4) | (0xff & c);
-
 
700
		state = IN6PTON_COLON_1 | IN6PTON_DELIM;
-
 
701
		if (!(w & 0xf000)) {
-
 
702
			state |= IN6PTON_XDIGIT;
-
 
703
		}
-
 
704
		if (!dc && d + 2 < dbuf + sizeof(dbuf)) {
-
 
705
			state |= IN6PTON_COLON_1_2;
-
 
706
			state &= ~IN6PTON_DELIM;
-
 
707
		}
-
 
708
		if (d + 2 >= dbuf + sizeof(dbuf)) {
-
 
709
			state &= ~(IN6PTON_COLON_1|IN6PTON_COLON_1_2);
-
 
710
		}
-
 
711
cont:
-
 
712
		if ((dc && d + 4 < dbuf + sizeof(dbuf)) ||
-
 
713
		    d + 4 == dbuf + sizeof(dbuf)) {
-
 
714
			state |= IN6PTON_DOT;
-
 
715
		}
-
 
716
		if (d >= dbuf + sizeof(dbuf)) {
-
 
717
			state &= ~(IN6PTON_XDIGIT|IN6PTON_COLON_MASK);
-
 
718
		}
-
 
719
		s++;
-
 
720
		srclen--;
-
 
721
	}
-
 
722
 
-
 
723
	i = 15; d--;
-
 
724
 
-
 
725
	if (dc) {
-
 
726
		while(d >= dc)
-
 
727
			dst[i--] = *d--;
-
 
728
		while(i >= dc - dbuf)
-
 
729
			dst[i--] = 0;
-
 
730
		while(i >= 0)
-
 
731
			dst[i--] = *d--;
-
 
732
	} else
-
 
733
		memcpy(dst, dbuf, sizeof(dbuf));
-
 
734
 
-
 
735
	ret = 1;
-
 
736
out:
-
 
737
	if (end)
-
 
738
		*end = s;
-
 
739
	return ret;
-
 
740
}
-
 
741
#endif /* IN6PTON_XDIGIT */
-
 
742
 
-
 
743
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
-
 
744
# define sock_create_kern(f, t, p, s) sock_create_kern(&init_net, f, t, p, s)
-
 
745
#endif
-
 
746
 
-
 
747
#if !defined(vlan_tx_tag_get) && defined(skb_vlan_tag_get)
-
 
748
# define vlan_tx_tag_get skb_vlan_tag_get
-
 
749
# define vlan_tx_tag_present skb_vlan_tag_present
-
 
750
#endif
-
 
751
 
-
 
752
#ifndef SPEED_UNKNOWN
-
 
753
# define SPEED_UNKNOWN		-1
-
 
754
#endif
-
 
755
 
-
 
756
#if !defined __GNUC_PREREQ && defined __GNUC__ && defined __GNUC_MINOR__
-
 
757
# define __GNUC_PREREQ(maj, min) \
-
 
758
	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-
 
759
#else
-
 
760
# define __GNUC_PREREQ(maj, min) 0
-
 
761
#endif
-
 
762
 
-
 
763
/* ktime is not union anymore, since 2456e855354415bfaeb7badaa14e11b3e02c8466 */
-
 
764
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
-
 
765
# define first_tv64	first.tv64
-
 
766
# define last_tv64	last.tv64
-
 
767
#else
-
 
768
# define first_tv64	first
-
 
769
# define last_tv64	last
-
 
770
#endif
-
 
771
 
-
 
772
/* Offset changes made in 613dbd95723aee7abd16860745691b6c7bda20dc */
-
 
773
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
-
 
774
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
-
 
775
#  define xt_action_param xt_target_param
-
 
776
# endif
-
 
777
static inline u_int8_t xt_family(const struct xt_action_param *par)
-
 
778
{
-
 
779
	return par->family;
-
 
780
}
-
 
781
static inline const struct net_device *xt_in(const struct xt_action_param *par)
-
 
782
{
-
 
783
	return par->in;
-
 
784
}
-
 
785
static inline const struct net_device *xt_out(const struct xt_action_param *par)
-
 
786
{
-
 
787
	return par->out;
-
 
788
}
-
 
789
static inline unsigned int xt_hooknum(const struct xt_action_param *par)
-
 
790
{
-
 
791
	return par->hooknum;
-
 
792
}
-
 
793
#endif
-
 
794
 
-
 
795
#ifndef SK_CAN_REUSE
-
 
796
# define SK_CAN_REUSE   1
-
 
797
#endif
-
 
798
 
-
 
799
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0)
-
 
800
# define compat_refcount_read atomic_read
-
 
801
#else
-
 
802
# define compat_refcount_read refcount_read
-
 
803
#endif
-
 
804
 
-
 
805
#endif /* COMPAT_NETFLOW_H */
-
 
806
ipt-netflow-2.2/IPT-NETFLOW-MIB.my0000644000000000000000000004327713213006644015063 0ustar  rootroot-- IPT-NETFLOW-MIB.my
-
 
807
 
-
 
808
IPT-NETFLOW-MIB DEFINITIONS ::= BEGIN
-
 
809
 
-
 
810
IMPORTS
-
 
811
    MODULE-IDENTITY, OBJECT-TYPE, Counter64,
-
 
812
    Gauge32, Integer32, Counter32, enterprises
-
 
813
	FROM SNMPv2-SMI
-
 
814
    OBJECT-GROUP, MODULE-COMPLIANCE
-
 
815
	FROM SNMPv2-CONF
-
 
816
    CounterBasedGauge64
-
 
817
	FROM HCNUM-TC
-
 
818
    TEXTUAL-CONVENTION, DisplayString, DateAndTime
-
 
819
	FROM SNMPv2-TC;
-
 
820
 
-
 
821
iptNetflowMIB MODULE-IDENTITY
-
 
822
    LAST-UPDATED "201409120000Z"
-
 
823
    ORGANIZATION "ABC"
-
 
824
    CONTACT-INFO
-
 
825
	"Author's email: abc at telekom.ru
-
 
826
 
-
 
827
	Latest version should be obtained from
-
 
828
	https://raw.githubusercontent.com/aabc/ipt-netflow/master/IPT-NETFLOW-MIB.my"
-
 
829
 
-
 
830
    DESCRIPTION
-
 
831
	"The IPT-NETFLOW-MIB defines managed objects
-
 
832
	for ipt_NETFLOW kernel module, which is high
-
 
833
	performance NetFlow/IPFIX probe for Linux.
-
 
834
 
-
 
835
	Copyright (c) 2014 <abc at telekom.ru>.
-
 
836
 
-
 
837
	License: GPL"
-
 
838
 
-
 
839
    REVISION	"201409110000Z"
-
 
840
    DESCRIPTION "Initial revision."
-
 
841
 
-
 
842
    ::= { enterprises 37476 9000 10 1 }
-
 
843
 
-
 
844
-- Top Level --
-
 
845
iptNetflowObjects	OBJECT IDENTIFIER ::= { iptNetflowMIB 1 }
-
 
846
iptNetflowStatistics	OBJECT IDENTIFIER ::= { iptNetflowMIB 2 }
-
 
847
iptNetflowConformance	OBJECT IDENTIFIER ::= { iptNetflowMIB 3 }
-
 
848
 
-
 
849
-- Objects --
-
 
850
 
-
 
851
-- modinfo
-
 
852
iptNetflowModule	OBJECT IDENTIFIER ::= { iptNetflowObjects 1 }
-
 
853
-- sysctl net.netflow
-
 
854
iptNetflowSysctl	OBJECT IDENTIFIER ::= { iptNetflowObjects 2 }
-
 
855
 
-
 
856
-- Modinfo Objects --
-
 
857
 
-
 
858
name OBJECT-TYPE
-
 
859
    SYNTAX	DisplayString
-
 
860
    MAX-ACCESS	read-only
-
 
861
    STATUS	current
-
 
862
    DESCRIPTION
-
 
863
	"Module name."
-
 
864
    ::= { iptNetflowModule 1 }
-
 
865
 
-
 
866
version OBJECT-TYPE
-
 
867
    SYNTAX	DisplayString
-
 
868
    MAX-ACCESS	read-only
-
 
869
    STATUS	current
-
 
870
    DESCRIPTION
-
 
871
	"Software version of the module."
-
 
872
    ::= { iptNetflowModule 2 }
-
 
873
 
-
 
874
srcversion OBJECT-TYPE
-
 
875
    SYNTAX	DisplayString
-
 
876
    MAX-ACCESS	read-only
-
 
877
    STATUS	current
-
 
878
    DESCRIPTION
-
 
879
	 "Binary version of the module."
-
 
880
    ::= { iptNetflowModule 3 }
-
 
881
 
-
 
882
loadTime OBJECT-TYPE
-
 
883
    SYNTAX	DateAndTime
-
 
884
    MAX-ACCESS	read-only
-
 
885
    STATUS	current
-
 
886
    DESCRIPTION
-
 
887
	 "Module load date-time."
-
 
888
    ::= { iptNetflowModule 4 }
-
 
889
 
-
 
890
refcnt OBJECT-TYPE
-
 
891
    SYNTAX	Integer32
-
 
892
    MAX-ACCESS	read-only
-
 
893
    STATUS	current
-
 
894
    DESCRIPTION
-
 
895
	 "Module usage by other kernel objects."
-
 
896
    ::= { iptNetflowModule 5 }
-
 
897
 
-
 
898
-- RW Sysctl objects --
-
 
899
 
-
 
900
protocol OBJECT-TYPE
-
 
901
    SYNTAX	INTEGER {
-
 
902
	netflow5(5),
-
 
903
	netflow9(9),
-
 
904
	ipfix(10)
-
 
905
    }
-
 
906
    MAX-ACCESS	read-write
-
 
907
    STATUS	current
-
 
908
    DESCRIPTION
-
 
909
	"Protocol version (5, 9, 10=IPFIX)."
-
 
910
    ::= { iptNetflowSysctl 1 }
-
 
911
 
-
 
912
hashsize OBJECT-TYPE
-
 
913
    SYNTAX	Integer32
-
 
914
    UNITS	"buckets"
-
 
915
    MAX-ACCESS	read-write
-
 
916
    STATUS	current
-
 
917
    DESCRIPTION
-
 
918
	"Hash table size of flows cache."
-
 
919
    ::= { iptNetflowSysctl 2 }
-
 
920
 
-
 
921
maxflows OBJECT-TYPE
-
 
922
    SYNTAX	Integer32
-
 
923
    UNITS	"flows"
-
 
924
    MAX-ACCESS	read-write
-
 
925
    STATUS	current
-
 
926
    DESCRIPTION
-
 
927
	"Max flows limit. This limit is used for DoS protection."
-
 
928
    ::= { iptNetflowSysctl 3 }
-
 
929
 
-
 
930
active-timeout OBJECT-TYPE
-
 
931
    SYNTAX	Integer32
-
 
932
    UNITS	"minutes"
-
 
933
    MAX-ACCESS	read-write
-
 
934
    STATUS	current
-
 
935
    DESCRIPTION
-
 
936
	"Active flows timeout value."
-
 
937
    ::= { iptNetflowSysctl 4 }
-
 
938
 
-
 
939
inactive-timeout OBJECT-TYPE
-
 
940
    SYNTAX	Integer32
-
 
941
    UNITS	"minutes"
-
 
942
    MAX-ACCESS	read-write
-
 
943
    STATUS	current
-
 
944
    DESCRIPTION
-
 
945
	"Inactive flows timeout value."
-
 
946
    ::= { iptNetflowSysctl 5 }
-
 
947
 
-
 
948
sndbuf OBJECT-TYPE
-
 
949
    SYNTAX	Integer32
-
 
950
    UNITS	"bytes"
-
 
951
    MAX-ACCESS	read-write
-
 
952
    STATUS	current
-
 
953
    DESCRIPTION
-
 
954
	"Sockets SNDBUF size."
-
 
955
    ::= { iptNetflowSysctl 6 }
-
 
956
 
-
 
957
destination OBJECT-TYPE
-
 
958
    SYNTAX	DisplayString
-
 
959
    MAX-ACCESS	read-write
-
 
960
    STATUS	current
-
 
961
    DESCRIPTION
-
 
962
	"Export destination parameter."
-
 
963
    ::= { iptNetflowSysctl 7 }
-
 
964
 
-
 
965
aggregation OBJECT-TYPE
-
 
966
    SYNTAX	DisplayString
-
 
967
    MAX-ACCESS	read-write
-
 
968
    STATUS	current
-
 
969
    DESCRIPTION
-
 
970
	"Aggregation parameters."
-
 
971
    ::= { iptNetflowSysctl 8 }
-
 
972
 
-
 
973
sampler OBJECT-TYPE
-
 
974
    SYNTAX	DisplayString
-
 
975
    MAX-ACCESS	read-write
-
 
976
    STATUS	current
-
 
977
    DESCRIPTION
-
 
978
	"Sampler parameters: sampling mode:sampling interval.
-
 
979
	Where samplign modes: deterministic, random, hash."
-
 
980
    ::= { iptNetflowSysctl 9 }
-
 
981
 
-
 
982
natevents OBJECT-TYPE
-
 
983
    SYNTAX	INTEGER {
-
 
984
	disabled(0),
-
 
985
	enabled(1)
-
 
986
    }
-
 
987
    MAX-ACCESS	read-write
-
 
988
    STATUS	current
-
 
989
    DESCRIPTION
-
 
990
	"Natevents (NEL) controlling parameter."
-
 
991
    ::= { iptNetflowSysctl 10 }
-
 
992
 
-
 
993
promisc OBJECT-TYPE
-
 
994
    SYNTAX	INTEGER {
-
 
995
	disabled(0),
-
 
996
	enabled(1)
-
 
997
    }
-
 
998
    MAX-ACCESS	read-write
-
 
999
    STATUS	current
-
 
1000
    DESCRIPTION
-
 
1001
	"Promisc hack controlling parameter."
-
 
1002
    ::= { iptNetflowSysctl 11 }
-
 
1003
 
-
 
1004
snmp-rules OBJECT-TYPE
-
 
1005
    SYNTAX	DisplayString
-
 
1006
    MAX-ACCESS	read-write
-
 
1007
    STATUS	current
-
 
1008
    DESCRIPTION
-
 
1009
	"SNMP-index translation rules."
-
 
1010
    ::= { iptNetflowSysctl 12 }
-
 
1011
 
-
 
1012
scan-min OBJECT-TYPE
-
 
1013
    SYNTAX	Integer32
-
 
1014
    MAX-ACCESS	read-write
-
 
1015
    STATUS	current
-
 
1016
    DESCRIPTION
-
 
1017
	"scan-min parameter."
-
 
1018
    ::= { iptNetflowSysctl 13 }
-
 
1019
 
-
 
1020
-- Statistics Objects --
-
 
1021
 
-
 
1022
iptNetflowTotals	OBJECT IDENTIFIER ::= { iptNetflowStatistics 1 }
-
 
1023
 
-
 
1024
inBitRate OBJECT-TYPE
-
 
1025
    SYNTAX      CounterBasedGauge64
-
 
1026
    UNITS       "bits/second"
-
 
1027
    MAX-ACCESS  read-only
-
 
1028
    STATUS      current
-
 
1029
    DESCRIPTION
-
 
1030
	"Total incoming bits per second."
-
 
1031
::= { iptNetflowTotals 1 }
-
 
1032
 
-
 
1033
inPacketRate OBJECT-TYPE
-
 
1034
    SYNTAX      Gauge32
-
 
1035
    UNITS       "packets/second"
-
 
1036
    MAX-ACCESS  read-only
-
 
1037
    STATUS      current
-
 
1038
    DESCRIPTION
-
 
1039
	"Total incoming packets per second."
-
 
1040
::= { iptNetflowTotals 2 }
-
 
1041
 
-
 
1042
inFlows OBJECT-TYPE
-
 
1043
    SYNTAX      Counter64
-
 
1044
    UNITS       "flows"
-
 
1045
    MAX-ACCESS  read-only
-
 
1046
    STATUS      current
-
 
1047
    DESCRIPTION
-
 
1048
	"Total observed (metered) flows."
-
 
1049
::= { iptNetflowTotals 3 }
-
 
1050
 
-
 
1051
inPackets OBJECT-TYPE
-
 
1052
    SYNTAX      Counter64
-
 
1053
    UNITS       "packets"
-
 
1054
    MAX-ACCESS  read-only
-
 
1055
    STATUS      current
-
 
1056
    DESCRIPTION
-
 
1057
	"Total metered packets. Not couning dropped packets."
-
 
1058
::= { iptNetflowTotals 4 }
-
 
1059
 
-
 
1060
inBytes OBJECT-TYPE
-
 
1061
    SYNTAX      Counter64
-
 
1062
    UNITS       "bytes"
-
 
1063
    MAX-ACCESS  read-only
-
 
1064
    STATUS      current
-
 
1065
    DESCRIPTION
-
 
1066
	"Total metered bytes in inPackets."
-
 
1067
::= { iptNetflowTotals 5 }
-
 
1068
 
-
 
1069
FixedDiv100 ::= TEXTUAL-CONVENTION
-
 
1070
    DISPLAY-HINT "d-2"
-
 
1071
    STATUS	current
-
 
1072
    DESCRIPTION "Fixed point, two decimals."
-
 
1073
    SYNTAX	Gauge32
-
 
1074
 
-
 
1075
hashMetric OBJECT-TYPE
-
 
1076
    SYNTAX      FixedDiv100
-
 
1077
    MAX-ACCESS  read-only
-
 
1078
    STATUS      current
-
 
1079
    DESCRIPTION
-
 
1080
	"Measure of performance of hash table. When optimal should
-
 
1081
	attract to 1.0, when non-optimal will be highly above of 1."
-
 
1082
::= { iptNetflowTotals 6 }
-
 
1083
 
-
 
1084
hashMemory OBJECT-TYPE
-
 
1085
    SYNTAX      Gauge32
-
 
1086
    UNITS       "bytes"
-
 
1087
    MAX-ACCESS  read-only
-
 
1088
    STATUS      current
-
 
1089
    DESCRIPTION
-
 
1090
	"How much system memory is used by the hash table."
-
 
1091
::= { iptNetflowTotals 7 }
-
 
1092
 
-
 
1093
hashFlows OBJECT-TYPE
-
 
1094
    SYNTAX      Gauge32
-
 
1095
    UNITS       "flows"
-
 
1096
    MAX-ACCESS  read-only
-
 
1097
    STATUS      current
-
 
1098
    DESCRIPTION
-
 
1099
	"Flows currently residing in the hash table and not
-
 
1100
	exported yet."
-
 
1101
::= { iptNetflowTotals 8 }
-
 
1102
 
-
 
1103
hashPackets OBJECT-TYPE
-
 
1104
    SYNTAX      Gauge32
-
 
1105
    UNITS       "packets"
-
 
1106
    MAX-ACCESS  read-only
-
 
1107
    STATUS      current
-
 
1108
    DESCRIPTION
-
 
1109
	"Packets in flows currently residing in the hash table."
-
 
1110
::= { iptNetflowTotals 9 }
-
 
1111
 
-
 
1112
hashBytes OBJECT-TYPE
-
 
1113
    SYNTAX      CounterBasedGauge64
-
 
1114
    UNITS       "bytes"
-
 
1115
    MAX-ACCESS  read-only
-
 
1116
    STATUS      current
-
 
1117
    DESCRIPTION
-
 
1118
	"Bytes in flows currently residing in the hash table."
-
 
1119
::= { iptNetflowTotals 10 }
-
 
1120
 
-
 
1121
dropPackets OBJECT-TYPE
-
 
1122
    SYNTAX      Counter64
-
 
1123
    UNITS       "packets"
-
 
1124
    MAX-ACCESS  read-only
-
 
1125
    STATUS      current
-
 
1126
    DESCRIPTION
-
 
1127
	"Total packets dropped by metering process."
-
 
1128
::= { iptNetflowTotals 11 }
-
 
1129
 
-
 
1130
dropBytes OBJECT-TYPE
-
 
1131
    SYNTAX      Counter64
-
 
1132
    UNITS       "bytes"
-
 
1133
    MAX-ACCESS  read-only
-
 
1134
    STATUS      current
-
 
1135
    DESCRIPTION
-
 
1136
	"Total bytes in packets dropped by metering process."
-
 
1137
::= { iptNetflowTotals 12 }
-
 
1138
 
-
 
1139
outByteRate OBJECT-TYPE
-
 
1140
    SYNTAX      Gauge32
-
 
1141
    UNITS       "bytes/second"
-
 
1142
    MAX-ACCESS  read-only
-
 
1143
    STATUS      current
-
 
1144
    DESCRIPTION
-
 
1145
	"Total exporter output bytes per second."
-
 
1146
::= { iptNetflowTotals 13 }
-
 
1147
 
-
 
1148
outFlows OBJECT-TYPE
-
 
1149
    SYNTAX      Counter64
-
 
1150
    UNITS       "flows"
-
 
1151
    MAX-ACCESS  read-only
-
 
1152
    STATUS      current
-
 
1153
    DESCRIPTION
-
 
1154
	"Total exported flow data records."
-
 
1155
::= { iptNetflowTotals 14 }
-
 
1156
 
-
 
1157
outPackets OBJECT-TYPE
-
 
1158
    SYNTAX      Counter64
-
 
1159
    UNITS       "packets"
-
 
1160
    MAX-ACCESS  read-only
-
 
1161
    STATUS      current
-
 
1162
    DESCRIPTION
-
 
1163
	"Total exported packets of netflow stream itself."
-
 
1164
::= { iptNetflowTotals 15 }
-
 
1165
 
-
 
1166
outBytes OBJECT-TYPE
-
 
1167
    SYNTAX      Counter64
-
 
1168
    UNITS       "bytes"
-
 
1169
    MAX-ACCESS  read-only
-
 
1170
    STATUS      current
-
 
1171
    DESCRIPTION
-
 
1172
	"Total exported bytes of netflow stream itself."
-
 
1173
::= { iptNetflowTotals 16 }
-
 
1174
 
-
 
1175
lostFlows OBJECT-TYPE
-
 
1176
    SYNTAX      Counter64
-
 
1177
    UNITS       "flows"
-
 
1178
    MAX-ACCESS  read-only
-
 
1179
    STATUS      current
-
 
1180
    DESCRIPTION
-
 
1181
	"Total of accounted flows that are lost by exporting process
-
 
1182
	 due to socket errors. This value will not include asynchronous
-
 
1183
	 errors (cberr), these will be counted in errTotal."
-
 
1184
::= { iptNetflowTotals 17 }
-
 
1185
 
-
 
1186
lostPackets OBJECT-TYPE
-
 
1187
    SYNTAX      Counter64
-
 
1188
    UNITS       "packets"
-
 
1189
    MAX-ACCESS  read-only
-
 
1190
    STATUS      current
-
 
1191
    DESCRIPTION
-
 
1192
	"Total metered packets lost by exporting process.
-
 
1193
	 See lostFlows for details."
-
 
1194
::= { iptNetflowTotals 18 }
-
 
1195
 
-
 
1196
lostBytes OBJECT-TYPE
-
 
1197
    SYNTAX      Counter64
-
 
1198
    UNITS       "bytes"
-
 
1199
    MAX-ACCESS  read-only
-
 
1200
    STATUS      current
-
 
1201
    DESCRIPTION
-
 
1202
	"Total bytes in packets lost by exporting process.
-
 
1203
	 See lostFlows for details."
-
 
1204
::= { iptNetflowTotals 19 }
-
 
1205
 
-
 
1206
errTotal OBJECT-TYPE
-
 
1207
    SYNTAX      Counter32
-
 
1208
    MAX-ACCESS  read-only
-
 
1209
    STATUS      current
-
 
1210
    DESCRIPTION
-
 
1211
	"Total exporting sockets errors (including cberr)."
-
 
1212
::= { iptNetflowTotals 20 }
-
 
1213
 
-
 
1214
sndbufPeak OBJECT-TYPE
-
 
1215
    SYNTAX      Counter32
-
 
1216
    UNITS       "bytes"
-
 
1217
    MAX-ACCESS  read-only
-
 
1218
    STATUS      current
-
 
1219
    DESCRIPTION
-
 
1220
	"Global maximum value of socket sndbuf. Sort of output
-
 
1221
	queue length."
-
 
1222
::= { iptNetflowTotals 21 }
-
 
1223
 
-
 
1224
-- Per CPU statistics --
-
 
1225
 
-
 
1226
iptNetflowCpuTable OBJECT-TYPE
-
 
1227
    SYNTAX	SEQUENCE OF IptNetflowCpuEntry
-
 
1228
    MAX-ACCESS	not-accessible
-
 
1229
    STATUS	current
-
 
1230
    DESCRIPTION
-
 
1231
	"Per-CPU statistics."
-
 
1232
    ::= { iptNetflowStatistics 2 }
-
 
1233
 
-
 
1234
iptNetflowCpuEntry OBJECT-TYPE
-
 
1235
    SYNTAX	IptNetflowCpuEntry
-
 
1236
    MAX-ACCESS	not-accessible
-
 
1237
    STATUS	current
-
 
1238
    DESCRIPTION
-
 
1239
	"Defines an entry in the iptNetflowCpuTable."
-
 
1240
    INDEX	{ cpuIndex }
-
 
1241
    ::= { iptNetflowCpuTable 1 }
-
 
1242
 
-
 
1243
IptNetflowCpuEntry ::=
-
 
1244
    SEQUENCE {
-
 
1245
      cpuIndex		INTEGER,
-
 
1246
      cpuInPacketRate	Gauge32,
-
 
1247
      cpuInFlows	Counter64,
-
 
1248
      cpuInPackets	Counter64,
-
 
1249
      cpuInBytes	Counter64,
-
 
1250
      cpuHashMetric	FixedDiv100,
-
 
1251
      cpuDropPackets	Counter64,
-
 
1252
      cpuDropBytes	Counter64,
-
 
1253
      cpuErrTrunc	Counter32,
-
 
1254
      cpuErrFrag	Counter32,
-
 
1255
      cpuErrAlloc	Counter32,
-
 
1256
      cpuErrMaxflows	Counter32
-
 
1257
    }
-
 
1258
 
-
 
1259
cpuIndex OBJECT-TYPE
-
 
1260
    SYNTAX	Integer32 (0..4096)
-
 
1261
    MAX-ACCESS	read-only
-
 
1262
    STATUS	current
-
 
1263
    DESCRIPTION
-
 
1264
	"Index of this cpu."
-
 
1265
    ::= { iptNetflowCpuEntry 1 }
-
 
1266
 
-
 
1267
cpuInPacketRate OBJECT-TYPE
-
 
1268
    SYNTAX	Gauge32
-
 
1269
    UNITS	"packets/second"
-
 
1270
    MAX-ACCESS	read-only
-
 
1271
    STATUS	current
-
 
1272
    DESCRIPTION
-
 
1273
	"Incoming packets per second for this cpu."
-
 
1274
    ::= { iptNetflowCpuEntry 2 }
-
 
1275
 
-
 
1276
cpuInFlows OBJECT-TYPE
-
 
1277
    SYNTAX	Counter64
-
 
1278
    UNITS	"flows"
-
 
1279
    MAX-ACCESS	read-only
-
 
1280
    STATUS	current
-
 
1281
    DESCRIPTION
-
 
1282
	"Flows metered on this cpu."
-
 
1283
    ::= { iptNetflowCpuEntry 3 }
-
 
1284
 
-
 
1285
cpuInPackets OBJECT-TYPE
-
 
1286
    SYNTAX	Counter64
-
 
1287
    UNITS	"packets"
-
 
1288
    MAX-ACCESS	read-only
-
 
1289
    STATUS	current
-
 
1290
    DESCRIPTION
-
 
1291
	"Packets metered for cpuIndex."
-
 
1292
    ::= { iptNetflowCpuEntry 4 }
-
 
1293
 
-
 
1294
cpuInBytes OBJECT-TYPE
-
 
1295
    SYNTAX	Counter64
-
 
1296
    UNITS	"bytes"
-
 
1297
    MAX-ACCESS	read-only
-
 
1298
    STATUS	current
-
 
1299
    DESCRIPTION
-
 
1300
	"Bytes metered on this cpu."
-
 
1301
    ::= { iptNetflowCpuEntry 5 }
-
 
1302
 
-
 
1303
cpuHashMetric OBJECT-TYPE
-
 
1304
    SYNTAX	FixedDiv100
-
 
1305
    MAX-ACCESS	read-only
-
 
1306
    STATUS	current
-
 
1307
    DESCRIPTION
-
 
1308
	"Measure of performance of hash table on this cpu."
-
 
1309
    ::= { iptNetflowCpuEntry 6 }
-
 
1310
 
-
 
1311
cpuDropPackets OBJECT-TYPE
-
 
1312
    SYNTAX	Counter64
-
 
1313
    UNITS	"packets"
-
 
1314
    MAX-ACCESS	read-only
-
 
1315
    STATUS	current
-
 
1316
    DESCRIPTION
-
 
1317
	"Packets dropped by metering process on this cpu."
-
 
1318
    ::= { iptNetflowCpuEntry 7 }
-
 
1319
 
-
 
1320
cpuDropBytes OBJECT-TYPE
-
 
1321
    SYNTAX	Counter64
-
 
1322
    UNITS	"bytes"
-
 
1323
    MAX-ACCESS	read-only
-
 
1324
    STATUS	current
-
 
1325
    DESCRIPTION
-
 
1326
	"Bytes in cpuDropPackets for this cpu."
-
 
1327
    ::= { iptNetflowCpuEntry 8 }
-
 
1328
 
-
 
1329
cpuErrTrunc OBJECT-TYPE
-
 
1330
    SYNTAX	Counter32
-
 
1331
    MAX-ACCESS	read-only
-
 
1332
    STATUS	current
-
 
1333
    DESCRIPTION
-
 
1334
	"Truncated packets dropped for this cpu."
-
 
1335
    ::= { iptNetflowCpuEntry 9 }
-
 
1336
 
-
 
1337
cpuErrFrag OBJECT-TYPE
-
 
1338
    SYNTAX	Counter32
-
 
1339
    MAX-ACCESS	read-only
-
 
1340
    STATUS	current
-
 
1341
    DESCRIPTION
-
 
1342
	"Fragmented packets dropped for this cpu."
-
 
1343
    ::= { iptNetflowCpuEntry 10 }
-
 
1344
 
-
 
1345
cpuErrAlloc OBJECT-TYPE
-
 
1346
    SYNTAX	Counter32
-
 
1347
    MAX-ACCESS	read-only
-
 
1348
    STATUS	current
-
 
1349
    DESCRIPTION
-
 
1350
	"Packets dropped due to memory allocation errors."
-
 
1351
    ::= { iptNetflowCpuEntry 11 }
-
 
1352
 
-
 
1353
cpuErrMaxflows OBJECT-TYPE
-
 
1354
    SYNTAX	Counter32
-
 
1355
    MAX-ACCESS	read-only
-
 
1356
    STATUS	current
-
 
1357
    DESCRIPTION
-
 
1358
	"Packets dropped due to maxflows limit being reached."
-
 
1359
    ::= { iptNetflowCpuEntry 12 }
-
 
1360
 
-
 
1361
-- Per Socket statistics --
-
 
1362
 
-
 
1363
iptNetflowSockTable OBJECT-TYPE
-
 
1364
    SYNTAX	SEQUENCE OF IptNetflowSockEntry
-
 
1365
    MAX-ACCESS	not-accessible
-
 
1366
    STATUS	current
-
 
1367
    DESCRIPTION
-
 
1368
	"Per socket statistics."
-
 
1369
    ::= { iptNetflowStatistics 3 }
-
 
1370
 
-
 
1371
iptNetflowSockEntry OBJECT-TYPE
-
 
1372
    SYNTAX	IptNetflowSockEntry
-
 
1373
    MAX-ACCESS	not-accessible
-
 
1374
    STATUS	current
-
 
1375
    DESCRIPTION
-
 
1376
	"Defines an entry in the iptNetflowSockTable."
-
 
1377
    INDEX	{ sockIndex }
-
 
1378
    ::= { iptNetflowSockTable 1 }
-
 
1379
 
-
 
1380
IptNetflowSockEntry ::=
-
 
1381
    SEQUENCE {
-
 
1382
      sockIndex		INTEGER,
-
 
1383
      sockDestination	DisplayString,
-
 
1384
      sockActive	INTEGER,
-
 
1385
      sockErrConnect	Counter32,
-
 
1386
      sockErrFull	Counter32,
-
 
1387
      sockErrCberr	Counter32,
-
 
1388
      sockErrOther	Counter32,
-
 
1389
      sockSndbuf	Gauge32,
-
 
1390
      sockSndbufFill	Gauge32,
-
 
1391
      sockSndbufPeak	Gauge32
-
 
1392
    }
-
 
1393
 
-
 
1394
sockIndex OBJECT-TYPE
-
 
1395
    SYNTAX	Integer32 (0..4096)
-
 
1396
    MAX-ACCESS	not-accessible
-
 
1397
    STATUS	current
-
 
1398
    DESCRIPTION
-
 
1399
	"Exporting socket index."
-
 
1400
    ::= { iptNetflowSockEntry 1 }
-
 
1401
 
-
 
1402
sockDestination OBJECT-TYPE
-
 
1403
    SYNTAX	DisplayString
-
 
1404
    MAX-ACCESS	read-only
-
 
1405
    STATUS	current
-
 
1406
    DESCRIPTION
-
 
1407
	"Exporting connection destination of this socket."
-
 
1408
    ::= { iptNetflowSockEntry 2 }
-
 
1409
 
-
 
1410
sockActive OBJECT-TYPE
-
 
1411
    SYNTAX	INTEGER {
-
 
1412
	  inactive(0),
-
 
1413
	  active(1)
-
 
1414
    }
-
 
1415
    MAX-ACCESS	read-only
-
 
1416
    STATUS	current
-
 
1417
    DESCRIPTION
-
 
1418
	"Connection state of this socket."
-
 
1419
    ::= { iptNetflowSockEntry 3 }
-
 
1420
 
-
 
1421
sockErrConnect OBJECT-TYPE
-
 
1422
    SYNTAX	Counter32
-
 
1423
    MAX-ACCESS	read-only
-
 
1424
    STATUS	current
-
 
1425
    DESCRIPTION
-
 
1426
	"Connections attempt count. High value usually mean
-
 
1427
	that network is not set up properly, or module is loaded
-
 
1428
	before network is up, in this case it is not dangerous
-
 
1429
	and should be ignored."
-
 
1430
    ::= { iptNetflowSockEntry 4 }
-
 
1431
 
-
 
1432
sockErrFull OBJECT-TYPE
-
 
1433
    SYNTAX	Counter32
-
 
1434
    MAX-ACCESS	read-only
-
 
1435
    STATUS	current
-
 
1436
    DESCRIPTION
-
 
1437
	"Socket full errors on this socket. Usually mean sndbuf
-
 
1438
	value is too small."
-
 
1439
    ::= { iptNetflowSockEntry 5 }
-
 
1440
 
-
 
1441
sockErrCberr OBJECT-TYPE
-
 
1442
    SYNTAX	Counter32
-
 
1443
    MAX-ACCESS	read-only
-
 
1444
    STATUS	current
-
 
1445
    DESCRIPTION
-
 
1446
	"Asynchronous callback errors on this socket. Usually mean
-
 
1447
	that there is 'connection refused' errors on UDP socket
-
 
1448
	reported via ICMP messages."
-
 
1449
    ::= { iptNetflowSockEntry 6 }
-
 
1450
 
-
 
1451
sockErrOther OBJECT-TYPE
-
 
1452
    SYNTAX	Counter32
-
 
1453
    MAX-ACCESS	read-only
-
 
1454
    STATUS	current
-
 
1455
    DESCRIPTION
-
 
1456
	"All other possible errors on this socket."
-
 
1457
    ::= { iptNetflowSockEntry 7 }
-
 
1458
 
-
 
1459
sockSndbuf OBJECT-TYPE
-
 
1460
    SYNTAX	Gauge32
-
 
1461
    UNITS	"bytes"
-
 
1462
    MAX-ACCESS	read-only
-
 
1463
    STATUS	current
-
 
1464
    DESCRIPTION
-
 
1465
	"Sndbuf value for this socket. Higher value allows accommodate
-
 
1466
	(exporting) traffic bursts."
-
 
1467
    ::= { iptNetflowSockEntry 8 }
-
 
1468
 
-
 
1469
sockSndbufFill OBJECT-TYPE
-
 
1470
    SYNTAX	Gauge32
-
 
1471
    UNITS	"bytes"
-
 
1472
    MAX-ACCESS	read-only
-
 
1473
    STATUS	current
-
 
1474
    DESCRIPTION
-
 
1475
	"Amount of data currently in socket buffers. When this value
-
 
1476
	will reach size sndbuf, packet loss will occur."
-
 
1477
    ::= { iptNetflowSockEntry 9 }
-
 
1478
 
-
 
1479
sockSndbufPeak OBJECT-TYPE
-
 
1480
    SYNTAX	Gauge32
-
 
1481
    UNITS	"bytes"
-
 
1482
    MAX-ACCESS	read-only
-
 
1483
    STATUS	current
-
 
1484
    DESCRIPTION
-
 
1485
	"Historical peak amount of data in socket buffers. Useful to
-
 
1486
	evaluate sndbuf size, because sockSndbufFill is transient."
-
 
1487
    ::= { iptNetflowSockEntry 10 }
-
 
1488
 
-
 
1489
-- Conformance Information --
-
 
1490
 
-
 
1491
iptNetflowCompliances	OBJECT IDENTIFIER ::= { iptNetflowConformance 1 }
-
 
1492
iptNetflowGroups	OBJECT IDENTIFIER ::= { iptNetflowConformance 2 }
-
 
1493
 
-
 
1494
iptNetflowCompliance MODULE-COMPLIANCE
-
 
1495
    STATUS current
-
 
1496
    DESCRIPTION "iptNetflowCompliance"
-
 
1497
    MODULE
-
 
1498
    MANDATORY-GROUPS {
-
 
1499
	iptNetflowModuleGroup,
-
 
1500
	iptNetflowSysctlGroup,
-
 
1501
	iptNetflowTotalsGroup,
-
 
1502
	iptNetflowCpuGroup,
-
 
1503
	iptNetflowSockGroup
-
 
1504
    }
-
 
1505
    ::= { iptNetflowCompliances 1 }
-
 
1506
 
-
 
1507
iptNetflowModuleGroup OBJECT-GROUP
-
 
1508
    OBJECTS {
-
 
1509
	name,
-
 
1510
	version,
-
 
1511
	srcversion,
-
 
1512
	loadTime,
-
 
1513
	refcnt
-
 
1514
    }
-
 
1515
    STATUS	current
-
 
1516
    DESCRIPTION "Modinfo."
-
 
1517
    ::= { iptNetflowGroups 1 }
-
 
1518
 
-
 
1519
iptNetflowSysctlGroup OBJECT-GROUP
-
 
1520
    OBJECTS {
-
 
1521
	hashsize,
-
 
1522
	maxflows,
-
 
1523
	protocol,
-
 
1524
	active-timeout,
-
 
1525
	inactive-timeout,
-
 
1526
	sndbuf,
-
 
1527
	destination,
-
 
1528
	aggregation,
-
 
1529
	sampler,
-
 
1530
	natevents,
-
 
1531
	promisc,
-
 
1532
	snmp-rules,
-
 
1533
	scan-min
-
 
1534
    }
-
 
1535
    STATUS	current
-
 
1536
    DESCRIPTION "Read-write objects accessed via sysctl"
-
 
1537
    ::= { iptNetflowGroups 2 }
-
 
1538
 
-
 
1539
iptNetflowTotalsGroup OBJECT-GROUP
-
 
1540
    OBJECTS {
-
 
1541
	inBitRate,
-
 
1542
	inPacketRate,
-
 
1543
	inFlows,
-
 
1544
	inPackets,
-
 
1545
	inBytes,
-
 
1546
	hashMetric,
-
 
1547
	hashMemory,
-
 
1548
	hashFlows,
-
 
1549
	hashPackets,
-
 
1550
	hashBytes,
-
 
1551
	dropPackets,
-
 
1552
	dropBytes,
-
 
1553
	outByteRate,
-
 
1554
	outFlows,
-
 
1555
	outPackets,
-
 
1556
	outBytes,
-
 
1557
	lostFlows,
-
 
1558
	lostPackets,
-
 
1559
	lostBytes,
-
 
1560
	errTotal,
-
 
1561
	sndbufPeak
-
 
1562
    }
-
 
1563
    STATUS	current
-
 
1564
    DESCRIPTION "Statistics totals."
-
 
1565
    ::= { iptNetflowGroups 3 }
-
 
1566
 
-
 
1567
iptNetflowCpuGroup OBJECT-GROUP
-
 
1568
    OBJECTS {
-
 
1569
	cpuIndex,
-
 
1570
	cpuInPacketRate,
-
 
1571
	cpuInFlows,
-
 
1572
	cpuInPackets,
-
 
1573
	cpuInBytes,
-
 
1574
	cpuHashMetric,
-
 
1575
	cpuDropPackets,
-
 
1576
	cpuDropBytes,
-
 
1577
	cpuErrTrunc,
-
 
1578
	cpuErrFrag,
-
 
1579
	cpuErrAlloc,
-
 
1580
	cpuErrMaxflows
-
 
1581
    }
-
 
1582
    STATUS	current
-
 
1583
    DESCRIPTION "Per CPU statistics."
-
 
1584
    ::= { iptNetflowGroups 4 }
-
 
1585
 
-
 
1586
iptNetflowSockGroup OBJECT-GROUP
-
 
1587
    OBJECTS {
-
 
1588
	sockDestination,
-
 
1589
	sockActive,
-
 
1590
	sockErrConnect,
-
 
1591
	sockErrFull,
-
 
1592
	sockErrCberr,
-
 
1593
	sockErrOther,
-
 
1594
	sockSndbuf,
-
 
1595
	sockSndbufFill,
-
 
1596
	sockSndbufPeak
-
 
1597
    }
-
 
1598
    STATUS	current
-
 
1599
    DESCRIPTION "Per socket statistics."
-
 
1600
    ::= { iptNetflowGroups 5 }
-
 
1601
 
-
 
1602
END
-
 
1603
ipt-netflow-2.2/install-dkms.sh0000755000000000000000000000522413213006644015266 0ustar  rootroot#!/bin/bash
-
 
1604
# This script cleanly re-install module into DKMS tree.
-
 
1605
 
-
 
1606
PATH=$PATH:/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/sbin
-
 
1607
 
-
 
1608
if [ "$1" = --uninstall ]; then
-
 
1609
  echo "Uninstalling from DKMS..."
-
 
1610
elif [ "$1" = --install ]; then
-
 
1611
  echo "Installing into DKMS..."
-
 
1612
else
-
 
1613
  exit 1
-
 
1614
fi
-
 
1615
 
-
 
1616
if ! which dkms >/dev/null 2>&1; then
-
 
1617
  echo "! You don't have DKMS accessible in system."
-
 
1618
  exit 1
-
 
1619
fi
-
 
1620
 
-
 
1621
if [ ! -e dkms.conf ]; then
-
 
1622
  echo "! You don't have DKMS configured for this module."
-
 
1623
  exit 1
-
 
1624
fi
-
 
1625
 
-
 
1626
MVERSION=`./version.sh`
-
 
1627
 
-
 
1628
contains() { for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done; return 1; }
-
 
1629
 
-
 
1630
D=() # to be list of installed versions
-
 
1631
OLDIFS="$IFS"
-
 
1632
IFS=$'\n' A=(`dkms status | grep ^ipt-netflow`)
-
 
1633
IFS="$OLDIFS"
-
 
1634
 
-
 
1635
for i in "${A[@]}"; do
-
 
1636
  z=($i)
-
 
1637
  v=${z[1]}
-
 
1638
  v=${v%,}
-
 
1639
  v=${v%:}
-
 
1640
  if ! contains "$v" "${D[@]}"; then
-
 
1641
    D+=($v)
-
 
1642
  fi
-
 
1643
done
-
 
1644
 
-
 
1645
if [ ${#D[@]} -eq 1 ]; then
-
 
1646
  # single version is already installed.
-
 
1647
  if [ $D = "$MVERSION" ]; then
-
 
1648
    echo "! You have same version of module already installed into DKMS."
-
 
1649
  else
-
 
1650
    echo "! You have different version of module installed into DKMS."
-
 
1651
  fi
-
 
1652
  if [ ! -d /usr/src/ipt-netflow-$D ]; then
-
 
1653
    echo "! Can not find DKMS dir for it, that's plain weird."
-
 
1654
  elif [ -e /usr/src/ipt-netflow-$D/.automatic ]; then
-
 
1655
    echo "! That version was automatically installed by this script,"
-
 
1656
    echo "! thus, is safe to remove. No worries."
-
 
1657
  else
-
 
1658
    echo "! That version was manually installed by you."
-
 
1659
  fi
-
 
1660
 
-
 
1661
  nodepmod=
-
 
1662
  if grep -qs no-depmod `which dkms`; then
-
 
1663
    nodepmod=--no-depmod
-
 
1664
  fi
-
 
1665
  echo "! Removing from dkms..."
-
 
1666
  dkms $nodepmod remove ipt-netflow/$D --all
-
 
1667
 
-
 
1668
  if [ -d "/usr/src/ipt-netflow-$D" ]; then
-
 
1669
    echo "! Removing source tree from /usr/src/ipt-netflow-$D"
-
 
1670
    rm -rf "/usr/src/ipt-netflow-$D"
-
 
1671
  fi
-
 
1672
 
-
 
1673
elif [ ${#D[@]} -gt 1 ]; then
-
 
1674
  # multiple versions are installed.
-
 
1675
  echo "! You have multiple versions of module already installed in DKMS."
-
 
1676
  echo "! Please remove them manually to avoid conflict."
-
 
1677
  echo "! 'dkms status' output:"
-
 
1678
  dkms status
-
 
1679
  echo "! Suggested commands to remove them:"
-
 
1680
  for i in ${D[@]}; do
-
 
1681
    echo "!   root# dkms remove ipt-netflow/$i --all"
-
 
1682
  done
-
 
1683
  exit 1
-
 
1684
fi
-
 
1685
 
-
 
1686
if [ "$1" = --uninstall ]; then
-
 
1687
  exit 0
-
 
1688
fi
-
 
1689
 
-
 
1690
if [ "$PWD" = "/usr/src/ipt-netflow-$MVERSION" ]; then
-
 
1691
  echo "! You are already in DKMS dir."
-
 
1692
  dkms add -m ipt-netflow -v $MVERSION
-
 
1693
  exit $?
-
 
1694
fi
-
 
1695
 
-
 
1696
echo "! Installing $MVERSION into DKMS..."
-
 
1697
rm -rf /usr/src/ipt-netflow-$MVERSION
-
 
1698
 
-
 
1699
mkdir -p /usr/src/ipt-netflow-$MVERSION
-
 
1700
cp -p *.[ch] Make* READ* conf* irq* *.sh *.conf /usr/src/ipt-netflow-$MVERSION/
-
 
1701
if [ -d .git ]; then
-
 
1702
  cp -pr .git /usr/src/ipt-netflow-$MVERSION/
-
 
1703
fi
-
 
1704
touch /usr/src/ipt-netflow-$MVERSION/.automatic
-
 
1705
 
-
 
1706
dkms add -m ipt-netflow -v $MVERSION
-
 
1707
exit $?
-
 
1708
 
-
 
1709
ipt-netflow-2.2/ipt_NETFLOW.c0000644000000000000000000046327313213006644014477 0ustar  rootroot/*
-
 
1710
 * This is NetFlow exporting module (NETFLOW target) for linux
-
 
1711
 * (c) 2008-2016 <abc@telekom.ru>
-
 
1712
 *
-
 
1713
 *
-
 
1714
 *   This program is free software: you can redistribute it and/or modify
-
 
1715
 *   it under the terms of the GNU General Public License as published by
-
 
1716
 *   the Free Software Foundation, either version 2 of the License, or
-
 
1717
 *   (at your option) any later version.
-
 
1718
 *
-
 
1719
 *   This program is distributed in the hope that it will be useful,
-
 
1720
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
1721
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
1722
 *   GNU General Public License for more details.
-
 
1723
 *
-
 
1724
 *   You should have received a copy of the GNU General Public License
-
 
1725
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 
1726
 *
-
 
1727
 */
-
 
1728
 
-
 
1729
#include <linux/module.h>
-
 
1730
#include <linux/ctype.h>
-
 
1731
#include <linux/skbuff.h>
-
 
1732
#include <linux/proc_fs.h>
-
 
1733
#include <linux/vmalloc.h>
-
 
1734
#include <linux/seq_file.h>
-
 
1735
#include <linux/random.h>
-
 
1736
#include <linux/in6.h>
-
 
1737
#include <linux/inet.h>
-
 
1738
#include <linux/kernel.h>
-
 
1739
#include <linux/ip.h>
-
 
1740
#include <linux/udp.h>
-
 
1741
#include <linux/icmp.h>
-
 
1742
#include <linux/igmp.h>
-
 
1743
#include <linux/inetdevice.h>
-
 
1744
#include <linux/netdevice.h>
-
 
1745
#include <linux/etherdevice.h>
-
 
1746
#include <linux/ethtool.h>
-
 
1747
#include <linux/hash.h>
-
 
1748
#include <linux/delay.h>
-
 
1749
#include <linux/spinlock_types.h>
-
 
1750
#include <linux/ktime.h>
-
 
1751
#include <linux/if_arp.h>
-
 
1752
#include <net/icmp.h>
-
 
1753
#include <net/ip.h>
-
 
1754
#include <net/ipv6.h>
-
 
1755
#include <net/tcp.h>
-
 
1756
#include <net/route.h>
-
 
1757
#include <net/ip6_fib.h>
-
 
1758
#include <net/addrconf.h>
-
 
1759
#include <net/dst.h>
-
 
1760
#include <linux/netfilter_ipv4/ip_tables.h>
-
 
1761
#ifndef ENABLE_NAT
-
 
1762
# undef CONFIG_NF_NAT_NEEDED
-
 
1763
#endif
-
 
1764
#if defined(ENABLE_VLAN) || defined(ENABLE_PROMISC)
-
 
1765
# include <linux/if_vlan.h>
-
 
1766
#endif
-
 
1767
#ifdef ENABLE_MAC
-
 
1768
# include <linux/if_ether.h>
-
 
1769
# include <linux/etherdevice.h>
-
 
1770
#endif
-
 
1771
#if defined(CONFIG_NF_NAT_NEEDED)
-
 
1772
# include <linux/notifier.h>
-
 
1773
# include <net/netfilter/nf_conntrack.h>
-
 
1774
# include <net/netfilter/nf_conntrack_core.h>
-
 
1775
#endif
-
 
1776
#include <linux/version.h>
-
 
1777
#include <asm/unaligned.h>
-
 
1778
#ifdef HAVE_LLIST
-
 
1779
	/* llist.h is officially defined since linux 3.1,
-
 
1780
	 * but centos6 have it backported on its 2.6.32.el6 */
-
 
1781
# include <linux/llist.h>
-
 
1782
#endif
-
 
1783
#include "compat.h"
-
 
1784
#include "ipt_NETFLOW.h"
-
 
1785
#include "murmur3.h"
-
 
1786
#ifdef CONFIG_BRIDGE_NETFILTER
-
 
1787
# include <linux/netfilter_bridge.h>
-
 
1788
#endif
-
 
1789
#ifdef CONFIG_SYSCTL
-
 
1790
# include <linux/sysctl.h>
-
 
1791
#endif
-
 
1792
#ifndef CONFIG_NF_CONNTRACK_EVENTS
-
 
1793
/* No conntrack events in the kernel imply no natevents. */
-
 
1794
# undef CONFIG_NF_NAT_NEEDED
-
 
1795
#endif
-
 
1796
 
-
 
1797
#define IPT_NETFLOW_VERSION "2.2"   /* Note that if you are using git, you
-
 
1798
				       will see version in other format. */
-
 
1799
#include "version.h"
-
 
1800
#ifdef GITVERSION
-
 
1801
#undef IPT_NETFLOW_VERSION
-
 
1802
#define IPT_NETFLOW_VERSION GITVERSION
-
 
1803
#endif
-
 
1804
 
-
 
1805
MODULE_LICENSE("GPL");
-
 
1806
MODULE_AUTHOR("<abc@telekom.ru>");
-
 
1807
MODULE_DESCRIPTION("iptables NETFLOW target module");
-
 
1808
MODULE_VERSION(IPT_NETFLOW_VERSION);
-
 
1809
MODULE_ALIAS("ip6t_NETFLOW");
-
 
1810
 
-
 
1811
static char version_string[128];
-
 
1812
static int  version_string_size;
-
 
1813
static struct duration start_ts; /* ts of module start (ktime) */
-
 
1814
 
-
 
1815
#define DST_SIZE 256
-
 
1816
static char destination_buf[DST_SIZE] = "127.0.0.1:2055";
-
 
1817
static char *destination = destination_buf;
-
 
1818
module_param(destination, charp, 0444);
-
 
1819
MODULE_PARM_DESC(destination, "export destination ipaddress:port");
-
 
1820
 
-
 
1821
#ifdef ENABLE_SAMPLER
-
 
1822
static char sampler_buf[128] = "";
-
 
1823
static char *sampler = sampler_buf;
-
 
1824
module_param(sampler, charp, 0444);
-
 
1825
MODULE_PARM_DESC(sampler, "flow sampler parameters");
-
 
1826
static atomic_t flow_count = ATOMIC_INIT(0); /* flow counter for deterministic sampler */
-
 
1827
static atomic64_t flows_observed = ATOMIC_INIT(0);
-
 
1828
static atomic64_t flows_selected = ATOMIC_INIT(0);
-
 
1829
#define SAMPLER_INFO_INTERVAL (5*60)
-
 
1830
static unsigned long ts_sampler_last = 0; /* template send time (jiffies) */
-
 
1831
static struct duration sampling_ts; /* ts of sampling start (ktime) */
-
 
1832
#define SAMPLER_SHIFT       14
-
 
1833
#define SAMPLER_INTERVAL_M  ((1 << SAMPLER_SHIFT) - 1)
-
 
1834
enum {
-
 
1835
	SAMPLER_DETERMINISTIC = 1,
-
 
1836
	SAMPLER_RANDOM	      = 2,
-
 
1837
	SAMPLER_HASH	      = 3
-
 
1838
};
-
 
1839
struct sampling {
-
 
1840
	union {
-
 
1841
		u32		v32;
-
 
1842
		struct {
-
 
1843
			u8	mode;
-
 
1844
			u16 	interval;
-
 
1845
		};
-
 
1846
	};
-
 
1847
} samp;
-
 
1848
#endif
-
 
1849
 
-
 
1850
static int inactive_timeout = 15;
-
 
1851
module_param(inactive_timeout, int, 0644);
-
 
1852
MODULE_PARM_DESC(inactive_timeout, "inactive flows timeout in seconds");
-
 
1853
 
-
 
1854
static int active_timeout = 30 * 60;
-
 
1855
module_param(active_timeout, int, 0644);
-
 
1856
MODULE_PARM_DESC(active_timeout, "active flows timeout in seconds");
-
 
1857
 
-
 
1858
static int exportcpu = -1;
-
 
1859
module_param(exportcpu, int, 0644);
-
 
1860
MODULE_PARM_DESC(exportcpu, "lock exporter to this cpu");
-
 
1861
 
-
 
1862
#ifdef ENABLE_PROMISC
-
 
1863
static int promisc = 0;
-
 
1864
module_param(promisc, int, 0444);
-
 
1865
MODULE_PARM_DESC(promisc, "enable promisc hack (0=default, 1)");
-
 
1866
static DEFINE_MUTEX(promisc_lock);
-
 
1867
#endif
-
 
1868
 
-
 
1869
static int debug = 0;
-
 
1870
module_param(debug, int, 0644);
-
 
1871
MODULE_PARM_DESC(debug, "debug verbosity level");
-
 
1872
 
-
 
1873
static int sndbuf;
-
 
1874
module_param(sndbuf, int, 0444);
-
 
1875
MODULE_PARM_DESC(sndbuf, "udp socket SNDBUF size");
-
 
1876
 
-
 
1877
static int protocol = 5;
-
 
1878
module_param(protocol, int, 0444);
-
 
1879
MODULE_PARM_DESC(protocol, "netflow protocol version (5, 9, 10=IPFIX)");
-
 
1880
 
-
 
1881
static unsigned int refresh_rate = 20;
-
 
1882
module_param(refresh_rate, uint, 0644);
-
 
1883
MODULE_PARM_DESC(refresh_rate, "NetFlow v9/IPFIX refresh rate (packets)");
-
 
1884
 
-
 
1885
static unsigned int timeout_rate = 30;
-
 
1886
module_param(timeout_rate, uint, 0644);
-
 
1887
MODULE_PARM_DESC(timeout_rate, "NetFlow v9/IPFIX timeout rate (minutes)");
-
 
1888
 
-
 
1889
static int one = 1;
-
 
1890
static unsigned int scan_min = 1;
-
 
1891
static unsigned int scan_max = HZ / 10;
-
 
1892
module_param(scan_min, uint, 0644);
-
 
1893
MODULE_PARM_DESC(scan_min, "Minimal interval between export scans (jiffies)");
-
 
1894
 
-
 
1895
#ifdef SNMP_RULES
-
 
1896
static char snmp_rules_buf[DST_SIZE] = "";
-
 
1897
static char *snmp_rules = snmp_rules_buf;
-
 
1898
module_param(snmp_rules, charp, 0444);
-
 
1899
MODULE_PARM_DESC(snmp_rules, "SNMP-index conversion rules");
-
 
1900
static unsigned char *snmp_ruleset;
-
 
1901
static DEFINE_SPINLOCK(snmp_lock);
-
 
1902
#endif
-
 
1903
 
-
 
1904
#ifdef CONFIG_NF_NAT_NEEDED
-
 
1905
static int natevents = 0;
-
 
1906
module_param(natevents, int, 0444);
-
 
1907
MODULE_PARM_DESC(natevents, "enable NAT Events");
-
 
1908
#endif
-
 
1909
 
-
 
1910
static int hashsize;
-
 
1911
module_param(hashsize, int, 0444);
-
 
1912
MODULE_PARM_DESC(hashsize, "hash table size");
-
 
1913
 
-
 
1914
static int maxflows = 2000000;
-
 
1915
module_param(maxflows, int, 0644);
-
 
1916
MODULE_PARM_DESC(maxflows, "maximum number of flows");
-
 
1917
static int peakflows = 0;
-
 
1918
static unsigned long peakflows_at; /* jfffies */
-
 
1919
 
-
 
1920
static int engine_id = 0;
-
 
1921
module_param(engine_id, int, 0644);
-
 
1922
MODULE_PARM_DESC(engine_id, "Observation Domain ID");
-
 
1923
 
-
 
1924
#ifdef ENABLE_AGGR
-
 
1925
#define AGGR_SIZE 1024
-
 
1926
static char aggregation_buf[AGGR_SIZE] = "";
-
 
1927
static char *aggregation = aggregation_buf;
-
 
1928
module_param(aggregation, charp, 0400);
-
 
1929
MODULE_PARM_DESC(aggregation, "aggregation ruleset");
-
 
1930
static LIST_HEAD(aggr_n_list);
-
 
1931
static LIST_HEAD(aggr_p_list);
-
 
1932
static DEFINE_RWLOCK(aggr_lock);
-
 
1933
static void aggregation_remove(struct list_head *list);
-
 
1934
static int add_aggregation(char *ptr);
-
 
1935
#endif
-
 
1936
 
-
 
1937
static DEFINE_PER_CPU(struct ipt_netflow_stat, ipt_netflow_stat);
-
 
1938
static LIST_HEAD(usock_list);
-
 
1939
static DEFINE_MUTEX(sock_lock);
-
 
1940
 
-
 
1941
#define LOCK_COUNT (1<<8)
-
 
1942
#define LOCK_COUNT_MASK (LOCK_COUNT-1)
-
 
1943
struct stripe_entry {
-
 
1944
	struct list_head list; /* struct ipt_netflow, list for export */
-
 
1945
	spinlock_t lock; /* this locks both: hash table stripe & list above */
-
 
1946
};
-
 
1947
static struct stripe_entry htable_stripes[LOCK_COUNT];
-
 
1948
static DEFINE_RWLOCK(htable_rwlock); /* global rwlock to protect htable[] resize */
-
 
1949
static struct hlist_head *htable __read_mostly; /* hash table memory */
-
 
1950
static unsigned int htable_size __read_mostly = 0; /* buckets */
-
 
1951
/* How it's organized:
-
 
1952
 *  htable_rwlock locks access to htable[hash], where
-
 
1953
 *  htable[htable_size] is big/resizable hash table, which is striped into
-
 
1954
 *  htable_stripes[LOCK_COUNT] smaller/static hash table, which contains
-
 
1955
 *  .list - list of flows ordered by exportability (usually it's access time)
-
 
1956
 *  .lock - lock to both: that .list and to htable[hash], where
-
 
1957
 *  hash to the htable[] is hash_netflow(&tuple) % htable_size
-
 
1958
 *  hash to the htable_stripes[] is hash & LOCK_COUNT_MASK
-
 
1959
 */
-
 
1960
#ifdef HAVE_LLIST
-
 
1961
static LLIST_HEAD(export_llist); /* flows to purge */
-
 
1962
#endif
-
 
1963
#ifdef CONFIG_NF_NAT_NEEDED
-
 
1964
static LIST_HEAD(nat_list); /* nat events */
-
 
1965
static DEFINE_SPINLOCK(nat_lock);
-
 
1966
static unsigned long nat_events_start = 0;
-
 
1967
static unsigned long nat_events_stop = 0;
-
 
1968
#endif
-
 
1969
static struct kmem_cache *ipt_netflow_cachep __read_mostly; /* ipt_netflow memory */
-
 
1970
static atomic_t ipt_netflow_count = ATOMIC_INIT(0);
-
 
1971
 
-
 
1972
static long long pdu_packets = 0, pdu_traf = 0; /* how much accounted traffic in pdu */
-
 
1973
static unsigned int pdu_count = 0;
-
 
1974
static unsigned int pdu_seq = 0;
-
 
1975
static unsigned int pdu_data_records = 0; /* Data records */
-
 
1976
static unsigned int pdu_flow_records = 0; /* Data records with flows (for stat only) */
-
 
1977
static unsigned int pdu_tpl_records = 0;
-
 
1978
static unsigned long pdu_ts_mod; /* ts(jiffies) of last flow */
-
 
1979
static unsigned int pdu_needs_export = 0;
-
 
1980
static union {
-
 
1981
	__be16 version;
-
 
1982
	struct netflow5_pdu v5;
-
 
1983
	struct netflow9_pdu v9;
-
 
1984
	struct ipfix_pdu ipfix;
-
 
1985
} pdu;
-
 
1986
static __u8 *pdu_data_used;
-
 
1987
static __u8 *pdu_high_wm; /* high watermark */
-
 
1988
static struct flowset_data *pdu_flowset = NULL; /* current data flowset */
-
 
1989
 
-
 
1990
static unsigned long wk_start; /* last start of worker (jiffies) */
-
 
1991
static unsigned long wk_busy;  /* last work busy time (jiffies) */
-
 
1992
static unsigned int wk_count;  /* how much is scanned */
-
 
1993
static unsigned int wk_cpu;
-
 
1994
static unsigned int wk_trylock;
-
 
1995
static unsigned int wk_llist;
-
 
1996
static void (*netflow_export_flow)(struct ipt_netflow *nf);
-
 
1997
static void (*netflow_export_pdu)(void); /* called on timeout */
-
 
1998
static void netflow_switch_version(int ver);
-
 
1999
 
-
 
2000
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-
 
2001
static void netflow_work_fn(void *work);
-
 
2002
static DECLARE_WORK(netflow_work, netflow_work_fn, NULL);
-
 
2003
#else
-
 
2004
static void netflow_work_fn(struct work_struct *work);
-
 
2005
static DECLARE_DELAYED_WORK(netflow_work, netflow_work_fn);
-
 
2006
#endif
-
 
2007
static struct timer_list rate_timer;
-
 
2008
 
-
 
2009
#define TCP_SYN_ACK 0x12
-
 
2010
#define TCP_FIN_RST 0x05
-
 
2011
 
-
 
2012
static long long sec_prate = 0, sec_brate = 0;
-
 
2013
static long long min_prate = 0, min_brate = 0;
-
 
2014
static long long min5_prate = 0, min5_brate = 0;
-
 
2015
#define METRIC_DFL 100
-
 
2016
static int metric = METRIC_DFL,
-
 
2017
	   min15_metric = METRIC_DFL,
-
 
2018
	   min5_metric = METRIC_DFL,
-
 
2019
	   min_metric = METRIC_DFL; /* hash metrics */
-
 
2020
 
-
 
2021
static int set_hashsize(int new_size);
-
 
2022
static void destination_removeall(void);
-
 
2023
static int add_destinations(const char *ptr);
-
 
2024
static int netflow_scan_and_export(int flush);
-
 
2025
enum {
-
 
2026
	DONT_FLUSH, AND_FLUSH
-
 
2027
};
-
 
2028
static int template_ids = FLOWSET_DATA_FIRST;
-
 
2029
static int tpl_count = 0; /* how much active templates */
-
 
2030
#define STAT_INTERVAL	 (1*60)
-
 
2031
#define SYSINFO_INTERVAL (5*60)
-
 
2032
static unsigned long ts_stat_last = 0; /* (jiffies) */
-
 
2033
static unsigned long ts_sysinf_last = 0; /* (jiffies) */
-
 
2034
static unsigned long ts_ifnames_last = 0; /* (jiffies) */
-
 
2035
 
-
 
2036
static inline __be32 bits2mask(int bits) {
-
 
2037
	return (bits? 0xffffffff << (32 - bits) : 0);
-
 
2038
}
-
 
2039
 
-
 
2040
static inline int mask2bits(__be32 mask) {
-
 
2041
	int n;
-
 
2042
 
-
 
2043
	for (n = 0; mask; n++)
-
 
2044
		mask = (mask << 1) & 0xffffffff;
-
 
2045
	return n;
-
 
2046
}
-
 
2047
 
-
 
2048
/* under that lock worker is always stopped and not rescheduled,
-
 
2049
 * and we can call worker sub-functions manually */
-
 
2050
static DEFINE_MUTEX(worker_lock);
-
 
2051
 
-
 
2052
static int worker_delay = HZ / 10;
-
 
2053
static inline void _schedule_scan_worker(const int pdus)
-
 
2054
{
-
 
2055
	int cpu = exportcpu;
-
 
2056
 
-
 
2057
	/* rudimentary congestion avoidance */
-
 
2058
	if (pdus > 0)
-
 
2059
		worker_delay /= pdus;
-
 
2060
	else
-
 
2061
		worker_delay *= 2;
-
 
2062
 
-
 
2063
	if (worker_delay < scan_min)
-
 
2064
		worker_delay = scan_min;
-
 
2065
	else if (worker_delay > scan_max)
-
 
2066
		worker_delay = scan_max;
-
 
2067
 
-
 
2068
	if (cpu >= 0) {
-
 
2069
		if (cpu < NR_CPUS &&
-
 
2070
		    cpu_online(cpu)) {
-
 
2071
			schedule_delayed_work_on(cpu, &netflow_work, worker_delay);
-
 
2072
			return;
-
 
2073
		}
-
 
2074
		printk(KERN_WARNING "ipt_NETFLOW: can't schedule exporter on cpu %d. Disabling cpu lock.\n",
-
 
2075
		    cpu);
-
 
2076
		exportcpu = -1;
-
 
2077
	}
-
 
2078
	schedule_delayed_work(&netflow_work, worker_delay);
-
 
2079
}
-
 
2080
 
-
 
2081
/* This is only called soon after pause_scan_worker. */
-
 
2082
static inline void cont_scan_worker(void)
-
 
2083
{
-
 
2084
	_schedule_scan_worker(0);
-
 
2085
	mutex_unlock(&worker_lock);
-
 
2086
}
-
 
2087
 
-
 
2088
static inline void _unschedule_scan_worker(void)
-
 
2089
{
-
 
2090
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-
 
2091
	cancel_rearming_delayed_work(&netflow_work);
-
 
2092
#else
-
 
2093
	cancel_delayed_work_sync(&netflow_work);
-
 
2094
#endif
-
 
2095
}
-
 
2096
 
-
 
2097
/* This is only used for quick pause (in procctl). */
-
 
2098
static inline void pause_scan_worker(void)
-
 
2099
{
-
 
2100
	mutex_lock(&worker_lock);
-
 
2101
	_unschedule_scan_worker();
-
 
2102
}
-
 
2103
 
-
 
2104
#ifdef ENABLE_SAMPLER
-
 
2105
static inline unsigned char get_sampler_mode(void)
-
 
2106
{
-
 
2107
	return samp.mode;
-
 
2108
}
-
 
2109
static inline unsigned short get_sampler_interval(void)
-
 
2110
{
-
 
2111
	return samp.interval;
-
 
2112
}
-
 
2113
static inline const char *sampler_mode_string(void)
-
 
2114
{
-
 
2115
	const unsigned char mode = get_sampler_mode();
-
 
2116
	return mode == SAMPLER_DETERMINISTIC? "deterministic" :
-
 
2117
		mode == SAMPLER_RANDOM? "random" : "hash";
-
 
2118
}
-
 
2119
/* map SAMPLER_HASH into SAMPLER_RANDOM */
-
 
2120
static unsigned char get_sampler_mode_nf(void)
-
 
2121
{
-
 
2122
	const unsigned char mode = get_sampler_mode();
-
 
2123
	return (mode == SAMPLER_HASH)? SAMPLER_RANDOM : mode;
-
 
2124
}
-
 
2125
static inline unsigned short sampler_nf_v5(void)
-
 
2126
{
-
 
2127
	return (get_sampler_mode_nf() << SAMPLER_SHIFT) | get_sampler_interval();
-
 
2128
}
-
 
2129
#endif
-
 
2130
 
-
 
2131
/* return value is different from usual snprintf */
-
 
2132
static char *snprintf_sockaddr(char *buf, size_t len, const struct sockaddr_storage *ss)
-
 
2133
{
-
 
2134
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
-
 
2135
	if (ss->ss_family == AF_INET) {
-
 
2136
		const struct sockaddr_in *sin = (struct sockaddr_in *)ss;
-
 
2137
 
-
 
2138
		snprintf(buf, len, "%u.%u.%u.%u:%u",
-
 
2139
		    NIPQUAD(sin->sin_addr.s_addr),
-
 
2140
		    ntohs(sin->sin_port));
-
 
2141
	} else if (ss->ss_family == AF_INET6) {
-
 
2142
		const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ss;
-
 
2143
 
-
 
2144
		snprintf(buf, len, "[%x:%x:%x:%x:%x:%x:%x:%x]:%u",
-
 
2145
		    ntohs(sin6->sin6_addr.s6_addr16[0]),
-
 
2146
		    ntohs(sin6->sin6_addr.s6_addr16[1]),
-
 
2147
		    ntohs(sin6->sin6_addr.s6_addr16[2]),
-
 
2148
		    ntohs(sin6->sin6_addr.s6_addr16[3]),
-
 
2149
		    ntohs(sin6->sin6_addr.s6_addr16[4]),
-
 
2150
		    ntohs(sin6->sin6_addr.s6_addr16[5]),
-
 
2151
		    ntohs(sin6->sin6_addr.s6_addr16[6]),
-
 
2152
		    ntohs(sin6->sin6_addr.s6_addr16[7]),
-
 
2153
		    ntohs(sin6->sin6_port));
-
 
2154
	} else
-
 
2155
		snprintf(buf, len, "(invalid address)");
-
 
2156
#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
-
 
2157
	if (ss->ss_family == AF_INET)
-
 
2158
		snprintf(buf, len, "%pI4:%u",
-
 
2159
		    &((const struct sockaddr_in *)ss)->sin_addr,
-
 
2160
		    ntohs(((const struct sockaddr_in *)ss)->sin_port));
-
 
2161
	else if (ss->ss_family == AF_INET6)
-
 
2162
		snprintf(buf, len, "[%pI6c]:%u",
-
 
2163
		    &((const struct sockaddr_in6 *)ss)->sin6_addr,
-
 
2164
		    ntohs(((const struct sockaddr_in6 *)ss)->sin6_port));
-
 
2165
	else
-
 
2166
		snprintf(buf, len, "(invalid address)");
-
 
2167
#else
-
 
2168
	snprintf(buf, len, "%pISpc", ss);
-
 
2169
#endif
-
 
2170
	return buf;
-
 
2171
}
-
 
2172
 
-
 
2173
static char *print_sockaddr(const struct sockaddr_storage *ss)
-
 
2174
{
-
 
2175
	static char buf[64];
-
 
2176
 
-
 
2177
	return snprintf_sockaddr(buf, sizeof(buf), ss);
-
 
2178
}
-
 
2179
 
-
 
2180
static int is_zero_addr(const struct sockaddr_storage *ss)
-
 
2181
{
-
 
2182
	if (ss->ss_family == AF_INET)
-
 
2183
		return ((const struct sockaddr_in *)ss)->sin_addr.s_addr == 0;
-
 
2184
	else if (ss->ss_family == AF_INET6)
-
 
2185
		return  ((const struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[0] == 0 &&
-
 
2186
			((const struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[1] == 0 &&
-
 
2187
			((const struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[2] == 0 &&
-
 
2188
			((const struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[3] == 0;
-
 
2189
	else /* AF_UNSPEC */
-
 
2190
		return 1;
-
 
2191
}
-
 
2192
 
-
 
2193
static char *print_usock_addr(struct ipt_netflow_sock *usock)
-
 
2194
{
-
 
2195
	static char buf[128];
-
 
2196
	size_t len;
-
 
2197
 
-
 
2198
	snprintf(buf, sizeof(buf), "%s", print_sockaddr(&usock->addr));
-
 
2199
 
-
 
2200
	if (!is_zero_addr(&usock->saddr)) {
-
 
2201
		len = strlen(buf);
-
 
2202
		snprintf(buf + len, sizeof(buf) - len, "@%s",
-
 
2203
		    print_sockaddr(&usock->saddr));
-
 
2204
		len = strlen(buf);
-
 
2205
		/* strip zero port */
-
 
2206
		if (len > 2 && buf[len - 1] == '0' && buf[len - 2] == ':')
-
 
2207
			buf[len - 2] = '\0';
-
 
2208
	}
-
 
2209
	if (usock->sdev[0]) {
-
 
2210
		len = strlen(buf);
-
 
2211
		snprintf(buf + len, sizeof(buf) - len, "%%%s", usock->sdev);
-
 
2212
	}
-
 
2213
	return buf;
-
 
2214
}
-
 
2215
 
-
 
2216
#ifdef CONFIG_PROC_FS
-
 
2217
static inline int ABS(int x) { return x >= 0 ? x : -x; }
-
 
2218
#define SAFEDIV(x,y) ((y)? ({ u64 __tmp = x; do_div(__tmp, y); (int)__tmp; }) : 0)
-
 
2219
#define FFLOAT(x, prec) (int)(x) / prec, ABS((int)(x) % prec)
-
 
2220
static int snmp_seq_show(struct seq_file *seq, void *v)
-
 
2221
{
-
 
2222
	int cpu;
-
 
2223
	unsigned int nr_flows = atomic_read(&ipt_netflow_count);
-
 
2224
	struct ipt_netflow_stat t = { 0 };
-
 
2225
	struct ipt_netflow_sock *usock;
-
 
2226
	unsigned int sndbuf_peak = 0;
-
 
2227
	int snum = 0;
-
 
2228
 
-
 
2229
	for_each_present_cpu(cpu) {
-
 
2230
		struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
2231
 
-
 
2232
		t.notfound	+= st->notfound;
-
 
2233
		t.pkt_total	+= st->pkt_total;
-
 
2234
		t.traf_total	+= st->traf_total;
-
 
2235
 
-
 
2236
		t.send_failed	+= st->send_failed;
-
 
2237
		t.sock_cberr	+= st->sock_cberr;
-
 
2238
 
-
 
2239
		t.exported_rate	+= st->exported_rate;
-
 
2240
		t.exported_pkt	+= st->exported_pkt;
-
 
2241
		t.exported_flow	+= st->exported_flow;
-
 
2242
		t.exported_traf	+= st->exported_traf;
-
 
2243
 
-
 
2244
		t.pkt_drop	+= st->pkt_drop;
-
 
2245
		t.traf_drop	+= st->traf_drop;
-
 
2246
		t.pkt_lost	+= st->pkt_lost;
-
 
2247
		t.traf_lost	+= st->traf_lost;
-
 
2248
		t.flow_lost	+= st->flow_lost;
-
 
2249
	}
-
 
2250
 
-
 
2251
 
-
 
2252
	seq_printf(seq,
-
 
2253
	    "inBitRate    %llu\n"
-
 
2254
	    "inPacketRate %llu\n"
-
 
2255
	    "inFlows      %llu\n"
-
 
2256
	    "inPackets    %llu\n"
-
 
2257
	    "inBytes      %llu\n"
-
 
2258
	    "hashMetric   %d.%02d\n"
-
 
2259
	    "hashMemory   %lu\n"
-
 
2260
	    "hashFlows    %u\n"
-
 
2261
	    "hashPackets  %llu\n"
-
 
2262
	    "hashBytes    %llu\n"
-
 
2263
	    "dropPackets  %llu\n"
-
 
2264
	    "dropBytes    %llu\n"
-
 
2265
	    "outByteRate  %u\n"
-
 
2266
	    "outFlows     %llu\n"
-
 
2267
	    "outPackets   %llu\n"
-
 
2268
	    "outBytes     %llu\n"
-
 
2269
	    "lostFlows    %llu\n"
-
 
2270
	    "lostPackets  %llu\n"
-
 
2271
	    "lostBytes    %llu\n"
-
 
2272
	    "errTotal     %u\n",
-
 
2273
	    sec_brate,
-
 
2274
	    sec_prate,
-
 
2275
	    t.notfound,
-
 
2276
	    t.pkt_total,
-
 
2277
	    t.traf_total,
-
 
2278
	    FFLOAT(SAFEDIV(100LL * (t.searched + t.found + t.notfound), (t.found + t.notfound)), 100),
-
 
2279
	    (unsigned long)nr_flows * sizeof(struct ipt_netflow) +
-
 
2280
		   (unsigned long)htable_size * sizeof(struct hlist_head),
-
 
2281
	    nr_flows,
-
 
2282
	    t.pkt_total - t.pkt_out,
-
 
2283
	    t.traf_total - t.traf_out,
-
 
2284
	    t.pkt_drop,
-
 
2285
	    t.traf_drop,
-
 
2286
	    t.exported_rate,
-
 
2287
	    t.exported_flow,
-
 
2288
	    t.exported_pkt,
-
 
2289
	    t.exported_traf,
-
 
2290
	    t.flow_lost,
-
 
2291
	    t.pkt_lost,
-
 
2292
	    t.traf_lost,
-
 
2293
	    t.send_failed + t.sock_cberr);
-
 
2294
 
-
 
2295
	for_each_present_cpu(cpu) {
-
 
2296
		struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
2297
 
-
 
2298
		seq_printf(seq,
-
 
2299
		    "cpu%u %u %llu %llu %llu %d.%02d %llu %llu %u %u %u %u\n",
-
 
2300
		    cpu,
-
 
2301
		    st->pkt_total_rate,
-
 
2302
		    st->notfound,
-
 
2303
		    st->pkt_total,
-
 
2304
		    st->traf_total,
-
 
2305
		    FFLOAT(st->metric, 100),
-
 
2306
		    st->pkt_drop,
-
 
2307
		    st->traf_drop,
-
 
2308
		    st->truncated,
-
 
2309
		    st->frags,
-
 
2310
		    st->alloc_err,
-
 
2311
		    st->maxflows_err);
-
 
2312
	}
-
 
2313
 
-
 
2314
	mutex_lock(&sock_lock);
-
 
2315
	list_for_each_entry(usock, &usock_list, list) {
-
 
2316
		int wmem_peak = atomic_read(&usock->wmem_peak);
-
 
2317
 
-
 
2318
		if (sndbuf_peak < wmem_peak)
-
 
2319
			sndbuf_peak = wmem_peak;
-
 
2320
		seq_printf(seq, "sock%d %s %d %u %u %u %u",
-
 
2321
		    snum,
-
 
2322
		    print_usock_addr(usock),
-
 
2323
		    !!usock->sock,
-
 
2324
		    usock->err_connect,
-
 
2325
		    usock->err_full,
-
 
2326
		    usock->err_cberr,
-
 
2327
		    usock->err_other);
-
 
2328
		if (usock->sock) {
-
 
2329
			struct sock *sk = usock->sock->sk;
-
 
2330
 
-
 
2331
			seq_printf(seq, " %u %u %u\n",
-
 
2332
			    sk->sk_sndbuf,
-
 
2333
			    compat_refcount_read(&sk->sk_wmem_alloc),
-
 
2334
			    wmem_peak);
-
 
2335
		} else
-
 
2336
			seq_printf(seq, " 0 0 %u\n", wmem_peak);
-
 
2337
 
-
 
2338
		snum++;
-
 
2339
	}
-
 
2340
	mutex_unlock(&sock_lock);
-
 
2341
	seq_printf(seq, "sndbufPeak   %u\n", sndbuf_peak);
-
 
2342
 
-
 
2343
	return 0;
-
 
2344
}
-
 
2345
 
-
 
2346
/* procfs statistics /proc/net/stat/ipt_netflow */
-
 
2347
static int nf_seq_show(struct seq_file *seq, void *v)
-
 
2348
{
-
 
2349
	unsigned int nr_flows = atomic_read(&ipt_netflow_count);
-
 
2350
	int cpu;
-
 
2351
	struct ipt_netflow_stat t = { 0 };
-
 
2352
	struct ipt_netflow_sock *usock;
-
 
2353
#ifdef ENABLE_AGGR
-
 
2354
	struct netflow_aggr_n *aggr_n;
-
 
2355
	struct netflow_aggr_p *aggr_p;
-
 
2356
#endif
-
 
2357
	int snum = 0;
-
 
2358
	int peak = (jiffies - peakflows_at) / HZ;
-
 
2359
 
-
 
2360
	seq_printf(seq, "ipt_NETFLOW " IPT_NETFLOW_VERSION ", srcversion %s;"
-
 
2361
#ifdef ENABLE_AGGR
-
 
2362
	    " aggr"
-
 
2363
#endif
-
 
2364
#ifdef ENABLE_DIRECTION
-
 
2365
	    " dir"
-
 
2366
#endif
-
 
2367
#ifdef HAVE_LLIST
-
 
2368
	    " llist"
-
 
2369
#endif
-
 
2370
#ifdef ENABLE_MAC
-
 
2371
	    " mac"
-
 
2372
#endif
-
 
2373
#ifdef CONFIG_NF_NAT_NEEDED
-
 
2374
	    " nel"
-
 
2375
#endif
-
 
2376
#ifdef ENABLE_PROMISC
-
 
2377
	    " promisc"
-
 
2378
# ifdef PROMISC_MPLS
-
 
2379
	    "+mpls"
-
 
2380
# endif
-
 
2381
#endif
-
 
2382
#ifdef ENABLE_SAMPLER
-
 
2383
	    " samp"
-
 
2384
# ifdef SAMPLING_HASH
-
 
2385
	    "-h"
-
 
2386
# endif
-
 
2387
#endif
-
 
2388
#ifdef SNMP_RULES
-
 
2389
	    " snmp"
-
 
2390
#endif
-
 
2391
#ifdef ENABLE_VLAN
-
 
2392
	    " vlan"
-
 
2393
#endif
-
 
2394
	    "\n",
-
 
2395
	    THIS_MODULE->srcversion);
-
 
2396
 
-
 
2397
	seq_printf(seq, "Protocol version %d", protocol);
-
 
2398
	if (protocol == 10)
-
 
2399
		seq_printf(seq, " (ipfix)");
-
 
2400
	else
-
 
2401
		seq_printf(seq, " (netflow)");
-
 
2402
	if (protocol >= 9)
-
 
2403
		seq_printf(seq, ", refresh-rate %u, timeout-rate %u, (templates %d, active %d).\n",
-
 
2404
		    refresh_rate, timeout_rate, template_ids - FLOWSET_DATA_FIRST, tpl_count);
-
 
2405
	else
-
 
2406
		seq_printf(seq, "\n");
-
 
2407
 
-
 
2408
	seq_printf(seq, "Timeouts: active %ds, inactive %ds. Maxflows %u\n",
-
 
2409
	    active_timeout,
-
 
2410
	    inactive_timeout,
-
 
2411
	    maxflows);
-
 
2412
 
-
 
2413
	for_each_present_cpu(cpu) {
-
 
2414
		struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
2415
 
-
 
2416
		t.searched	+= st->searched;
-
 
2417
		t.found		+= st->found;
-
 
2418
		t.notfound	+= st->notfound;
-
 
2419
		t.pkt_total	+= st->pkt_total;
-
 
2420
		t.traf_total	+= st->traf_total;
-
 
2421
#ifdef ENABLE_PROMISC
-
 
2422
		t.pkt_promisc	+= st->pkt_promisc;
-
 
2423
		t.pkt_promisc_drop += st->pkt_promisc_drop;
-
 
2424
#endif
-
 
2425
		t.truncated	+= st->truncated;
-
 
2426
		t.frags		+= st->frags;
-
 
2427
		t.maxflows_err	+= st->maxflows_err;
-
 
2428
		t.alloc_err	+= st->alloc_err;
-
 
2429
		t.send_failed	+= st->send_failed;
-
 
2430
		t.sock_cberr	+= st->sock_cberr;
-
 
2431
 
-
 
2432
		t.exported_rate	+= st->exported_rate;
-
 
2433
		t.exported_pkt	+= st->exported_pkt;
-
 
2434
		t.exported_flow	+= st->exported_flow;
-
 
2435
		t.exported_traf	+= st->exported_traf;
-
 
2436
 
-
 
2437
		t.pkt_total_rate += st->pkt_total_rate;
-
 
2438
		t.pkt_drop	+= st->pkt_drop;
-
 
2439
		t.traf_drop	+= st->traf_drop;
-
 
2440
		t.pkt_lost	+= st->pkt_lost;
-
 
2441
		t.traf_lost	+= st->traf_lost;
-
 
2442
		t.flow_lost	+= st->flow_lost;
-
 
2443
		t.pkt_out	+= st->pkt_out;
-
 
2444
		t.traf_out	+= st->traf_out;
-
 
2445
#ifdef ENABLE_SAMPLER
-
 
2446
		t.pkts_observed	+= st->pkts_observed;
-
 
2447
		t.pkts_selected	+= st->pkts_selected;
-
 
2448
#endif
-
 
2449
	}
-
 
2450
 
-
 
2451
#ifdef ENABLE_SAMPLER
-
 
2452
	if (get_sampler_mode()) {
-
 
2453
		seq_printf(seq, "Flow sampling mode %s one-out-of %u.",
-
 
2454
		    sampler_mode_string(),
-
 
2455
		    get_sampler_interval());
-
 
2456
		if (get_sampler_mode() != SAMPLER_HASH)
-
 
2457
			seq_printf(seq, " Flows selected %lu, discarded %lu.",
-
 
2458
			    atomic64_read(&flows_selected),
-
 
2459
			    atomic64_read(&flows_observed) - atomic64_read(&flows_selected));
-
 
2460
		else
-
 
2461
			seq_printf(seq, " Flows selected %lu.", atomic64_read(&flows_selected));
-
 
2462
		seq_printf(seq, " Pkts selected %llu, discarded %llu.\n",
-
 
2463
		    t.pkts_selected,
-
 
2464
		    t.pkts_observed - t.pkts_selected);
-
 
2465
	} else
-
 
2466
		seq_printf(seq, "Flow sampling is disabled.\n");
-
 
2467
#endif
-
 
2468
 
-
 
2469
#ifdef ENABLE_PROMISC
-
 
2470
	seq_printf(seq, "Promisc hack is %s (observed %llu packets, discarded %llu).\n",
-
 
2471
	    promisc? "enabled" : "disabled",
-
 
2472
	    t.pkt_promisc,
-
 
2473
	    t.pkt_promisc_drop);
-
 
2474
#endif
-
 
2475
 
-
 
2476
#ifdef CONFIG_NF_NAT_NEEDED
-
 
2477
	seq_printf(seq, "Natevents %s, count start %lu, stop %lu.\n", natevents? "enabled" : "disabled",
-
 
2478
	    nat_events_start, nat_events_stop);
-
 
2479
#endif
-
 
2480
 
-
 
2481
	seq_printf(seq, "Flows: active %u (peak %u reached %ud%uh%um ago), mem %uK, worker delay %d/%d"
-
 
2482
	    " [%d..%d] (%u ms, %u us, %u:%u"
-
 
2483
#ifdef HAVE_LLIST
-
 
2484
	    " %u"
-
 
2485
#endif
-
 
2486
	    " [cpu%u]).\n",
-
 
2487
		   nr_flows,
-
 
2488
		   peakflows,
-
 
2489
		   peak / (60 * 60 * 24), (peak / (60 * 60)) % 24, (peak / 60) % 60,
-
 
2490
		   (unsigned int)(((unsigned long)nr_flows * sizeof(struct ipt_netflow) +
-
 
2491
				   (unsigned long)htable_size * sizeof(struct hlist_head)) >> 10),
-
 
2492
		   worker_delay, HZ,
-
 
2493
		   scan_min, scan_max,
-
 
2494
		   jiffies_to_msecs(jiffies - wk_start),
-
 
2495
		   jiffies_to_usecs(wk_busy),
-
 
2496
		   wk_count,
-
 
2497
		   wk_trylock,
-
 
2498
#ifdef HAVE_LLIST
-
 
2499
		   wk_llist,
-
 
2500
#endif
-
 
2501
		   wk_cpu);
-
 
2502
 
-
 
2503
	seq_printf(seq, "Hash: size %u (mem %uK), metric %d.%02d [%d.%02d, %d.%02d, %d.%02d]."
-
 
2504
	    " InHash: %llu pkt, %llu K, InPDU %llu, %llu.\n",
-
 
2505
	    htable_size,
-
 
2506
	    (unsigned int)((htable_size * sizeof(struct hlist_head)) >> 10),
-
 
2507
	    FFLOAT(metric, 100),
-
 
2508
	    FFLOAT(min_metric, 100),
-
 
2509
	    FFLOAT(min5_metric, 100),
-
 
2510
	    FFLOAT(min15_metric, 100),
-
 
2511
	    t.pkt_total - t.pkt_out,
-
 
2512
	    (t.traf_total - t.traf_out) >> 10,
-
 
2513
	    pdu_packets,
-
 
2514
	    pdu_traf);
-
 
2515
 
-
 
2516
	seq_printf(seq, "Rate: %llu bits/sec, %llu packets/sec;"
-
 
2517
	    " Avg 1 min: %llu bps, %llu pps; 5 min: %llu bps, %llu pps\n",
-
 
2518
	    sec_brate, sec_prate, min_brate, min_prate, min5_brate, min5_prate);
-
 
2519
 
-
 
2520
	seq_printf(seq, "cpu#     pps; <search found new [metric], trunc frag alloc maxflows>,"
-
 
2521
	    " traffic: <pkt, bytes>, drop: <pkt, bytes>\n");
-
 
2522
 
-
 
2523
	seq_printf(seq, "Total %6u; %6llu %6llu %6llu [%d.%02d], %4u %4u %4u %4u,"
-
 
2524
	    " traffic: %llu, %llu MB, drop: %llu, %llu K\n",
-
 
2525
	    t.pkt_total_rate,
-
 
2526
	    t.searched,
-
 
2527
	    t.found,
-
 
2528
	    t.notfound,
-
 
2529
	    FFLOAT(SAFEDIV(100LL * (t.searched + t.found + t.notfound), (t.found + t.notfound)), 100),
-
 
2530
	    t.truncated, t.frags, t.alloc_err, t.maxflows_err,
-
 
2531
	    t.pkt_total, t.traf_total >> 20,
-
 
2532
	    t.pkt_drop, t.traf_drop >> 10);
-
 
2533
 
-
 
2534
	if (num_present_cpus() > 1) {
-
 
2535
		for_each_present_cpu(cpu) {
-
 
2536
			struct ipt_netflow_stat *st;
-
 
2537
 
-
 
2538
			st = &per_cpu(ipt_netflow_stat, cpu);
-
 
2539
			seq_printf(seq, "cpu%-2u %6u; %6llu %6llu %6llu [%d.%02d], %4u %4u %4u %4u,"
-
 
2540
			    " traffic: %llu, %llu MB, drop: %llu, %llu K\n",
-
 
2541
			    cpu,
-
 
2542
			    st->pkt_total_rate,
-
 
2543
			    st->searched,
-
 
2544
			    st->found,
-
 
2545
			    st->notfound,
-
 
2546
			    FFLOAT(st->metric, 100),
-
 
2547
			    st->truncated, st->frags, st->alloc_err, st->maxflows_err,
-
 
2548
			    st->pkt_total, st->traf_total >> 20,
-
 
2549
			    st->pkt_drop, st->traf_drop >> 10);
-
 
2550
		}
-
 
2551
	}
-
 
2552
 
-
 
2553
	seq_printf(seq, "Export: Rate %u bytes/s; Total %llu pkts, %llu MB, %llu flows;"
-
 
2554
	    " Errors %u pkts; Traffic lost %llu pkts, %llu Kbytes, %llu flows.\n",
-
 
2555
	    t.exported_rate,
-
 
2556
	    t.exported_pkt,
-
 
2557
	    t.exported_traf >> 20,
-
 
2558
	    t.exported_flow,
-
 
2559
	    t.send_failed,
-
 
2560
	    t.pkt_lost,
-
 
2561
	    t.traf_lost >> 10,
-
 
2562
	    t.flow_lost);
-
 
2563
 
-
 
2564
	mutex_lock(&sock_lock);
-
 
2565
	list_for_each_entry(usock, &usock_list, list) {
-
 
2566
		seq_printf(seq, "sock%d: %s",
-
 
2567
		    snum,
-
 
2568
		    print_usock_addr(usock));
-
 
2569
		if (usock->sock) {
-
 
2570
			struct sock *sk = usock->sock->sk;
-
 
2571
 
-
 
2572
			seq_printf(seq, ", sndbuf %u, filled %u, peak %u;"
-
 
2573
			    " err: sndbuf reached %u, connect %u, cberr %u, other %u\n",
-
 
2574
			    sk->sk_sndbuf,
-
 
2575
			    compat_refcount_read(&sk->sk_wmem_alloc),
-
 
2576
			    atomic_read(&usock->wmem_peak),
-
 
2577
			    usock->err_full,
-
 
2578
			    usock->err_connect,
-
 
2579
			    usock->err_cberr,
-
 
2580
			    usock->err_other);
-
 
2581
		} else
-
 
2582
			seq_printf(seq, " unconnected (%u attempts).\n",
-
 
2583
			    usock->err_connect);
-
 
2584
		snum++;
-
 
2585
	}
-
 
2586
	mutex_unlock(&sock_lock);
-
 
2587
 
-
 
2588
#ifdef ENABLE_AGGR
-
 
2589
	read_lock_bh(&aggr_lock);
-
 
2590
	snum = 0;
-
 
2591
	list_for_each_entry(aggr_n, &aggr_n_list, list) {
-
 
2592
		seq_printf(seq, "aggr#%d net: match %u.%u.%u.%u/%d strip %d (usage %u)\n",
-
 
2593
		    snum,
-
 
2594
		    HIPQUAD(aggr_n->addr),
-
 
2595
		    mask2bits(aggr_n->mask),
-
 
2596
		    mask2bits(aggr_n->aggr_mask),
-
 
2597
		    atomic_read(&aggr_n->usage));
-
 
2598
		snum++;
-
 
2599
	}
-
 
2600
	snum = 0;
-
 
2601
	list_for_each_entry(aggr_p, &aggr_p_list, list) {
-
 
2602
		seq_printf(seq, "aggr#%d port: ports %u-%u replace %u (usage %u)\n",
-
 
2603
		    snum,
-
 
2604
		    aggr_p->port1,
-
 
2605
		    aggr_p->port2,
-
 
2606
		    aggr_p->aggr_port,
-
 
2607
		    atomic_read(&aggr_p->usage));
-
 
2608
		snum++;
-
 
2609
	}
-
 
2610
	read_unlock_bh(&aggr_lock);
-
 
2611
#endif
-
 
2612
#ifdef SNMP_RULES
-
 
2613
	{
-
 
2614
		const unsigned char *rules;
-
 
2615
 
-
 
2616
		snum = 0;
-
 
2617
		rcu_read_lock();
-
 
2618
		rules = rcu_dereference(snmp_ruleset);
-
 
2619
		if (rules)
-
 
2620
		while (*rules) {
-
 
2621
			const unsigned int len = *rules++;
-
 
2622
 
-
 
2623
			seq_printf(seq, "SNMP-rule#%d: prefix '%.*s' map to %d\n",
-
 
2624
				snum, len, rules, (rules[len] << 8) + rules[len + 1]);
-
 
2625
			rules += len + 2;
-
 
2626
			++snum;
-
 
2627
		}
-
 
2628
		rcu_read_unlock();
-
 
2629
	}
-
 
2630
#endif
-
 
2631
	return 0;
-
 
2632
}
-
 
2633
 
-
 
2634
static int nf_seq_open(struct inode *inode, struct file *file)
-
 
2635
{
-
 
2636
	return single_open(file, nf_seq_show, NULL);
-
 
2637
}
-
 
2638
 
-
 
2639
static int snmp_seq_open(struct inode *inode, struct file *file)
-
 
2640
{
-
 
2641
	return single_open(file, snmp_seq_show, NULL);
-
 
2642
}
-
 
2643
 
-
 
2644
static struct file_operations nf_seq_fops = {
-
 
2645
	.owner	 = THIS_MODULE,
-
 
2646
	.open	 = nf_seq_open,
-
 
2647
	.read	 = seq_read,
-
 
2648
	.llseek	 = seq_lseek,
-
 
2649
	.release = single_release,
-
 
2650
};
-
 
2651
 
-
 
2652
static struct file_operations snmp_seq_fops = {
-
 
2653
	.owner	 = THIS_MODULE,
-
 
2654
	.open	 = snmp_seq_open,
-
 
2655
	.read	 = seq_read,
-
 
2656
	.llseek	 = seq_lseek,
-
 
2657
	.release = single_release,
-
 
2658
};
-
 
2659
 
-
 
2660
static inline int inactive_needs_export(const struct ipt_netflow *nf, const long i_timeout,
-
 
2661
    const unsigned long jiff);
-
 
2662
static inline int active_needs_export(const struct ipt_netflow *nf, const long a_timeout,
-
 
2663
    const unsigned long jiff);
-
 
2664
static inline u_int32_t hash_netflow(const struct ipt_netflow_tuple *tuple);
-
 
2665
 
-
 
2666
struct flows_dump_private {
-
 
2667
	int pcache;	/* pos */
-
 
2668
	void *vcache;	/* corresponding pointer for pos */
-
 
2669
	int stripe;	/* current stripe */
-
 
2670
	struct list_head list; /* copy of stripe */
-
 
2671
	int alloc_errors;
-
 
2672
};
-
 
2673
 
-
 
2674
/* deallocate copied stripe */
-
 
2675
static void nf_free_stripe(struct list_head *list)
-
 
2676
{
-
 
2677
	struct ipt_netflow *cf, *tmp;
-
 
2678
 
-
 
2679
	list_for_each_entry_safe(cf, tmp, list, flows_list) {
-
 
2680
		kmem_cache_free(ipt_netflow_cachep, cf);
-
 
2681
	}
-
 
2682
	INIT_LIST_HEAD(list);
-
 
2683
}
-
 
2684
 
-
 
2685
/* quickly clone stripe into flows_dump_private then it can be walked slowly
-
 
2686
 * and lockless */
-
 
2687
static void __nf_copy_stripe(struct flows_dump_private *st, const struct list_head *list)
-
 
2688
{
-
 
2689
	const struct ipt_netflow *nf;
-
 
2690
	struct ipt_netflow *cf;
-
 
2691
 
-
 
2692
	nf_free_stripe(&st->list);
-
 
2693
	list_for_each_entry(nf, list, flows_list) {
-
 
2694
		cf = kmem_cache_alloc(ipt_netflow_cachep, GFP_ATOMIC);
-
 
2695
		if (!cf) {
-
 
2696
			st->alloc_errors++;
-
 
2697
			continue;
-
 
2698
		}
-
 
2699
		memcpy(cf, nf, sizeof(*cf));
-
 
2700
		list_add(&cf->flows_list, &st->list);
-
 
2701
	}
-
 
2702
}
-
 
2703
 
-
 
2704
/* nstripe is desired stripe, in st->stripe will be recorded actual stripe used
-
 
2705
 * (with empty stripes skipped), -1 is there is no valid stripes anymore,
-
 
2706
 * return first element in stripe list or NULL */
-
 
2707
static struct list_head *nf_get_stripe(struct flows_dump_private *st, int nstripe)
-
 
2708
{
-
 
2709
	read_lock_bh(&htable_rwlock);
-
 
2710
	for (; nstripe < LOCK_COUNT; nstripe++) {
-
 
2711
		struct stripe_entry *stripe = &htable_stripes[nstripe];
-
 
2712
 
-
 
2713
		spin_lock(&stripe->lock);
-
 
2714
		if (!list_empty(&stripe->list)) {
-
 
2715
			st->stripe = nstripe;
-
 
2716
			__nf_copy_stripe(st, &stripe->list);
-
 
2717
			spin_unlock(&stripe->lock);
-
 
2718
			read_unlock_bh(&htable_rwlock);
-
 
2719
			return st->list.next;
-
 
2720
		}
-
 
2721
		spin_unlock(&stripe->lock);
-
 
2722
	}
-
 
2723
	read_unlock_bh(&htable_rwlock);
-
 
2724
	st->stripe = -1;
-
 
2725
	return NULL;
-
 
2726
}
-
 
2727
 
-
 
2728
/* simply next element in flows list or NULL */
-
 
2729
static struct list_head *nf_get_next(struct flows_dump_private *st, struct list_head *head)
-
 
2730
{
-
 
2731
	if (head == SEQ_START_TOKEN)
-
 
2732
		return nf_get_stripe(st, 0);
-
 
2733
	if (st->stripe < 0)
-
 
2734
		return NULL;
-
 
2735
	/* next element */
-
 
2736
	if (!list_is_last(head, &st->list))
-
 
2737
		return head->next;
-
 
2738
	/* next bucket */
-
 
2739
	return nf_get_stripe(st, st->stripe + 1);
-
 
2740
}
-
 
2741
 
-
 
2742
/* seq_file could arbitrarily start/stop iteration as it feels need,
-
 
2743
 * so, I try to cache things to (significantly) speed it up. */
-
 
2744
static void *flows_dump_seq_start(struct seq_file *seq, loff_t *pos)
-
 
2745
{
-
 
2746
	struct flows_dump_private *st = seq->private;
-
 
2747
	int ppos = *pos;
-
 
2748
	struct list_head *lh;
-
 
2749
 
-
 
2750
	if (!ppos) {
-
 
2751
		/* first */
-
 
2752
		st->pcache = 0;
-
 
2753
		st->vcache = SEQ_START_TOKEN;
-
 
2754
		return st->vcache;
-
 
2755
	}
-
 
2756
	if (ppos >= st->pcache) {
-
 
2757
		/* can iterate forward */
-
 
2758
		ppos -= st->pcache;
-
 
2759
		lh = st->vcache;
-
 
2760
	} else /* can't, start from 0 */
-
 
2761
		lh = SEQ_START_TOKEN;
-
 
2762
	/* iterate forward */
-
 
2763
	while (ppos--)
-
 
2764
		lh = nf_get_next(st, lh);
-
 
2765
	st->pcache = *pos;
-
 
2766
	st->vcache = lh;
-
 
2767
	return st->vcache;
-
 
2768
}
-
 
2769
 
-
 
2770
static void *flows_dump_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-
 
2771
{
-
 
2772
	struct flows_dump_private *st = seq->private;
-
 
2773
 
-
 
2774
	st->pcache = ++*pos;
-
 
2775
	st->vcache = nf_get_next(st, (struct list_head *)v);
-
 
2776
	return st->vcache;
-
 
2777
}
-
 
2778
 
-
 
2779
static void flows_dump_seq_stop(struct seq_file *seq, void *v)
-
 
2780
{
-
 
2781
}
-
 
2782
 
-
 
2783
/* To view this: cat /sys/kernel/debug/netflow_dump */
-
 
2784
static int flows_dump_seq_show(struct seq_file *seq, void *v)
-
 
2785
{
-
 
2786
	struct flows_dump_private *st = seq->private;
-
 
2787
	const long i_timeout = inactive_timeout * HZ;
-
 
2788
	const long a_timeout = active_timeout * HZ;
-
 
2789
	const struct ipt_netflow *nf;
-
 
2790
 
-
 
2791
	if (v == SEQ_START_TOKEN) {
-
 
2792
		seq_printf(seq, "# hash a dev:i,o"
-
 
2793
#ifdef SNMP_RULES
-
 
2794
		    " snmp:i,o"
-
 
2795
#endif
-
 
2796
#ifdef ENABLE_MAC
-
 
2797
		    " mac:src,dst"
-
 
2798
#endif
-
 
2799
#ifdef ENABLE_VLAN
-
 
2800
		    " vlan"
-
 
2801
#endif
-
 
2802
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
2803
		    " type"
-
 
2804
#endif
-
 
2805
		    " proto src:ip,port dst:ip,port nexthop"
-
 
2806
		    " tos,tcpflags,options,tcpoptions"
-
 
2807
		    " packets bytes ts:first,last\n");
-
 
2808
		return 0;
-
 
2809
	}
-
 
2810
 
-
 
2811
	nf = list_entry(v, struct ipt_netflow, flows_list);
-
 
2812
	seq_printf(seq, "%d %04x %x",
-
 
2813
	    st->pcache,
-
 
2814
	    hash_netflow(&nf->tuple),
-
 
2815
	    (!!inactive_needs_export(nf, i_timeout, jiffies)) | 
-
 
2816
	    (active_needs_export(nf, a_timeout, jiffies) << 1));
-
 
2817
	seq_printf(seq, " %hd,%hd",
-
 
2818
	    nf->tuple.i_ifc,
-
 
2819
	    nf->o_ifc);
-
 
2820
#ifdef SNMP_RULES
-
 
2821
	seq_printf(seq, " %hd,%hd",
-
 
2822
	    nf->i_ifcr,
-
 
2823
	    nf->o_ifcr);
-
 
2824
#endif
-
 
2825
#ifdef ENABLE_MAC
-
 
2826
	seq_printf(seq, " %pM,%pM", &nf->tuple.h_src, &nf->tuple.h_dst);
-
 
2827
#endif
-
 
2828
#ifdef ENABLE_VLAN
-
 
2829
	if (nf->tuple.tag[0]) {
-
 
2830
		seq_printf(seq, " %d", ntohs(nf->tuple.tag[0]));
-
 
2831
		if (nf->tuple.tag[1])
-
 
2832
			seq_printf(seq, ",%d", ntohs(nf->tuple.tag[1]));
-
 
2833
	}
-
 
2834
#endif
-
 
2835
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
2836
	seq_printf(seq, " %04x", ntohs(nf->ethernetType));
-
 
2837
#endif
-
 
2838
	seq_printf(seq, " %u ",
-
 
2839
	    nf->tuple.protocol);
-
 
2840
	if (nf->tuple.l3proto == AF_INET) {
-
 
2841
		seq_printf(seq, "%pI4n,%u %pI4n,%u %pI4n",
-
 
2842
		    &nf->tuple.src,
-
 
2843
		    ntohs(nf->tuple.s_port),
-
 
2844
		    &nf->tuple.dst,
-
 
2845
		    ntohs(nf->tuple.d_port),
-
 
2846
		    &nf->nh);
-
 
2847
	} else if (nf->tuple.l3proto == AF_INET6) {
-
 
2848
		seq_printf(seq, "%pI6c,%u %pI6c,%u %pI6c",
-
 
2849
		    &nf->tuple.src,
-
 
2850
		    ntohs(nf->tuple.s_port),
-
 
2851
		    &nf->tuple.dst,
-
 
2852
		    ntohs(nf->tuple.d_port),
-
 
2853
		    &nf->nh);
-
 
2854
	} else {
-
 
2855
		seq_puts(seq, "?,? ?,? ?");
-
 
2856
	}
-
 
2857
	seq_printf(seq, " %x,%x,%x,%x",
-
 
2858
	    nf->tuple.tos,
-
 
2859
	    nf->tcp_flags,
-
 
2860
	    nf->options,
-
 
2861
	    nf->tcpoptions);
-
 
2862
	seq_printf(seq, " %u %u %lu,%lu\n",
-
 
2863
	    nf->nr_packets,
-
 
2864
	    nf->nr_bytes,
-
 
2865
	    jiffies - nf->nf_ts_first,
-
 
2866
	    jiffies - nf->nf_ts_last);
-
 
2867
 
-
 
2868
	return 0;
-
 
2869
}
-
 
2870
 
-
 
2871
static struct seq_operations flows_dump_seq_ops = {
-
 
2872
	.start	= flows_dump_seq_start,
-
 
2873
	.show	= flows_dump_seq_show,
-
 
2874
	.next	= flows_dump_seq_next,
-
 
2875
	.stop	= flows_dump_seq_stop,
-
 
2876
};
-
 
2877
 
-
 
2878
static int flows_seq_open(struct inode *inode, struct file *file)
-
 
2879
{
-
 
2880
	struct flows_dump_private *st;
-
 
2881
	char *buf;
-
 
2882
	const size_t size = 4 * PAGE_SIZE;
-
 
2883
 
-
 
2884
	buf = kmalloc(size, GFP_KERNEL);
-
 
2885
	if (!buf)
-
 
2886
		return -ENOMEM;
-
 
2887
 
-
 
2888
	st = __seq_open_private(file, &flows_dump_seq_ops, sizeof(struct flows_dump_private));
-
 
2889
	if (!st) {
-
 
2890
		kfree(buf);
-
 
2891
		return -ENOMEM;
-
 
2892
	}
-
 
2893
	INIT_LIST_HEAD(&st->list);
-
 
2894
	/* speed up seq interface with bigger buffer */
-
 
2895
	((struct seq_file *)file->private_data)->buf = buf;
-
 
2896
	((struct seq_file *)file->private_data)->size = size;
-
 
2897
	return 0;
-
 
2898
 
-
 
2899
}
-
 
2900
static int flows_seq_release(struct inode *inode, struct file *file)
-
 
2901
{
-
 
2902
	struct seq_file *seq = file->private_data;
-
 
2903
	struct flows_dump_private *st = seq->private;
-
 
2904
 
-
 
2905
	nf_free_stripe(&st->list);
-
 
2906
	if (st->alloc_errors)
-
 
2907
		printk(KERN_INFO "ipt_NETFLOW: alloc_errors %d\n", st->alloc_errors);
-
 
2908
	return seq_release_private(inode, file);
-
 
2909
}
-
 
2910
 
-
 
2911
static struct file_operations flows_seq_fops = {
-
 
2912
	.owner	 = THIS_MODULE,
-
 
2913
	.open	 = flows_seq_open,
-
 
2914
	.read	 = seq_read,
-
 
2915
	.llseek	 = seq_lseek,
-
 
2916
	.release = flows_seq_release,
-
 
2917
};
-
 
2918
#endif /* CONFIG_PROC_FS */
-
 
2919
 
-
 
2920
#ifdef ENABLE_PROMISC
-
 
2921
static int promisc_finish(
-
 
2922
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
-
 
2923
    struct net *net,
-
 
2924
#endif
-
 
2925
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) || \
-
 
2926
    (defined(RHEL_MAJOR) && RHEL_MAJOR == 7 && RHEL_MINOR >= 2)
-
 
2927
    struct sock *sk,
-
 
2928
#endif
-
 
2929
    struct sk_buff *skb)
-
 
2930
{
-
 
2931
	/* don't pass to the routing */
-
 
2932
	kfree_skb(skb);
-
 
2933
	return NET_RX_DROP;
-
 
2934
}
-
 
2935
 
-
 
2936
static int promisc4_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
-
 
2937
{
-
 
2938
	const struct iphdr *iph;
-
 
2939
	u32 len;
-
 
2940
 
-
 
2941
	/* clone skb and do basic IPv4 sanity checking and preparations
-
 
2942
	 * for L3, this is quick and dirty version of ip_rcv() */
-
 
2943
	if (!pskb_may_pull(skb, sizeof(struct iphdr)))
-
 
2944
		goto drop;
-
 
2945
	iph = ip_hdr(skb);
-
 
2946
	if (iph->ihl < 5 || iph->version != 4)
-
 
2947
		goto drop;
-
 
2948
	if (!pskb_may_pull(skb, iph->ihl*4))
-
 
2949
		goto drop;
-
 
2950
	iph = ip_hdr(skb);
-
 
2951
	if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
-
 
2952
		goto drop;
-
 
2953
	len = ntohs(iph->tot_len);
-
 
2954
	if (skb->len < len)
-
 
2955
		goto drop;
-
 
2956
	else if (len < (iph->ihl*4))
-
 
2957
		goto drop;
-
 
2958
	if (pskb_trim_rcsum(skb, len))
-
 
2959
		goto drop;
-
 
2960
	skb->transport_header = skb->network_header + iph->ihl*4;
-
 
2961
	memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
-
 
2962
	skb_orphan(skb);
-
 
2963
 
-
 
2964
	return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
-
 
2965
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
-
 
2966
	    dev_net(dev),
-
 
2967
#endif
-
 
2968
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) || (defined(RHEL_MAJOR) && RHEL_MAJOR == 7 && RHEL_MINOR > 1)
-
 
2969
	    NULL,
-
 
2970
#endif
-
 
2971
	    skb, dev, NULL, promisc_finish);
-
 
2972
drop:
-
 
2973
	NETFLOW_STAT_INC(pkt_promisc_drop);
-
 
2974
	kfree_skb(skb);
-
 
2975
	return NET_RX_DROP;
-
 
2976
}
-
 
2977
 
-
 
2978
static int promisc6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
-
 
2979
{
-
 
2980
	const struct ipv6hdr *hdr;
-
 
2981
	u32 pkt_len;
-
 
2982
	struct inet6_dev *idev;
-
 
2983
 
-
 
2984
	/* quick and dirty version of ipv6_rcv(), basic sanity checking
-
 
2985
	 * and preparation of skb for later processing */
-
 
2986
	rcu_read_lock();
-
 
2987
	idev = __in6_dev_get(skb->dev);
-
 
2988
	if (!idev || unlikely(idev->cnf.disable_ipv6))
-
 
2989
		goto drop;
-
 
2990
	memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
-
 
2991
	IP6CB(skb)->iif = skb_dst(skb) ? ip6_dst_idev(skb_dst(skb))->dev->ifindex : dev->ifindex;
-
 
2992
	if (unlikely(!pskb_may_pull(skb, sizeof(*hdr))))
-
 
2993
		goto drop;
-
 
2994
	hdr = ipv6_hdr(skb);
-
 
2995
	if (hdr->version != 6)
-
 
2996
		goto drop;
-
 
2997
	if (!(dev->flags & IFF_LOOPBACK) &&
-
 
2998
	    ipv6_addr_loopback(&hdr->daddr))
-
 
2999
		goto drop;
-
 
3000
	if (!(skb->pkt_type == PACKET_LOOPBACK ||
-
 
3001
		    dev->flags & IFF_LOOPBACK) &&
-
 
3002
	    ipv6_addr_is_multicast(&hdr->daddr) &&
-
 
3003
	    IPV6_ADDR_MC_SCOPE(&hdr->daddr) == 1)
-
 
3004
		goto drop;
-
 
3005
	if (ipv6_addr_is_multicast(&hdr->daddr) &&
-
 
3006
	    IPV6_ADDR_MC_SCOPE(&hdr->daddr) == 0)
-
 
3007
		goto drop;
-
 
3008
	if (ipv6_addr_is_multicast(&hdr->saddr))
-
 
3009
		goto drop;
-
 
3010
	skb->transport_header = skb->network_header + sizeof(*hdr);
-
 
3011
	IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr);
-
 
3012
	pkt_len = ntohs(hdr->payload_len);
-
 
3013
	if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {
-
 
3014
		if (pkt_len + sizeof(struct ipv6hdr) > skb->len)
-
 
3015
			goto drop;
-
 
3016
		if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
-
 
3017
			goto drop;
-
 
3018
		hdr = ipv6_hdr(skb);
-
 
3019
	}
-
 
3020
	if (hdr->nexthdr == NEXTHDR_HOP) {
-
 
3021
		int optlen;
-
 
3022
		/* ipv6_parse_hopopts() is not exported by kernel.
-
 
3023
		 * I dont really need to parse hop options, since packets
-
 
3024
		 * are not routed, nor terminated, but I keep calculations
-
 
3025
		 * in case other code depend on it. */
-
 
3026
		if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
-
 
3027
		    !pskb_may_pull(skb, (sizeof(struct ipv6hdr) +
-
 
3028
				    ((skb_transport_header(skb)[1] + 1) << 3))))
-
 
3029
			goto drop;
-
 
3030
		optlen = (skb_transport_header(skb)[1] + 1) << 3;
-
 
3031
		if (skb_transport_offset(skb) + optlen > skb_headlen(skb))
-
 
3032
			goto drop;
-
 
3033
		skb->transport_header += optlen;
-
 
3034
		IP6CB(skb)->nhoff = sizeof(struct ipv6hdr);
-
 
3035
	}
-
 
3036
	rcu_read_unlock();
-
 
3037
	skb_orphan(skb);
-
 
3038
 
-
 
3039
	return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
-
 
3040
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
-
 
3041
	    dev_net(dev),
-
 
3042
#endif
-
 
3043
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) || (defined(RHEL_MAJOR) && RHEL_MAJOR == 7 && RHEL_MINOR > 1)
-
 
3044
	    NULL,
-
 
3045
#endif
-
 
3046
	    skb, dev, NULL, promisc_finish);
-
 
3047
drop:
-
 
3048
	rcu_read_unlock();
-
 
3049
	NETFLOW_STAT_INC(pkt_promisc_drop);
-
 
3050
	kfree_skb(skb);
-
 
3051
	return NET_RX_DROP;
-
 
3052
}
-
 
3053
 
-
 
3054
/* source is skb_network_protocol() and __vlan_get_protocol() */
-
 
3055
static __be16 __skb_network_protocol(struct sk_buff *skb, int *depth)
-
 
3056
{
-
 
3057
	__be16 type = skb->protocol;
-
 
3058
	unsigned int vlan_depth;
-
 
3059
 
-
 
3060
	if (type == htons(ETH_P_TEB)) {
-
 
3061
		struct ethhdr *eth;
-
 
3062
 
-
 
3063
		if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr))))
-
 
3064
			return 0;
-
 
3065
 
-
 
3066
		eth = (struct ethhdr *)skb_mac_header(skb);
-
 
3067
		type = eth->h_proto;
-
 
3068
	}
-
 
3069
 
-
 
3070
	vlan_depth = skb->mac_len;
-
 
3071
	if (type == htons(ETH_P_8021Q) || type == htons(ETH_P_8021AD)) {
-
 
3072
		if (vlan_depth) {
-
 
3073
			if (WARN_ON(vlan_depth < VLAN_HLEN))
-
 
3074
				return 0;
-
 
3075
			vlan_depth -= VLAN_HLEN;
-
 
3076
		} else {
-
 
3077
			vlan_depth = ETH_HLEN;
-
 
3078
		}
-
 
3079
		do {
-
 
3080
			struct vlan_hdr *vh;
-
 
3081
 
-
 
3082
			if (unlikely(!pskb_may_pull(skb, vlan_depth + VLAN_HLEN)))
-
 
3083
				return 0;
-
 
3084
 
-
 
3085
			vh = (struct vlan_hdr *)(skb->data + vlan_depth);
-
 
3086
			type = vh->h_vlan_encapsulated_proto;
-
 
3087
			vlan_depth += VLAN_HLEN;
-
 
3088
		} while (type == htons(ETH_P_8021Q) ||
-
 
3089
			 type == htons(ETH_P_8021AD));
-
 
3090
	}
-
 
3091
 
-
 
3092
	*depth = vlan_depth;
-
 
3093
 
-
 
3094
	return type;
-
 
3095
}
-
 
3096
 
-
 
3097
static int promisc_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
-
 
3098
{
-
 
3099
	/* what is not PACKET_OTHERHOST will be processed normally */
-
 
3100
	if (skb->pkt_type != PACKET_OTHERHOST)
-
 
3101
		goto out;
-
 
3102
 
-
 
3103
	NETFLOW_STAT_INC(pkt_promisc);
-
 
3104
 
-
 
3105
	if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
-
 
3106
		goto drop;
-
 
3107
 
-
 
3108
	/* Note about vlans:
-
 
3109
	 * - older kernels will pass raw packet;
-
 
3110
	 * - newer kernes (since 3.0) will have one vlan tag
-
 
3111
	 * physically stripped out of the packet, and it will
-
 
3112
	 * be saved into skb->vlan_tci. skb->protocol will be
-
 
3113
	 * untagged etherType. */
-
 
3114
 
-
 
3115
	if (skb->protocol == cpu_to_be16(ETH_P_8021Q) ||
-
 
3116
	    skb->protocol == cpu_to_be16(ETH_P_8021AD)) {
-
 
3117
		int vlan_depth = skb->mac_len;
-
 
3118
 
-
 
3119
		skb_push(skb, skb->data - skb_mac_header(skb));
-
 
3120
		skb->protocol = __skb_network_protocol(skb, &vlan_depth);
-
 
3121
		skb_pull(skb, vlan_depth);
-
 
3122
 
-
 
3123
		skb_reset_network_header(skb);
-
 
3124
		skb_reset_mac_len(skb);
-
 
3125
	}
-
 
3126
# ifdef PROMISC_MPLS
-
 
3127
	if (eth_p_mpls(skb->protocol)) {
-
 
3128
		size_t stack_len = 0;
-
 
3129
		const struct mpls_label *mpls;
-
 
3130
 
-
 
3131
		do {
-
 
3132
			stack_len += MPLS_HLEN;
-
 
3133
			if (unlikely(!pskb_may_pull(skb, stack_len)))
-
 
3134
				goto drop;
-
 
3135
			mpls = (struct mpls_label *)(skb->data + stack_len - MPLS_HLEN);
-
 
3136
		} while (!(mpls->entry & htonl(MPLS_LS_S_MASK)));
-
 
3137
 
-
 
3138
		skb_pull(skb, stack_len);
-
 
3139
		skb_reset_network_header(skb);
-
 
3140
 
-
 
3141
		if (!pskb_may_pull(skb, 1))
-
 
3142
			goto drop;
-
 
3143
		switch (ip_hdr(skb)->version) {
-
 
3144
		case 4:  skb->protocol = htons(ETH_P_IP);   break;
-
 
3145
		case 6:  skb->protocol = htons(ETH_P_IPV6); break;
-
 
3146
		default: goto drop;
-
 
3147
		}
-
 
3148
	}
-
 
3149
# endif
-
 
3150
	switch (skb->protocol) {
-
 
3151
	case htons(ETH_P_IP):
-
 
3152
		return promisc4_rcv(skb, dev, pt, orig_dev);
-
 
3153
	case htons(ETH_P_IPV6):
-
 
3154
		return promisc6_rcv(skb, dev, pt, orig_dev);
-
 
3155
	}
-
 
3156
drop:
-
 
3157
	NETFLOW_STAT_INC(pkt_promisc_drop);
-
 
3158
out:
-
 
3159
	kfree_skb(skb);
-
 
3160
	return 0;
-
 
3161
}
-
 
3162
 
-
 
3163
static struct packet_type promisc_packet_type __read_mostly = {
-
 
3164
	.type = htons(ETH_P_ALL),
-
 
3165
	.func = promisc_rcv,
-
 
3166
};
-
 
3167
 
-
 
3168
/* should not have promisc passed as parameter */
-
 
3169
static int switch_promisc(int newpromisc)
-
 
3170
{
-
 
3171
	newpromisc = !!newpromisc;
-
 
3172
	mutex_lock(&promisc_lock);
-
 
3173
	if (newpromisc == promisc)
-
 
3174
		goto unlock;
-
 
3175
	if (newpromisc)
-
 
3176
		dev_add_pack(&promisc_packet_type);
-
 
3177
	else
-
 
3178
		dev_remove_pack(&promisc_packet_type);
-
 
3179
	printk(KERN_INFO "ipt_NETFLOW: promisc hack is %s\n",
-
 
3180
	    newpromisc? "enabled" : "disabled");
-
 
3181
	promisc = newpromisc;
-
 
3182
unlock:
-
 
3183
	mutex_unlock(&promisc_lock);
-
 
3184
	return 0;
-
 
3185
}
-
 
3186
#endif
-
 
3187
 
-
 
3188
#ifdef CONFIG_SYSCTL
-
 
3189
/* sysctl /proc/sys/net/netflow */
-
 
3190
static int hsize_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3191
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3192
{
-
 
3193
	int ret, hsize;
-
 
3194
	ctl_table_no_const lctl = *ctl;
-
 
3195
 
-
 
3196
	if (write)
-
 
3197
		lctl.data = &hsize;
-
 
3198
	ret = proc_dointvec(&lctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3199
	if (write) {
-
 
3200
		if (hsize < LOCK_COUNT)
-
 
3201
			return -EPERM;
-
 
3202
		return set_hashsize(hsize)?:ret;
-
 
3203
	} else
-
 
3204
		return ret;
-
 
3205
}
-
 
3206
 
-
 
3207
static int sndbuf_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3208
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3209
{
-
 
3210
	int ret;
-
 
3211
	struct ipt_netflow_sock *usock;
-
 
3212
	ctl_table_no_const lctl = *ctl;
-
 
3213
 
-
 
3214
	mutex_lock(&sock_lock);
-
 
3215
	if (list_empty(&usock_list)) {
-
 
3216
		mutex_unlock(&sock_lock);
-
 
3217
		return -ENOENT;
-
 
3218
	}
-
 
3219
	usock = list_first_entry(&usock_list, struct ipt_netflow_sock, list);
-
 
3220
	if (usock->sock)
-
 
3221
		sndbuf = usock->sock->sk->sk_sndbuf;
-
 
3222
	mutex_unlock(&sock_lock);
-
 
3223
 
-
 
3224
	lctl.data = &sndbuf;
-
 
3225
	ret = proc_dointvec(&lctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3226
	if (!write)
-
 
3227
		return ret;
-
 
3228
	if (sndbuf < SOCK_MIN_SNDBUF)
-
 
3229
		sndbuf = SOCK_MIN_SNDBUF;
-
 
3230
	pause_scan_worker();
-
 
3231
	mutex_lock(&sock_lock);
-
 
3232
	list_for_each_entry(usock, &usock_list, list) {
-
 
3233
		if (usock->sock)
-
 
3234
			usock->sock->sk->sk_sndbuf = sndbuf;
-
 
3235
	}
-
 
3236
	mutex_unlock(&sock_lock);
-
 
3237
	cont_scan_worker();
-
 
3238
	return ret;
-
 
3239
}
-
 
3240
 
-
 
3241
static void free_templates(void);
-
 
3242
static int destination_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3243
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3244
{
-
 
3245
	int ret;
-
 
3246
 
-
 
3247
	ret = proc_dostring(ctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3248
	if (ret >= 0 && write) {
-
 
3249
		pause_scan_worker();
-
 
3250
		destination_removeall();
-
 
3251
		add_destinations(destination_buf);
-
 
3252
		free_templates();
-
 
3253
		cont_scan_worker();
-
 
3254
	}
-
 
3255
	return ret;
-
 
3256
}
-
 
3257
 
-
 
3258
#ifdef ENABLE_AGGR
-
 
3259
static int aggregation_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3260
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3261
{
-
 
3262
	int ret;
-
 
3263
 
-
 
3264
	if (debug > 1)
-
 
3265
		printk(KERN_INFO "aggregation_procctl (%d) %u %llu\n", write, (unsigned int)(*lenp), *fpos);
-
 
3266
	ret = proc_dostring(ctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3267
	if (ret >= 0 && write)
-
 
3268
		add_aggregation(aggregation_buf);
-
 
3269
	return ret;
-
 
3270
}
-
 
3271
#endif
-
 
3272
 
-
 
3273
#ifdef ENABLE_PROMISC
-
 
3274
static int promisc_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3275
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3276
{
-
 
3277
	int newpromisc = promisc;
-
 
3278
	int ret;
-
 
3279
	ctl_table_no_const lctl = *ctl;
-
 
3280
 
-
 
3281
	lctl.data = &newpromisc;
-
 
3282
	ret = proc_dointvec(&lctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3283
	if (ret < 0 || !write)
-
 
3284
		return ret;
-
 
3285
	return switch_promisc(newpromisc);
-
 
3286
}
-
 
3287
#endif
-
 
3288
 
-
 
3289
#ifdef ENABLE_SAMPLER
-
 
3290
static int parse_sampler(char *ptr);
-
 
3291
static int sampler_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3292
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3293
{
-
 
3294
	int ret;
-
 
3295
 
-
 
3296
	if (debug > 1)
-
 
3297
		printk(KERN_INFO "sampler_procctl (%d) %u %llu\n", write, (unsigned int)(*lenp), *fpos);
-
 
3298
	ret = proc_dostring(ctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3299
	if (ret >= 0 && write) {
-
 
3300
		int cpu;
-
 
3301
 
-
 
3302
		pause_scan_worker();
-
 
3303
		netflow_scan_and_export(AND_FLUSH);
-
 
3304
		/* paused for sampling_code reads to be consistent */
-
 
3305
		ret = parse_sampler(sampler_buf);
-
 
3306
		/* resend templates */
-
 
3307
		ts_sampler_last = 0;
-
 
3308
		/* zero stat */
-
 
3309
		atomic64_set(&flows_observed, 0);
-
 
3310
		atomic64_set(&flows_selected, 0);
-
 
3311
		for_each_present_cpu(cpu) {
-
 
3312
			struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
3313
			st->pkts_selected = 0;
-
 
3314
			st->pkts_observed = 0;
-
 
3315
		}
-
 
3316
		cont_scan_worker();
-
 
3317
	}
-
 
3318
	return ret;
-
 
3319
}
-
 
3320
#endif
-
 
3321
 
-
 
3322
#ifdef SNMP_RULES
-
 
3323
static int add_snmp_rules(char *ptr);
-
 
3324
static int snmp_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3325
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3326
{
-
 
3327
       int ret;
-
 
3328
 
-
 
3329
       if (debug > 1)
-
 
3330
	       printk(KERN_INFO "snmp_procctl (%d) %u %llu\n", write, (unsigned int)(*lenp), *fpos);
-
 
3331
       ret = proc_dostring(ctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3332
       if (ret >= 0 && write)
-
 
3333
               return add_snmp_rules(snmp_rules_buf);
-
 
3334
       return ret;
-
 
3335
}
-
 
3336
#endif
-
 
3337
 
-
 
3338
static void clear_ipt_netflow_stat(void)
-
 
3339
{
-
 
3340
	int cpu;
-
 
3341
 
-
 
3342
	for_each_present_cpu(cpu) {
-
 
3343
		struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
3344
		memset(st, 0, sizeof(*st));
-
 
3345
		st->metric = METRIC_DFL;
-
 
3346
	}
-
 
3347
}
-
 
3348
 
-
 
3349
static int flush_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3350
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3351
{
-
 
3352
	int ret;
-
 
3353
	int val = 0;
-
 
3354
	ctl_table_no_const lctl = *ctl;
-
 
3355
 
-
 
3356
	lctl.data = &val;
-
 
3357
	ret = proc_dointvec(&lctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3358
 
-
 
3359
	if (!write)
-
 
3360
		return ret;
-
 
3361
 
-
 
3362
	if (val > 0) {
-
 
3363
		char *stat = "";
-
 
3364
 
-
 
3365
		pause_scan_worker();
-
 
3366
		netflow_scan_and_export(AND_FLUSH);
-
 
3367
		if (val > 1) {
-
 
3368
			clear_ipt_netflow_stat();
-
 
3369
			stat = " (reset stat counters)";
-
 
3370
		}
-
 
3371
		printk(KERN_INFO "ipt_NETFLOW: forced flush%s.\n", stat);
-
 
3372
		cont_scan_worker();
-
 
3373
	}
-
 
3374
 
-
 
3375
	return ret;
-
 
3376
}
-
 
3377
 
-
 
3378
static int protocol_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3379
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3380
{
-
 
3381
	int ret;
-
 
3382
	int ver = protocol;
-
 
3383
	ctl_table_no_const lctl = *ctl;
-
 
3384
 
-
 
3385
	lctl.data = &ver;
-
 
3386
	ret = proc_dointvec(&lctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3387
 
-
 
3388
	if (!write)
-
 
3389
		return ret;
-
 
3390
 
-
 
3391
	switch (ver) {
-
 
3392
		case 5:
-
 
3393
		case 9:
-
 
3394
		case 10:
-
 
3395
			printk(KERN_INFO "ipt_NETFLOW: forced flush (protocol version change)\n");
-
 
3396
			pause_scan_worker();
-
 
3397
			netflow_scan_and_export(AND_FLUSH);
-
 
3398
			netflow_switch_version(ver);
-
 
3399
			cont_scan_worker();
-
 
3400
			break;
-
 
3401
		default:
-
 
3402
			return -EPERM;
-
 
3403
	}
-
 
3404
 
-
 
3405
	return ret;
-
 
3406
}
-
 
3407
 
-
 
3408
#ifdef CONFIG_NF_NAT_NEEDED
-
 
3409
static void register_ct_events(void);
-
 
3410
static void unregister_ct_events(void);
-
 
3411
static int natevents_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
-
 
3412
			 void __user *buffer, size_t *lenp, loff_t *fpos)
-
 
3413
{
-
 
3414
	int ret;
-
 
3415
	int val = natevents;
-
 
3416
	ctl_table_no_const lctl = *ctl;
-
 
3417
 
-
 
3418
	lctl.data = &val;
-
 
3419
	ret = proc_dointvec(&lctl, write, BEFORE2632(filp,) buffer, lenp, fpos);
-
 
3420
 
-
 
3421
	if (!write)
-
 
3422
		return ret;
-
 
3423
 
-
 
3424
	if (natevents && !val)
-
 
3425
		unregister_ct_events();
-
 
3426
	else if (!natevents && val)
-
 
3427
		register_ct_events();
-
 
3428
 
-
 
3429
	return ret;
-
 
3430
}
-
 
3431
#endif
-
 
3432
 
-
 
3433
static struct ctl_table_header *netflow_sysctl_header;
-
 
3434
 
-
 
3435
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-
 
3436
#define _CTL_NAME(x) .ctl_name = x,
-
 
3437
static void ctl_table_renumber(ctl_table *table)
-
 
3438
{
-
 
3439
	int c;
-
 
3440
 
-
 
3441
	for (c = 1; table->procname; table++, c++)
-
 
3442
		table->ctl_name = c;
-
 
3443
}
-
 
3444
#else
-
 
3445
#define _CTL_NAME(x)
-
 
3446
#define ctl_table_renumber(x)
-
 
3447
#endif
-
 
3448
static ctl_table netflow_sysctl_table[] = {
-
 
3449
	{
-
 
3450
		.procname	= "active_timeout",
-
 
3451
		.mode		= 0644,
-
 
3452
		.data		= &active_timeout,
-
 
3453
		.maxlen		= sizeof(int),
-
 
3454
		.proc_handler	= &proc_dointvec,
-
 
3455
	},
-
 
3456
	{
-
 
3457
		.procname	= "inactive_timeout",
-
 
3458
		.mode		= 0644,
-
 
3459
		.data		= &inactive_timeout,
-
 
3460
		.maxlen		= sizeof(int),
-
 
3461
		.proc_handler	= &proc_dointvec,
-
 
3462
	},
-
 
3463
	{
-
 
3464
		.procname	= "debug",
-
 
3465
		.mode		= 0644,
-
 
3466
		.data		= &debug,
-
 
3467
		.maxlen		= sizeof(int),
-
 
3468
		.proc_handler	= &proc_dointvec,
-
 
3469
	},
-
 
3470
	{
-
 
3471
		.procname	= "hashsize",
-
 
3472
		.mode		= 0644,
-
 
3473
		.data		= &htable_size,
-
 
3474
		.maxlen		= sizeof(int),
-
 
3475
		.proc_handler	= &hsize_procctl,
-
 
3476
	},
-
 
3477
	{
-
 
3478
		.procname	= "sndbuf",
-
 
3479
		.mode		= 0644,
-
 
3480
		.maxlen		= sizeof(int),
-
 
3481
		.proc_handler	= &sndbuf_procctl,
-
 
3482
	},
-
 
3483
	{
-
 
3484
		.procname	= "destination",
-
 
3485
		.mode		= 0644,
-
 
3486
		.data		= &destination_buf,
-
 
3487
		.maxlen		= sizeof(destination_buf),
-
 
3488
		.proc_handler	= &destination_procctl,
-
 
3489
	},
-
 
3490
#ifdef ENABLE_AGGR
-
 
3491
	{
-
 
3492
		.procname	= "aggregation",
-
 
3493
		.mode		= 0644,
-
 
3494
		.data		= &aggregation_buf,
-
 
3495
		.maxlen		= sizeof(aggregation_buf),
-
 
3496
		.proc_handler	= &aggregation_procctl,
-
 
3497
	},
-
 
3498
#endif
-
 
3499
	{
-
 
3500
		.procname	= "maxflows",
-
 
3501
		.mode		= 0644,
-
 
3502
		.data		= &maxflows,
-
 
3503
		.maxlen		= sizeof(int),
-
 
3504
		.proc_handler	= &proc_dointvec,
-
 
3505
	},
-
 
3506
	{
-
 
3507
		.procname	= "flush",
-
 
3508
		.mode		= 0644,
-
 
3509
		.maxlen		= sizeof(int),
-
 
3510
		.proc_handler	= &flush_procctl,
-
 
3511
	},
-
 
3512
	{
-
 
3513
		.procname	= "protocol",
-
 
3514
		.mode		= 0644,
-
 
3515
		.maxlen		= sizeof(int),
-
 
3516
		.proc_handler	= &protocol_procctl,
-
 
3517
	},
-
 
3518
	{
-
 
3519
		.procname	= "refresh-rate",
-
 
3520
		.mode		= 0644,
-
 
3521
		.data		= &refresh_rate,
-
 
3522
		.maxlen		= sizeof(int),
-
 
3523
		.proc_handler	= &proc_dointvec,
-
 
3524
	},
-
 
3525
	{
-
 
3526
		.procname	= "timeout-rate",
-
 
3527
		.mode		= 0644,
-
 
3528
		.data		= &timeout_rate,
-
 
3529
		.maxlen		= sizeof(int),
-
 
3530
		.proc_handler	= &proc_dointvec,
-
 
3531
	},
-
 
3532
#ifdef ENABLE_PROMISC
-
 
3533
	{
-
 
3534
		.procname	= "promisc",
-
 
3535
		.mode		= 0644,
-
 
3536
		.data		= &promisc,
-
 
3537
		.maxlen		= sizeof(int),
-
 
3538
		.proc_handler	= &promisc_procctl,
-
 
3539
	},
-
 
3540
#endif
-
 
3541
#ifdef ENABLE_SAMPLER
-
 
3542
	{
-
 
3543
		.procname	= "sampler",
-
 
3544
		.mode		= 0644,
-
 
3545
		.data		= &sampler_buf,
-
 
3546
		.maxlen		= sizeof(sampler_buf),
-
 
3547
		.proc_handler	= &sampler_procctl,
-
 
3548
	},
-
 
3549
#endif
-
 
3550
	{
-
 
3551
		.procname	= "scan-min",
-
 
3552
		.mode		= 0644,
-
 
3553
		.data		= &scan_min,
-
 
3554
		.maxlen		= sizeof(int),
-
 
3555
		.proc_handler	= &proc_dointvec_minmax,
-
 
3556
		.extra1		= &one,
-
 
3557
		.extra2		= &scan_max,
-
 
3558
	},
-
 
3559
#ifdef SNMP_RULES
-
 
3560
	{
-
 
3561
		.procname	= "snmp-rules",
-
 
3562
		.mode		= 0644,
-
 
3563
		.data		= &snmp_rules_buf,
-
 
3564
		.maxlen		= sizeof(snmp_rules_buf),
-
 
3565
		.proc_handler	= &snmp_procctl,
-
 
3566
	},
-
 
3567
#endif
-
 
3568
#ifdef CONFIG_NF_NAT_NEEDED
-
 
3569
	{
-
 
3570
		.procname	= "natevents",
-
 
3571
		.mode		= 0644,
-
 
3572
		.maxlen		= sizeof(int),
-
 
3573
		.proc_handler	= &natevents_procctl,
-
 
3574
	},
-
 
3575
#endif
-
 
3576
	{ }
-
 
3577
};
-
 
3578
 
-
 
3579
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
-
 
3580
static ctl_table netflow_sysctl_root[] = {
-
 
3581
	{
-
 
3582
		_CTL_NAME(33)
-
 
3583
		.procname	= "netflow",
-
 
3584
		.mode		= 0555,
-
 
3585
		.child		= netflow_sysctl_table,
-
 
3586
	},
-
 
3587
	{ }
-
 
3588
};
-
 
3589
 
-
 
3590
static ctl_table netflow_net_table[] = {
-
 
3591
	{
-
 
3592
		.ctl_name	= CTL_NET,
-
 
3593
		.procname	= "net",
-
 
3594
		.mode		= 0555,
-
 
3595
		.child		= netflow_sysctl_root,
-
 
3596
	},
-
 
3597
	{ }
-
 
3598
};
-
 
3599
#else /* >= 2.6.25 */
-
 
3600
static struct ctl_path netflow_sysctl_path[] = {
-
 
3601
	{
-
 
3602
		.procname = "net",
-
 
3603
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
-
 
3604
		.ctl_name = CTL_NET
-
 
3605
#endif
-
 
3606
	},
-
 
3607
	{ .procname = "netflow" },
-
 
3608
	{ }
-
 
3609
};
-
 
3610
#endif /* 2.6.25 */
-
 
3611
#endif /* CONFIG_SYSCTL */
-
 
3612
 
-
 
3613
/* socket code */
-
 
3614
static void sk_error_report(struct sock *sk)
-
 
3615
{
-
 
3616
	struct ipt_netflow_sock *usock;
-
 
3617
 
-
 
3618
	/* clear connection refused errors if any */
-
 
3619
	if (debug > 1)
-
 
3620
		printk(KERN_INFO "ipt_NETFLOW: socket error <%d>\n", sk->sk_err);
-
 
3621
	sk->sk_err = 0;
-
 
3622
	usock = sk->sk_user_data;
-
 
3623
	if (usock)
-
 
3624
		usock->err_cberr++;
-
 
3625
	NETFLOW_STAT_INC(sock_cberr);
-
 
3626
	/* It's theoretically possible to determine to which datagram this reply is,
-
 
3627
	 * because ICMP message frequently includes header of erroneous packet, but
-
 
3628
	 * this is not that reliable - packets could be spoofed, and requires keeping
-
 
3629
	 * book of sent packets. */
-
 
3630
	return;
-
 
3631
}
-
 
3632
 
-
 
3633
static struct socket *usock_open_sock(struct ipt_netflow_sock *usock)
-
 
3634
{
-
 
3635
	struct socket *sock;
-
 
3636
	int error;
-
 
3637
	int salen = 0;
-
 
3638
 
-
 
3639
	if ((error = sock_create_kern(usock->addr.ss_family, SOCK_DGRAM, IPPROTO_UDP, &sock)) < 0) {
-
 
3640
		printk(KERN_ERR "ipt_NETFLOW: sock_create_kern error %d\n", -error);
-
 
3641
		return NULL;
-
 
3642
	}
-
 
3643
	sock->sk->sk_allocation = GFP_ATOMIC;
-
 
3644
	sock->sk->sk_prot->unhash(sock->sk); /* hidden from input */
-
 
3645
	sock->sk->sk_error_report = &sk_error_report; /* clear ECONNREFUSED */
-
 
3646
	sock->sk->sk_user_data = usock;
-
 
3647
	sock->sk->sk_reuse = SK_CAN_REUSE;
-
 
3648
 
-
 
3649
	if (usock->sdev[0]) {
-
 
3650
		struct net_device *dev = dev_get_by_name(&init_net, usock->sdev);
-
 
3651
 
-
 
3652
		if (dev) {
-
 
3653
			sock->sk->sk_bound_dev_if = dev->ifindex;
-
 
3654
			dev_put(dev);
-
 
3655
		} else {
-
 
3656
			printk(KERN_ERR "ipt_NETFLOW: error binding to device %s, errno %d\n",
-
 
3657
			    usock->sdev, -error);
-
 
3658
			return NULL;
-
 
3659
		}
-
 
3660
	}
-
 
3661
	if (!is_zero_addr(&usock->saddr)) {
-
 
3662
		if (usock->saddr.ss_family == AF_INET)
-
 
3663
			salen = sizeof(struct sockaddr_in);
-
 
3664
		else if (usock->saddr.ss_family == AF_INET6)
-
 
3665
			salen = sizeof(struct sockaddr_in6);
-
 
3666
		if ((error = sock->ops->bind(sock, (struct sockaddr *)&usock->saddr, salen)) < 0) {
-
 
3667
			printk(KERN_ERR "ipt_NETFLOW: error binding socket %d\n", -error);
-
 
3668
			return NULL;
-
 
3669
		}
-
 
3670
	}
-
 
3671
 
-
 
3672
	if (sndbuf)
-
 
3673
		sock->sk->sk_sndbuf = sndbuf;
-
 
3674
	else
-
 
3675
		sndbuf = sock->sk->sk_sndbuf;
-
 
3676
	error = sock->ops->connect(sock, (struct sockaddr *)&usock->addr, sizeof(usock->addr), 0);
-
 
3677
	if (error < 0) {
-
 
3678
		printk(KERN_ERR "ipt_NETFLOW: error connecting UDP socket %d,"
-
 
3679
		    " don't worry, will try reconnect later.\n", -error);
-
 
3680
		/* ENETUNREACH when no interfaces */
-
 
3681
		sock_release(sock);
-
 
3682
		return NULL;
-
 
3683
	}
-
 
3684
	return sock;
-
 
3685
}
-
 
3686
 
-
 
3687
static void usock_connect(struct ipt_netflow_sock *usock, const int sendmsg)
-
 
3688
{
-
 
3689
	usock->sock = usock_open_sock(usock);
-
 
3690
	if (usock->sock) {
-
 
3691
		if (sendmsg || debug)
-
 
3692
			printk(KERN_INFO "ipt_NETFLOW: connected %s\n",
-
 
3693
			    print_sockaddr(&usock->addr));
-
 
3694
	} else {
-
 
3695
		usock->err_connect++;
-
 
3696
		if (debug)
-
 
3697
			printk(KERN_INFO "ipt_NETFLOW: connect to %s failed%s.\n",
-
 
3698
			    print_sockaddr(&usock->addr),
-
 
3699
			    (sendmsg)? " (pdu lost)" : "");
-
 
3700
	}
-
 
3701
	atomic_set(&usock->wmem_peak, 0);
-
 
3702
	usock->err_full = 0;
-
 
3703
	usock->err_other = 0;
-
 
3704
}
-
 
3705
 
-
 
3706
static void usock_close(struct ipt_netflow_sock *usock)
-
 
3707
{
-
 
3708
	if (usock->sock)
-
 
3709
		sock_release(usock->sock);
-
 
3710
	usock->sock = NULL;
-
 
3711
}
-
 
3712
 
-
 
3713
ktime_t ktime_get_real(void);
-
 
3714
 
-
 
3715
// return numbers of sends succeded, 0 if none
-
 
3716
/* only called in scan worker path */
-
 
3717
static void netflow_sendmsg(void *buffer, const int len)
-
 
3718
{
-
 
3719
	struct msghdr msg = { .msg_flags = MSG_DONTWAIT|MSG_NOSIGNAL };
-
 
3720
	struct kvec iov = { buffer, len };
-
 
3721
	int retok = 0, ret;
-
 
3722
	int snum = 0;
-
 
3723
	struct ipt_netflow_sock *usock;
-
 
3724
 
-
 
3725
	mutex_lock(&sock_lock);
-
 
3726
	list_for_each_entry(usock, &usock_list, list) {
-
 
3727
		usock->pkt_exp++;
-
 
3728
		usock->bytes_exp += len;
-
 
3729
		if (!usock->sock)
-
 
3730
			usock_connect(usock, 1);
-
 
3731
		if (!usock->sock) {
-
 
3732
			NETFLOW_STAT_INC(send_failed);
-
 
3733
			usock->pkt_fail++;
-
 
3734
			continue;
-
 
3735
		}
-
 
3736
		if (debug)
-
 
3737
			printk(KERN_INFO "netflow_sendmsg: sendmsg(%d, %d) [%u %u]\n",
-
 
3738
			       snum,
-
 
3739
			       len,
-
 
3740
			       compat_refcount_read(&usock->sock->sk->sk_wmem_alloc),
-
 
3741
			       usock->sock->sk->sk_sndbuf);
-
 
3742
		ret = kernel_sendmsg(usock->sock, &msg, &iov, 1, (size_t)len);
-
 
3743
		if (ret < 0) {
-
 
3744
			char *suggestion = "";
-
 
3745
 
-
 
3746
			NETFLOW_STAT_INC(send_failed);
-
 
3747
			usock->pkt_fail++;
-
 
3748
			if (ret == -EAGAIN) {
-
 
3749
				usock->err_full++;
-
 
3750
				suggestion = ": increase sndbuf!";
-
 
3751
			} else {
-
 
3752
				usock->err_other++;
-
 
3753
				if (ret == -ENETUNREACH) {
-
 
3754
					suggestion = ": network is unreachable.";
-
 
3755
				} else if (ret == -EINVAL) {
-
 
3756
					usock_close(usock);
-
 
3757
					suggestion = ": will reconnect.";
-
 
3758
				}
-
 
3759
			}
-
 
3760
			printk(KERN_ERR "ipt_NETFLOW: sendmsg[%d] error %d: data loss %llu pkt, %llu bytes%s\n",
-
 
3761
			       snum, ret, pdu_packets, pdu_traf, suggestion);
-
 
3762
		} else {
-
 
3763
			unsigned int wmem = compat_refcount_read(&usock->sock->sk->sk_wmem_alloc);
-
 
3764
			if (wmem > atomic_read(&usock->wmem_peak))
-
 
3765
				atomic_set(&usock->wmem_peak, wmem);
-
 
3766
			NETFLOW_STAT_INC(exported_pkt);
-
 
3767
			NETFLOW_STAT_ADD(exported_traf, ret);
-
 
3768
			usock->pkt_sent++;
-
 
3769
			retok++;
-
 
3770
		}
-
 
3771
		snum++;
-
 
3772
	}
-
 
3773
	mutex_unlock(&sock_lock);
-
 
3774
	if (retok == 0) {
-
 
3775
		/* not least one send succeded, account stat for dropped packets */
-
 
3776
		NETFLOW_STAT_ADD(pkt_lost, pdu_packets);
-
 
3777
		NETFLOW_STAT_ADD(traf_lost, pdu_traf);
-
 
3778
		NETFLOW_STAT_ADD(flow_lost, pdu_flow_records);
-
 
3779
		NETFLOW_STAT_TS(lost);
-
 
3780
	} else {
-
 
3781
		NETFLOW_STAT_ADD(exported_flow, pdu_flow_records);
-
 
3782
	}
-
 
3783
}
-
 
3784
 
-
 
3785
static void usock_close_free(struct ipt_netflow_sock *usock)
-
 
3786
{
-
 
3787
	printk(KERN_INFO "ipt_NETFLOW: removed destination %s\n",
-
 
3788
	       print_sockaddr(&usock->addr));
-
 
3789
	usock_close(usock);
-
 
3790
	vfree(usock);
-
 
3791
}
-
 
3792
 
-
 
3793
static void destination_removeall(void)
-
 
3794
{
-
 
3795
	mutex_lock(&sock_lock);
-
 
3796
	while (!list_empty(&usock_list)) {
-
 
3797
		struct ipt_netflow_sock *usock;
-
 
3798
 
-
 
3799
		usock = list_entry(usock_list.next, struct ipt_netflow_sock, list);
-
 
3800
		list_del(&usock->list);
-
 
3801
		mutex_unlock(&sock_lock);
-
 
3802
		usock_close_free(usock);
-
 
3803
		mutex_lock(&sock_lock);
-
 
3804
	}
-
 
3805
	mutex_unlock(&sock_lock);
-
 
3806
}
-
 
3807
 
-
 
3808
static void add_usock(struct ipt_netflow_sock *usock)
-
 
3809
{
-
 
3810
	struct ipt_netflow_sock *sk;
-
 
3811
 
-
 
3812
	mutex_lock(&sock_lock);
-
 
3813
	/* don't need duplicated sockets */
-
 
3814
	list_for_each_entry(sk, &usock_list, list) {
-
 
3815
		if (sockaddr_cmp(&sk->addr, &usock->addr)) {
-
 
3816
			mutex_unlock(&sock_lock);
-
 
3817
			usock_close_free(usock);
-
 
3818
			return;
-
 
3819
		}
-
 
3820
	}
-
 
3821
	list_add_tail(&usock->list, &usock_list);
-
 
3822
	printk(KERN_INFO "ipt_NETFLOW: added destination %s%s\n",
-
 
3823
	       print_usock_addr(usock),
-
 
3824
	       (!usock->sock)? " (unconnected)" : "");
-
 
3825
	mutex_unlock(&sock_lock);
-
 
3826
}
-
 
3827
 
-
 
3828
#if defined(ENABLE_SAMPLER) || defined(SNMP_RULES)
-
 
3829
static inline int xisdigit(int ch)
-
 
3830
{
-
 
3831
	return (ch >= '0') && (ch <= '9');
-
 
3832
}
-
 
3833
 
-
 
3834
static inline int simple_atoi(const char *p)
-
 
3835
{
-
 
3836
	int i;
-
 
3837
 
-
 
3838
	for (i = 0; xisdigit(*p); p++)
-
 
3839
		i = i * 10 + *p - '0';
-
 
3840
	return i;
-
 
3841
}
-
 
3842
#endif
-
 
3843
 
-
 
3844
#ifdef ENABLE_SAMPLER
-
 
3845
static void set_sampler(const unsigned char mode, const unsigned short interval)
-
 
3846
{
-
 
3847
	struct sampling s;
-
 
3848
 
-
 
3849
	s.mode = mode;
-
 
3850
	s.interval = interval;
-
 
3851
	if (!mode || interval > SAMPLER_INTERVAL_M) {
-
 
3852
		*sampler_buf = 0;
-
 
3853
		samp.v32 = s.v32;
-
 
3854
		printk(KERN_ERR "ipt_NETFLOW: flow sampling is disabled.\n");
-
 
3855
	} else {
-
 
3856
		sampling_ts.first = ktime_get_real();
-
 
3857
		/* no race here, becasue exporting process is stopped */
-
 
3858
		samp.v32 = s.v32;
-
 
3859
		sprintf(sampler_buf, "%s:%u", sampler_mode_string(), interval);
-
 
3860
		printk(KERN_ERR "ipt_NETFLOW: flow sampling is enabled, mode %s one-out-of %u.\n",
-
 
3861
		    sampler_mode_string(), interval);
-
 
3862
	}
-
 
3863
}
-
 
3864
 
-
 
3865
static int parse_sampler(char *ptr)
-
 
3866
{
-
 
3867
	char *p;
-
 
3868
	unsigned char mode;
-
 
3869
	unsigned int val;
-
 
3870
	int ret = 0;
-
 
3871
 
-
 
3872
	switch (tolower(*ptr)) {
-
 
3873
	case 'd': mode = SAMPLER_DETERMINISTIC; break;
-
 
3874
	case 'r': mode = SAMPLER_RANDOM; break;
-
 
3875
#ifdef SAMPLING_HASH
-
 
3876
	case 'h': mode = SAMPLER_HASH; break;
-
 
3877
#endif
-
 
3878
	default:
-
 
3879
		printk(KERN_ERR "ipt_NETFLOW: sampler parse error (%s '%s').\n",
-
 
3880
		    "unknown mode", ptr);
-
 
3881
		ret = -EINVAL;
-
 
3882
		/* FALLTHROUGH */
-
 
3883
	case '\0': /* empty */
-
 
3884
	case 'n':  /* none */
-
 
3885
	case 'o':  /* off */
-
 
3886
	case '0':  /* zero */
-
 
3887
		  set_sampler(0, 0);
-
 
3888
		  return ret;
-
 
3889
	}
-
 
3890
	p = strchr(ptr, ':');
-
 
3891
	if (!p) {
-
 
3892
		printk(KERN_ERR "ipt_NETFLOW: sampler parse error (%s '%s').\n",
-
 
3893
		    "no interval specified", ptr);
-
 
3894
		set_sampler(0, 0);
-
 
3895
		return -EINVAL;
-
 
3896
	}
-
 
3897
	val = simple_atoi(++p);
-
 
3898
	if (val < 2 || val > SAMPLER_INTERVAL_M) {
-
 
3899
		printk(KERN_ERR "ipt_NETFLOW: sampler parse error (%s '%s').\n",
-
 
3900
		    "illegal interval", p);
-
 
3901
		set_sampler(0, 0);
-
 
3902
		return -EINVAL;
-
 
3903
	}
-
 
3904
	set_sampler(mode, val);
-
 
3905
	return 0;
-
 
3906
}
-
 
3907
#endif
-
 
3908
 
-
 
3909
#ifdef SNMP_RULES
-
 
3910
/* source string: eth:100,ppp:200,vlan:300 */
-
 
3911
/* reformat to: length[1], prefix[len], offset[2], ..., null[1]. */
-
 
3912
static int parse_snmp_rules(char *ptr, unsigned char *dst)
-
 
3913
{
-
 
3914
	int osize = 0;
-
 
3915
 
-
 
3916
	while (*ptr) {
-
 
3917
		char *prefix = ptr;
-
 
3918
		unsigned int number;
-
 
3919
		int len, lsize;
-
 
3920
		char *p;
-
 
3921
 
-
 
3922
		p = strchr(ptr, ':');
-
 
3923
		if (!p)
-
 
3924
			return -EINVAL;
-
 
3925
		len = p - ptr;
-
 
3926
		if (len == 0)
-
 
3927
			return -EINVAL;
-
 
3928
		ptr += len;
-
 
3929
		if (sscanf(ptr, ":%d%n", &number, &lsize) < 1)
-
 
3930
			return -EINVAL;
-
 
3931
		ptr += lsize;
-
 
3932
		if (*ptr) /* any separator will work */
-
 
3933
			ptr++;
-
 
3934
		osize += 1 + len + 2;
-
 
3935
		if (dst) {
-
 
3936
			*dst++ = len;
-
 
3937
			memcpy(dst, prefix, len);
-
 
3938
			dst += len;
-
 
3939
			*dst++ = (number >> 8) & 0xff;
-
 
3940
			*dst++ = number & 0xff;
-
 
3941
		}
-
 
3942
	}
-
 
3943
	osize += 1;
-
 
3944
	if (dst)
-
 
3945
		*dst = '\0';
-
 
3946
	return osize;
-
 
3947
}
-
 
3948
 
-
 
3949
static int add_snmp_rules(char *ptr)
-
 
3950
{
-
 
3951
	int osize = parse_snmp_rules(ptr, NULL);
-
 
3952
	char *dst;
-
 
3953
	char *old;
-
 
3954
 
-
 
3955
	if (osize <= 0) {
-
 
3956
		printk(KERN_ERR "ipt_NETFLOW: add_snmp_rules parse error.\n");
-
 
3957
		strcpy(snmp_rules_buf, "parse error");
-
 
3958
		return -EINVAL;
-
 
3959
	}
-
 
3960
	dst = kmalloc(osize, GFP_KERNEL);
-
 
3961
	if (!dst) {
-
 
3962
		strcpy(snmp_rules_buf, "no memory");
-
 
3963
		printk(KERN_ERR "ipt_NETFLOW: add_snmp_rules no memory.\n");
-
 
3964
		return -ENOMEM;
-
 
3965
	}
-
 
3966
	parse_snmp_rules(ptr, dst);
-
 
3967
	spin_lock(&snmp_lock);
-
 
3968
	old = snmp_ruleset;
-
 
3969
	rcu_assign_pointer(snmp_ruleset, dst);
-
 
3970
	spin_unlock(&snmp_lock);
-
 
3971
	synchronize_rcu();
-
 
3972
	if (old)
-
 
3973
		kfree(old);
-
 
3974
	return 0;
-
 
3975
}
-
 
3976
 
-
 
3977
static inline int resolve_snmp(const struct net_device *ifc)
-
 
3978
{
-
 
3979
	const unsigned char *rules;
-
 
3980
 
-
 
3981
	if (!ifc)
-
 
3982
		return -1;
-
 
3983
	rules = rcu_dereference(snmp_ruleset);
-
 
3984
	if (!rules)
-
 
3985
		return ifc->ifindex;
-
 
3986
	while (*rules) {
-
 
3987
		const unsigned int len = *rules++;
-
 
3988
		const char *ifname = ifc->name;
-
 
3989
 
-
 
3990
		if (!strncmp(ifname, rules, len)) {
-
 
3991
			rules += len;
-
 
3992
			return (rules[0] << 8) + rules[1] +
-
 
3993
				simple_atoi(ifname + len);
-
 
3994
		}
-
 
3995
		rules += len + 2;
-
 
3996
	}
-
 
3997
	return ifc->ifindex;
-
 
3998
}
-
 
3999
#endif /* SNMP_RULES */
-
 
4000
 
-
 
4001
/* count how much character c is in the string */
-
 
4002
static size_t strncount(const char *s, size_t count, int c)
-
 
4003
{
-
 
4004
	size_t amount = 0;
-
 
4005
 
-
 
4006
	for (; count-- && *s != '\0'; ++s)
-
 
4007
		if (*s == (char)c)
-
 
4008
			++amount;
-
 
4009
	return amount;
-
 
4010
}
-
 
4011
 
-
 
4012
#define SEPARATORS " ,;\t\n"
-
 
4013
static int add_destinations(const char *ptr)
-
 
4014
{
-
 
4015
	int len;
-
 
4016
 
-
 
4017
	for (; ptr; ptr += len) {
-
 
4018
		struct sockaddr_storage ss;
-
 
4019
		struct sockaddr_storage sbind = {};
-
 
4020
		struct ipt_netflow_sock *usock;
-
 
4021
		const char *end;
-
 
4022
		int succ = 0;
-
 
4023
		char name[IFNAMSIZ] = { 0 };
-
 
4024
 
-
 
4025
		/* skip initial separators */
-
 
4026
		ptr += strspn(ptr, SEPARATORS);
-
 
4027
 
-
 
4028
		len = strcspn(ptr, SEPARATORS);
-
 
4029
		if (!len)
-
 
4030
			break;
-
 
4031
		memset(&ss, 0, sizeof(ss));
-
 
4032
 
-
 
4033
		if (strncount(ptr, len, ':') >= 2) {
-
 
4034
			struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&ss;
-
 
4035
			struct sockaddr_in6 *sout = (struct sockaddr_in6 *)&sbind;
-
 
4036
			const char *c = ptr;
-
 
4037
			int clen = len;
-
 
4038
 
-
 
4039
			sin6->sin6_family = AF_INET6;
-
 
4040
			sin6->sin6_port = htons(2055);
-
 
4041
			if (*c == '[') {
-
 
4042
				++c;
-
 
4043
				--clen;
-
 
4044
			}
-
 
4045
			succ = in6_pton(c, clen, (u8 *)&sin6->sin6_addr, -1, &end);
-
 
4046
			if (succ && *ptr == '[' && *end == ']')
-
 
4047
				++end;
-
 
4048
			if (succ &&
-
 
4049
			    (*end == ':' || *end == '.' || *end == 'p' || *end == '#'))
-
 
4050
				sin6->sin6_port = htons(simple_strtoul(++end, (char **)&end, 0));
-
 
4051
			if (succ && *end == '@') {
-
 
4052
				++end;
-
 
4053
				sout->sin6_family = AF_INET6;
-
 
4054
				sout->sin6_port   = 0;
-
 
4055
				succ = in6_pton(end, strcspn(end, SEPARATORS), (u8 *)&sout->sin6_addr, -1, &end);
-
 
4056
			}
-
 
4057
		} else {
-
 
4058
			struct sockaddr_in *sin  = (struct sockaddr_in *)&ss;
-
 
4059
			struct sockaddr_in *sout = (struct sockaddr_in *)&sbind;
-
 
4060
 
-
 
4061
			sin->sin_family = AF_INET;
-
 
4062
			sin->sin_port = htons(2055);
-
 
4063
			succ = in4_pton(ptr, len, (u8 *)&sin->sin_addr, -1, &end);
-
 
4064
			if (succ && *end == ':')
-
 
4065
				sin->sin_port = htons(simple_strtoul(++end, (char **)&end, 0));
-
 
4066
			if (succ && *end == '@') {
-
 
4067
				++end;
-
 
4068
				sout->sin_family = AF_INET;
-
 
4069
				sout->sin_port   = 0;
-
 
4070
				succ = in4_pton(end, strcspn(end, SEPARATORS), (u8 *)&sout->sin_addr, -1, &end);
-
 
4071
			}
-
 
4072
		}
-
 
4073
		if (succ && *end == '%') {
-
 
4074
			++end;
-
 
4075
			snprintf(name, sizeof(name), "%.*s", (int)strcspn(end, SEPARATORS), end);
-
 
4076
		}
-
 
4077
		if (!succ) {
-
 
4078
			printk(KERN_ERR "ipt_NETFLOW: can't parse destination: %.*s\n",
-
 
4079
			    len, ptr);
-
 
4080
			continue;
-
 
4081
		}
-
 
4082
 
-
 
4083
		if (!(usock = vmalloc(sizeof(*usock)))) {
-
 
4084
			printk(KERN_ERR "ipt_NETFLOW: can't vmalloc socket\n");
-
 
4085
			return -ENOMEM;
-
 
4086
		}
-
 
4087
		memset(usock, 0, sizeof(*usock));
-
 
4088
		usock->addr  = ss;
-
 
4089
		usock->saddr = sbind;
-
 
4090
		memcpy(usock->sdev, name, sizeof(usock->sdev));
-
 
4091
		usock_connect(usock, 0);
-
 
4092
		add_usock(usock);
-
 
4093
	}
-
 
4094
	return 0;
-
 
4095
}
-
 
4096
 
-
 
4097
#ifdef ENABLE_AGGR
-
 
4098
static void aggregation_remove(struct list_head *list)
-
 
4099
{
-
 
4100
	write_lock_bh(&aggr_lock);
-
 
4101
	while (!list_empty(list)) {
-
 
4102
		struct netflow_aggr_n *aggr; /* match netflow_aggr_p too */
-
 
4103
 
-
 
4104
		aggr = list_entry(list->next, struct netflow_aggr_n, list);
-
 
4105
		list_del(&aggr->list);
-
 
4106
		write_unlock_bh(&aggr_lock);
-
 
4107
		vfree(aggr);
-
 
4108
		write_lock_bh(&aggr_lock);
-
 
4109
	}
-
 
4110
	write_unlock_bh(&aggr_lock);
-
 
4111
}
-
 
4112
 
-
 
4113
static int add_aggregation(char *ptr)
-
 
4114
{
-
 
4115
	struct netflow_aggr_n *aggr_n, *aggr, *tmp;
-
 
4116
	struct netflow_aggr_p *aggr_p;
-
 
4117
	LIST_HEAD(new_aggr_n_list);
-
 
4118
	LIST_HEAD(new_aggr_p_list);
-
 
4119
	LIST_HEAD(old_aggr_list);
-
 
4120
 
-
 
4121
	while (ptr && *ptr) {
-
 
4122
		unsigned char ip[4];
-
 
4123
		unsigned int mask;
-
 
4124
		unsigned int port1, port2;
-
 
4125
		unsigned int aggr_to;
-
 
4126
 
-
 
4127
		ptr += strspn(ptr, SEPARATORS);
-
 
4128
 
-
 
4129
		if (sscanf(ptr, "%hhu.%hhu.%hhu.%hhu/%u=%u",
-
 
4130
			   ip, ip + 1, ip + 2, ip + 3, &mask, &aggr_to) == 6) {
-
 
4131
 
-
 
4132
			if (!(aggr_n = vmalloc(sizeof(*aggr_n)))) {
-
 
4133
				printk(KERN_ERR "ipt_NETFLOW: can't vmalloc aggr\n");
-
 
4134
				return -ENOMEM;
-
 
4135
			}
-
 
4136
			memset(aggr_n, 0, sizeof(*aggr_n));
-
 
4137
 
-
 
4138
			aggr_n->mask = bits2mask(mask);
-
 
4139
			aggr_n->addr = ntohl(*(__be32 *)ip) & aggr_n->mask;
-
 
4140
			aggr_n->aggr_mask = bits2mask(aggr_to);
-
 
4141
			aggr_n->prefix = mask;
-
 
4142
			printk(KERN_INFO "ipt_NETFLOW: add aggregation [%u.%u.%u.%u/%u=%u]\n",
-
 
4143
			       HIPQUAD(aggr_n->addr), mask, aggr_to);
-
 
4144
			list_add_tail(&aggr_n->list, &new_aggr_n_list);
-
 
4145
 
-
 
4146
		} else if (sscanf(ptr, "%u-%u=%u", &port1, &port2, &aggr_to) == 3 ||
-
 
4147
			   sscanf(ptr, "%u=%u", &port2, &aggr_to) == 2) {
-
 
4148
 
-
 
4149
			if (!(aggr_p = vmalloc(sizeof(*aggr_p)))) {
-
 
4150
				printk(KERN_ERR "ipt_NETFLOW: can't vmalloc aggr\n");
-
 
4151
				return -ENOMEM;
-
 
4152
			}
-
 
4153
			memset(aggr_p, 0, sizeof(*aggr_p));
-
 
4154
 
-
 
4155
			aggr_p->port1 = port1;
-
 
4156
			aggr_p->port2 = port2;
-
 
4157
			aggr_p->aggr_port = aggr_to;
-
 
4158
			printk(KERN_INFO "ipt_NETFLOW: add aggregation [%u-%u=%u]\n",
-
 
4159
			       port1, port2, aggr_to);
-
 
4160
			list_add_tail(&aggr_p->list, &new_aggr_p_list);
-
 
4161
		} else {
-
 
4162
			printk(KERN_ERR "ipt_NETFLOW: bad aggregation rule: %s (ignoring)\n", ptr);
-
 
4163
			break;
-
 
4164
		}
-
 
4165
 
-
 
4166
		ptr = strpbrk(ptr, SEPARATORS);
-
 
4167
	}
-
 
4168
 
-
 
4169
	/* swap lists */
-
 
4170
	write_lock_bh(&aggr_lock);
-
 
4171
	list_for_each_entry_safe(aggr, tmp, &aggr_n_list, list)
-
 
4172
		list_move(&aggr->list, &old_aggr_list);
-
 
4173
	list_for_each_entry_safe(aggr, tmp, &aggr_p_list, list)
-
 
4174
		list_move(&aggr->list, &old_aggr_list);
-
 
4175
 
-
 
4176
	list_for_each_entry_safe(aggr, tmp, &new_aggr_n_list, list)
-
 
4177
		list_move_tail(&aggr->list, &aggr_n_list);
-
 
4178
	list_for_each_entry_safe(aggr, tmp, &new_aggr_p_list, list)
-
 
4179
		list_move_tail(&aggr->list, &aggr_p_list);
-
 
4180
	write_unlock_bh(&aggr_lock);
-
 
4181
	aggregation_remove(&old_aggr_list);
-
 
4182
	return 0;
-
 
4183
}
-
 
4184
#endif
-
 
4185
 
-
 
4186
#ifdef SAMPLING_HASH
-
 
4187
static uint32_t hash_seed;
-
 
4188
#define HASH_SEED hash_seed
-
 
4189
#else
-
 
4190
#define HASH_SEED 0
-
 
4191
#endif
-
 
4192
static inline u_int32_t __hash_netflow(const struct ipt_netflow_tuple *tuple)
-
 
4193
{
-
 
4194
	return murmur3(tuple, sizeof(struct ipt_netflow_tuple), HASH_SEED);
-
 
4195
}
-
 
4196
 
-
 
4197
static inline u_int32_t hash_netflow(const struct ipt_netflow_tuple *tuple)
-
 
4198
{
-
 
4199
	return __hash_netflow(tuple) % htable_size;
-
 
4200
}
-
 
4201
 
-
 
4202
static struct ipt_netflow *
-
 
4203
ipt_netflow_find(const struct ipt_netflow_tuple *tuple, const unsigned int hash)
-
 
4204
{
-
 
4205
	struct ipt_netflow *nf;
-
 
4206
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
-
 
4207
	struct hlist_node *pos;
-
 
4208
#endif
-
 
4209
 
-
 
4210
	compat_hlist_for_each_entry(nf, pos, &htable[hash], hlist) {
-
 
4211
		if (ipt_netflow_tuple_equal(tuple, &nf->tuple) &&
-
 
4212
		    nf->nr_bytes < FLOW_FULL_WATERMARK) {
-
 
4213
			NETFLOW_STAT_INC(found);
-
 
4214
			return nf;
-
 
4215
		}
-
 
4216
		NETFLOW_STAT_INC(searched);
-
 
4217
	}
-
 
4218
	NETFLOW_STAT_INC(notfound);
-
 
4219
	return NULL;
-
 
4220
}
-
 
4221
 
-
 
4222
static struct hlist_head *alloc_hashtable(const int size)
-
 
4223
{
-
 
4224
	struct hlist_head *hash;
-
 
4225
 
-
 
4226
	hash = vmalloc(sizeof(struct hlist_head) * size);
-
 
4227
	if (hash) {
-
 
4228
		int i;
-
 
4229
 
-
 
4230
		for (i = 0; i < size; i++)
-
 
4231
			INIT_HLIST_HEAD(&hash[i]);
-
 
4232
	} else
-
 
4233
		printk(KERN_ERR "ipt_NETFLOW: unable to vmalloc hash table.\n");
-
 
4234
 
-
 
4235
	return hash;
-
 
4236
}
-
 
4237
 
-
 
4238
static int set_hashsize(int new_size)
-
 
4239
{
-
 
4240
	struct hlist_head *new_hash, *old_hash;
-
 
4241
	struct ipt_netflow *nf, *tmp;
-
 
4242
	LIST_HEAD(all_list);
-
 
4243
	int i;
-
 
4244
 
-
 
4245
	if (new_size < LOCK_COUNT)
-
 
4246
		new_size = LOCK_COUNT;
-
 
4247
	printk(KERN_INFO "ipt_NETFLOW: allocating new hash table %u -> %u buckets\n",
-
 
4248
	       htable_size, new_size);
-
 
4249
	new_hash = alloc_hashtable(new_size);
-
 
4250
	if (!new_hash)
-
 
4251
		return -ENOMEM;
-
 
4252
 
-
 
4253
	/* rehash */
-
 
4254
	write_lock_bh(&htable_rwlock);
-
 
4255
	old_hash = htable;
-
 
4256
	htable = new_hash;
-
 
4257
	htable_size = new_size;
-
 
4258
	for (i = 0; i < LOCK_COUNT; i++) {
-
 
4259
		struct stripe_entry *stripe = &htable_stripes[i];
-
 
4260
		spin_lock(&stripe->lock);
-
 
4261
		list_splice_init(&stripe->list, &all_list);
-
 
4262
		spin_unlock(&stripe->lock);
-
 
4263
	}
-
 
4264
	list_for_each_entry_safe(nf, tmp, &all_list, flows_list) {
-
 
4265
		unsigned int hash;
-
 
4266
		struct stripe_entry *stripe;
-
 
4267
 
-
 
4268
		hash = hash_netflow(&nf->tuple);
-
 
4269
		stripe = &htable_stripes[hash & LOCK_COUNT_MASK];
-
 
4270
		spin_lock(&stripe->lock);
-
 
4271
		list_move_tail(&nf->flows_list, &stripe->list);
-
 
4272
		hlist_add_head(&nf->hlist, &htable[hash]);
-
 
4273
		spin_unlock(&stripe->lock);
-
 
4274
	}
-
 
4275
	write_unlock_bh(&htable_rwlock);
-
 
4276
	vfree(old_hash);
-
 
4277
 
-
 
4278
	return 0;
-
 
4279
}
-
 
4280
 
-
 
4281
static struct ipt_netflow *
-
 
4282
ipt_netflow_alloc(const struct ipt_netflow_tuple *tuple)
-
 
4283
{
-
 
4284
	struct ipt_netflow *nf;
-
 
4285
	long count;
-
 
4286
 
-
 
4287
	nf = kmem_cache_alloc(ipt_netflow_cachep, GFP_ATOMIC);
-
 
4288
	if (!nf) {
-
 
4289
		printk(KERN_ERR "ipt_NETFLOW: Can't allocate flow.\n");
-
 
4290
		return NULL;
-
 
4291
	}
-
 
4292
 
-
 
4293
	memset(nf, 0, sizeof(*nf));
-
 
4294
	nf->tuple = *tuple;
-
 
4295
 
-
 
4296
	count = atomic_inc_return(&ipt_netflow_count);
-
 
4297
	if (count > peakflows) {
-
 
4298
		peakflows = count;
-
 
4299
		peakflows_at = jiffies;
-
 
4300
	}
-
 
4301
 
-
 
4302
	return nf;
-
 
4303
}
-
 
4304
 
-
 
4305
static void ipt_netflow_free(struct ipt_netflow *nf)
-
 
4306
{
-
 
4307
	if (IS_DUMMY_FLOW(nf))
-
 
4308
		return;
-
 
4309
	atomic_dec(&ipt_netflow_count);
-
 
4310
	kmem_cache_free(ipt_netflow_cachep, nf);
-
 
4311
}
-
 
4312
 
-
 
4313
/* cook pdu, send, and clean */
-
 
4314
/* only called in scan worker path */
-
 
4315
static void netflow_export_pdu_v5(void)
-
 
4316
{
-
 
4317
	struct timeval tv;
-
 
4318
	int pdusize;
-
 
4319
 
-
 
4320
	if (!pdu_data_records)
-
 
4321
		return;
-
 
4322
 
-
 
4323
	if (debug > 1)
-
 
4324
		printk(KERN_INFO "netflow_export_pdu_v5 with %d records\n", pdu_data_records);
-
 
4325
 
-
 
4326
	pdu.v5.version		= htons(5);
-
 
4327
	pdu.v5.nr_records	= htons(pdu_data_records);
-
 
4328
	pdu.v5.ts_uptime	= htonl(jiffies_to_msecs(jiffies));
-
 
4329
	do_gettimeofday(&tv);
-
 
4330
	pdu.v5.ts_usecs		= htonl(tv.tv_sec);
-
 
4331
	pdu.v5.ts_unsecs	= htonl(tv.tv_usec);
-
 
4332
	pdu.v5.seq		= htonl(pdu_seq);
-
 
4333
	//pdu.v5.eng_type	= 0;
-
 
4334
	pdu.v5.eng_id		= (__u8)engine_id;
-
 
4335
#ifdef ENABLE_SAMPLER
-
 
4336
	pdu.v5.sampling		= htons(sampler_nf_v5());
-
 
4337
#endif
-
 
4338
	pdusize = NETFLOW5_HEADER_SIZE + sizeof(struct netflow5_record) * pdu_data_records;
-
 
4339
 
-
 
4340
	netflow_sendmsg(&pdu.v5, pdusize);
-
 
4341
 
-
 
4342
	pdu_packets = 0;
-
 
4343
	pdu_traf    = 0;
-
 
4344
 
-
 
4345
	pdu_seq += pdu_data_records;
-
 
4346
	pdu_count++;
-
 
4347
	pdu_flow_records = pdu_data_records = 0;
-
 
4348
}
-
 
4349
 
-
 
4350
/* only called in scan worker path */
-
 
4351
static void netflow_export_flow_v5(struct ipt_netflow *nf)
-
 
4352
{
-
 
4353
	struct netflow5_record *rec;
-
 
4354
 
-
 
4355
	if (unlikely(debug > 2))
-
 
4356
		printk(KERN_INFO "adding flow to export (%d)\n", pdu_data_records);
-
 
4357
 
-
 
4358
	pdu_packets += nf->nr_packets;
-
 
4359
	pdu_traf += nf->nr_bytes;
-
 
4360
	pdu_ts_mod = jiffies;
-
 
4361
	rec = &pdu.v5.flow[pdu_data_records++];
-
 
4362
	pdu_flow_records++;
-
 
4363
 
-
 
4364
	/* make V5 flow record */
-
 
4365
	rec->s_addr	= nf->tuple.src.ip;
-
 
4366
	rec->d_addr	= nf->tuple.dst.ip;
-
 
4367
	rec->nexthop	= nf->nh.ip;
-
 
4368
#ifdef SNMP_RULES
-
 
4369
	rec->i_ifc	= htons(nf->i_ifcr);
-
 
4370
	rec->o_ifc	= htons(nf->o_ifcr);
-
 
4371
#else
-
 
4372
	rec->i_ifc	= htons(nf->tuple.i_ifc);
-
 
4373
	rec->o_ifc	= htons(nf->o_ifc);
-
 
4374
#endif
-
 
4375
	rec->nr_packets = htonl(nf->nr_packets);
-
 
4376
	rec->nr_octets	= htonl(nf->nr_bytes);
-
 
4377
	rec->first_ms	= htonl(jiffies_to_msecs(nf->nf_ts_first));
-
 
4378
	rec->last_ms	= htonl(jiffies_to_msecs(nf->nf_ts_last));
-
 
4379
	rec->s_port	= nf->tuple.s_port;
-
 
4380
	rec->d_port	= nf->tuple.d_port;
-
 
4381
	//rec->reserved	= 0; /* pdu is always zeroized for v5 in netflow_switch_version */
-
 
4382
	rec->tcp_flags	= nf->tcp_flags;
-
 
4383
	rec->protocol	= nf->tuple.protocol;
-
 
4384
	rec->tos	= nf->tuple.tos;
-
 
4385
#ifdef CONFIG_NF_NAT_NEEDED
-
 
4386
	rec->s_as	= nf->s_as;
-
 
4387
	rec->d_as	= nf->d_as;
-
 
4388
#endif
-
 
4389
	rec->s_mask	= nf->s_mask;
-
 
4390
	rec->d_mask	= nf->d_mask;
-
 
4391
	//rec->padding	= 0;
-
 
4392
	ipt_netflow_free(nf);
-
 
4393
 
-
 
4394
	if (pdu_data_records == NETFLOW5_RECORDS_MAX)
-
 
4395
		netflow_export_pdu_v5();
-
 
4396
}
-
 
4397
 
-
 
4398
/* pdu is initially blank, export current pdu, and prepare next for filling. */
-
 
4399
static void netflow_export_pdu_v9(void)
-
 
4400
{
-
 
4401
	struct timeval tv;
-
 
4402
	int pdusize;
-
 
4403
 
-
 
4404
	if (pdu_data_used <= pdu.v9.data)
-
 
4405
		return;
-
 
4406
 
-
 
4407
	if (debug > 1)
-
 
4408
		printk(KERN_INFO "netflow_export_pdu_v9 with %d records\n",
-
 
4409
		    pdu_data_records + pdu_tpl_records);
-
 
4410
 
-
 
4411
	pdu.v9.version		= htons(9);
-
 
4412
	pdu.v9.nr_records	= htons(pdu_data_records + pdu_tpl_records);
-
 
4413
	pdu.v9.sys_uptime_ms	= htonl(jiffies_to_msecs(jiffies));
-
 
4414
	do_gettimeofday(&tv);
-
 
4415
	pdu.v9.export_time_s	= htonl(tv.tv_sec);
-
 
4416
	pdu.v9.seq		= htonl(pdu_seq);
-
 
4417
	pdu.v9.source_id	= htonl(engine_id);
-
 
4418
 
-
 
4419
	pdusize = pdu_data_used - (unsigned char *)&pdu.v9;
-
 
4420
 
-
 
4421
	netflow_sendmsg(&pdu.v9, pdusize);
-
 
4422
 
-
 
4423
	pdu_packets = 0;
-
 
4424
	pdu_traf    = 0;
-
 
4425
 
-
 
4426
	pdu_seq++;
-
 
4427
	pdu_count++;
-
 
4428
	pdu_flow_records = pdu_data_records = pdu_tpl_records = 0;
-
 
4429
	pdu_data_used = pdu.v9.data;
-
 
4430
	pdu_flowset = NULL;
-
 
4431
}
-
 
4432
 
-
 
4433
static void netflow_export_pdu_ipfix(void)
-
 
4434
{
-
 
4435
	struct timeval tv;
-
 
4436
	int pdusize;
-
 
4437
 
-
 
4438
	if (pdu_data_used <= pdu.ipfix.data)
-
 
4439
		return;
-
 
4440
 
-
 
4441
	if (debug > 1)
-
 
4442
		printk(KERN_INFO "netflow_export_pduX with %d records\n",
-
 
4443
		    pdu_data_records);
-
 
4444
 
-
 
4445
	pdu.ipfix.version	= htons(10);
-
 
4446
	do_gettimeofday(&tv);
-
 
4447
	pdu.ipfix.export_time_s	= htonl(tv.tv_sec);
-
 
4448
	pdu.ipfix.seq		= htonl(pdu_seq);
-
 
4449
	pdu.ipfix.odomain_id	= htonl(engine_id);
-
 
4450
	pdusize = pdu_data_used - (unsigned char *)&pdu;
-
 
4451
	pdu.ipfix.length	= htons(pdusize);
-
 
4452
 
-
 
4453
	netflow_sendmsg(&pdu.ipfix, pdusize);
-
 
4454
 
-
 
4455
	pdu_packets = 0;
-
 
4456
	pdu_traf    = 0;
-
 
4457
 
-
 
4458
	pdu_seq += pdu_data_records;
-
 
4459
	pdu_count++;
-
 
4460
	pdu_flow_records = pdu_data_records = pdu_tpl_records = 0;
-
 
4461
	pdu_data_used = pdu.ipfix.data;
-
 
4462
	pdu_flowset = NULL;
-
 
4463
}
-
 
4464
 
-
 
4465
static inline int pdu_have_space(const size_t size)
-
 
4466
{
-
 
4467
	return ((pdu_data_used + size) <= pdu_high_wm);
-
 
4468
}
-
 
4469
 
-
 
4470
static inline unsigned char *pdu_grab_space(const size_t size)
-
 
4471
{
-
 
4472
	unsigned char *ptr = pdu_data_used;
-
 
4473
	pdu_data_used += size;
-
 
4474
	return ptr;
-
 
4475
}
-
 
4476
 
-
 
4477
static inline void pdu_rewind_space(const size_t size)
-
 
4478
{
-
 
4479
	pdu_data_used -= size;
-
 
4480
}
-
 
4481
 
-
 
4482
/* allocate data space in pdu, or export (reallocate) and fail. */
-
 
4483
static inline unsigned char *pdu_alloc_fail_export(const size_t size)
-
 
4484
{
-
 
4485
	if (unlikely(!pdu_have_space(size))) {
-
 
4486
		netflow_export_pdu();
-
 
4487
		return NULL;
-
 
4488
	}
-
 
4489
	return pdu_grab_space(size);
-
 
4490
}
-
 
4491
 
-
 
4492
/* doesn't fail, but can provide empty pdu. */
-
 
4493
static unsigned char *pdu_alloc_export(const size_t size)
-
 
4494
{
-
 
4495
	return pdu_alloc_fail_export(size) ?: pdu_grab_space(size);
-
 
4496
}
-
 
4497
 
-
 
4498
/* global table of sizes of template field types */
-
 
4499
#define two(id, a, b, len)	[id] = len,
-
 
4500
#define one(id, a, len)		[id] = len,
-
 
4501
static u_int8_t tpl_element_sizes[] = {
-
 
4502
	Elements
-
 
4503
};
-
 
4504
#undef two
-
 
4505
#undef one
-
 
4506
 
-
 
4507
#define TEMPLATES_HASH_BSIZE	8
-
 
4508
#define TEMPLATES_HASH_SIZE	(1<<TEMPLATES_HASH_BSIZE)
-
 
4509
static struct hlist_head templates_hash[TEMPLATES_HASH_SIZE];
-
 
4510
 
-
 
4511
struct base_template {
-
 
4512
	int length; /* number of elements in template */
-
 
4513
	u_int16_t types[]; /* {type, size} pairs */
-
 
4514
};
-
 
4515
 
-
 
4516
/* Data Templates */
-
 
4517
#define BTPL_BASE9	0x00000001	/* netflow base stat */
-
 
4518
#define BTPL_BASEIPFIX	0x00000002	/* ipfix base stat */
-
 
4519
#define BTPL_IP4	0x00000004	/* IPv4 */
-
 
4520
#define BTPL_MASK4	0x00000008	/* Aggregated */
-
 
4521
#define BTPL_PORTS	0x00000010	/* UDP&TCP */
-
 
4522
#define BTPL_IP6	0x00000020	/* IPv6 */
-
 
4523
#define BTPL_ICMP9	0x00000040	/* ICMP (for V9) */
-
 
4524
#define BTPL_ICMPX4	0x00000080	/* ICMP IPv4 (for IPFIX) */
-
 
4525
#define BTPL_ICMPX6	0x00000100	/* ICMP IPv6 (for IPFIX) */
-
 
4526
#define BTPL_IGMP	0x00000200	/* IGMP */
-
 
4527
#define BTPL_IPSEC	0x00000400	/* AH&ESP */
-
 
4528
#define BTPL_NAT4	0x00000800	/* NAT IPv4 */
-
 
4529
#define BTPL_LABEL6	0x00001000	/* IPv6 flow label */
-
 
4530
#define BTPL_IP4OPTIONS	0x00002000	/* IPv4 Options */
-
 
4531
#define BTPL_IP6OPTIONS	0x00004000	/* IPv6 Options */
-
 
4532
#define BTPL_TCPOPTIONS	0x00008000	/* TCP Options */
-
 
4533
#define BTPL_MAC	0x00010000	/* MAC addresses */
-
 
4534
#define BTPL_VLAN9	0x00020000	/* outer VLAN for v9 */
-
 
4535
#define BTPL_VLANX	0x00040000	/* outer VLAN for IPFIX */
-
 
4536
#define BTPL_VLANI	0x00080000	/* inner VLAN (IPFIX) */
-
 
4537
#define BTPL_ETHERTYPE	0x00100000	/* ethernetType */
-
 
4538
#define BTPL_DIRECTION	0x00200000	/* flowDirection */
-
 
4539
#define BTPL_SAMPLERID	0x00400000	/* samplerId (v9) */
-
 
4540
#define BTPL_SELECTORID	0x00800000	/* selectorId (IPFIX) */
-
 
4541
#define BTPL_MPLS	0x01000000	/* MPLS stack */
-
 
4542
#define BTPL_OPTION	0x80000000	/* Options Template */
-
 
4543
#define BTPL_MAX	32
-
 
4544
/* Options Templates */
-
 
4545
#define OTPL(x) (BTPL_OPTION | x)
-
 
4546
#define OTPL_SYSITIME	OTPL(1)		/* systemInitTimeMilliseconds */
-
 
4547
#define OTPL_MPSTAT	OTPL(2)		/* The Metering Process Statistics (rfc5101) */
-
 
4548
#define OTPL_MPRSTAT	OTPL(3)		/* The Metering Process Reliability Statistics */
-
 
4549
#define OTPL_EPRSTAT	OTPL(4)		/* The Exporting Process Reliability Statistics */
-
 
4550
#define OTPL_SAMPLER	OTPL(5)		/* Flow Sampler for v9 */
-
 
4551
#define OTPL_SEL_RAND	OTPL(6)		/* Random Flow Selector for IPFIX */
-
 
4552
#define OTPL_SEL_COUNT	OTPL(7)		/* Systematic count-based Flow Selector for IPFIX */
-
 
4553
#define OTPL_SEL_STAT	OTPL(8)		/* rfc7014 */
-
 
4554
#define OTPL_SEL_STATH	OTPL(9)		/* OTPL_SEL_STAT, except selectorIDTotalFlowsObserved */
-
 
4555
#define OTPL_IFNAMES	OTPL(10)
-
 
4556
 
-
 
4557
static struct base_template template_base_9 = {
-
 
4558
	.types = {
-
 
4559
		INPUT_SNMP,
-
 
4560
		OUTPUT_SNMP,
-
 
4561
#ifdef ENABLE_PHYSDEV
-
 
4562
		ingressPhysicalInterface,
-
 
4563
		egressPhysicalInterface,
-
 
4564
#endif
-
 
4565
		IN_PKTS,
-
 
4566
		IN_BYTES,
-
 
4567
		FIRST_SWITCHED,
-
 
4568
		LAST_SWITCHED,
-
 
4569
		PROTOCOL,
-
 
4570
		TOS,
-
 
4571
		0
-
 
4572
	}
-
 
4573
};
-
 
4574
static struct base_template template_base_ipfix = {
-
 
4575
	.types = {
-
 
4576
		ingressInterface,
-
 
4577
		egressInterface,
-
 
4578
#ifdef ENABLE_PHYSDEV
-
 
4579
		ingressPhysicalInterface,
-
 
4580
		egressPhysicalInterface,
-
 
4581
#endif
-
 
4582
		packetDeltaCount,
-
 
4583
		octetDeltaCount,
-
 
4584
		flowStartMilliseconds,
-
 
4585
		flowEndMilliseconds,
-
 
4586
		protocolIdentifier,
-
 
4587
		ipClassOfService,
-
 
4588
		flowEndReason,
-
 
4589
		0
-
 
4590
	}
-
 
4591
};
-
 
4592
#ifdef ENABLE_MAC
-
 
4593
static struct base_template template_mac_ipfix = {
-
 
4594
	.types = {
-
 
4595
		destinationMacAddress,
-
 
4596
		sourceMacAddress,
-
 
4597
		0
-
 
4598
	}
-
 
4599
};
-
 
4600
#endif
-
 
4601
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
4602
static struct base_template template_ethertype = {
-
 
4603
	.types = { ethernetType, 0 }
-
 
4604
};
-
 
4605
#endif
-
 
4606
#ifdef ENABLE_VLAN
-
 
4607
static struct base_template template_vlan_v9 = {
-
 
4608
	.types = { SRC_VLAN, 0 }
-
 
4609
};
-
 
4610
/* IPFIX is different from v9, see rfc7133. */
-
 
4611
static struct base_template template_vlan_ipfix = {
-
 
4612
	.types = {
-
 
4613
		dot1qVlanId,
-
 
4614
		dot1qPriority,
-
 
4615
		0
-
 
4616
	}
-
 
4617
};
-
 
4618
static struct base_template template_vlan_inner = {
-
 
4619
	.types = {
-
 
4620
		dot1qCustomerVlanId,
-
 
4621
		dot1qCustomerPriority,
-
 
4622
		0
-
 
4623
	}
-
 
4624
};
-
 
4625
#endif
-
 
4626
#ifdef MPLS_DEPTH
-
 
4627
static struct base_template template_mpls = {
-
 
4628
	.types = {
-
 
4629
		mplsTopLabelTTL,
-
 
4630
		/* do not just add element here, becasue this array
-
 
4631
		 * is truncated in ipt_netflow_init() */
-
 
4632
#define MPLS_LABELS_BASE_INDEX 1
-
 
4633
		MPLS_LABEL_1,
-
 
4634
		MPLS_LABEL_2,
-
 
4635
		MPLS_LABEL_3,
-
 
4636
		MPLS_LABEL_4,
-
 
4637
		MPLS_LABEL_5,
-
 
4638
		MPLS_LABEL_6,
-
 
4639
		MPLS_LABEL_7,
-
 
4640
		MPLS_LABEL_8,
-
 
4641
		MPLS_LABEL_9,
-
 
4642
		MPLS_LABEL_10,
-
 
4643
		0
-
 
4644
	}
-
 
4645
};
-
 
4646
#endif
-
 
4647
#ifdef ENABLE_DIRECTION
-
 
4648
static struct base_template template_direction = {
-
 
4649
	.types = { DIRECTION, 0 }
-
 
4650
};
-
 
4651
#endif
-
 
4652
static struct base_template template_ipv4 = {
-
 
4653
	.types = {
-
 
4654
		IPV4_SRC_ADDR,
-
 
4655
		IPV4_DST_ADDR,
-
 
4656
		IPV4_NEXT_HOP,
-
 
4657
		0
-
 
4658
	}
-
 
4659
};
-
 
4660
static struct base_template template_options4 = {
-
 
4661
	.types = { ipv4Options, 0 }
-
 
4662
};
-
 
4663
static struct base_template template_tcpoptions = {
-
 
4664
	.types = { tcpOptions, 0 }
-
 
4665
};
-
 
4666
static struct base_template template_ipv6 = {
-
 
4667
	.types = {
-
 
4668
		IPV6_SRC_ADDR,
-
 
4669
		IPV6_DST_ADDR,
-
 
4670
		IPV6_NEXT_HOP,
-
 
4671
		0
-
 
4672
	}
-
 
4673
};
-
 
4674
static struct base_template template_options6 = {
-
 
4675
	.types = { IPV6_OPTION_HEADERS, 0 }
-
 
4676
};
-
 
4677
static struct base_template template_label6 = {
-
 
4678
	.types = { IPV6_FLOW_LABEL, 0 }
-
 
4679
};
-
 
4680
static struct base_template template_ipv4_mask = {
-
 
4681
	.types = {
-
 
4682
		SRC_MASK,
-
 
4683
		DST_MASK,
-
 
4684
		0
-
 
4685
	}
-
 
4686
};
-
 
4687
static struct base_template template_ports = {
-
 
4688
	.types = {
-
 
4689
		L4_SRC_PORT,
-
 
4690
		L4_DST_PORT,
-
 
4691
		TCP_FLAGS,
-
 
4692
		0
-
 
4693
	}
-
 
4694
};
-
 
4695
static struct base_template template_icmp_v9 = {
-
 
4696
	.types = {
-
 
4697
		L4_SRC_PORT,	/* dummy (required by some collector(s) to
-
 
4698
				   recognize ICMP flows) */
-
 
4699
		L4_DST_PORT,	/* actually used in V9 world instead of
-
 
4700
				   ICMP_TYPE(32), disregarding docs */
-
 
4701
		0
-
 
4702
	}
-
 
4703
};
-
 
4704
static struct base_template template_icmp_ipv4 = {
-
 
4705
	.types = { icmpTypeCodeIPv4, 0 }
-
 
4706
};
-
 
4707
static struct base_template template_icmp_ipv6 = {
-
 
4708
	.types = { icmpTypeCodeIPv6, 0 }
-
 
4709
};
-
 
4710
static struct base_template template_igmp = {
-
 
4711
	.types = { MUL_IGMP_TYPE, 0 }
-
 
4712
};
-
 
4713
static struct base_template template_ipsec = {
-
 
4714
	.types = { IPSecSPI, 0 }
-
 
4715
};
-
 
4716
static struct base_template template_nat4 = {
-
 
4717
	.types = {
-
 
4718
		observationTimeMilliseconds,
-
 
4719
		IPV4_SRC_ADDR,
-
 
4720
		IPV4_DST_ADDR,
-
 
4721
		postNATSourceIPv4Address,
-
 
4722
		postNATDestinationIPv4Address,
-
 
4723
		L4_SRC_PORT,
-
 
4724
		L4_DST_PORT,
-
 
4725
		postNAPTSourceTransportPort,
-
 
4726
		postNAPTDestinationTransportPort,
-
 
4727
		PROTOCOL,
-
 
4728
		natEvent,
-
 
4729
		0
-
 
4730
	}
-
 
4731
};
-
 
4732
 
-
 
4733
static struct base_template template_sys_init_time = {
-
 
4734
	.types = {
-
 
4735
		observationDomainId,
-
 
4736
 
-
 
4737
		/* ipfix does not report sys_uptime_ms like v9 does,
-
 
4738
		 * so this could be useful to detect system restart
-
 
4739
		 * (rfc5102), and conversion of flow times to absolute
-
 
4740
		 * time (rfc5153 4.7) */
-
 
4741
		systemInitTimeMilliseconds,
-
 
4742
 
-
 
4743
		/* this will let collector detect module version and
-
 
4744
		 * recompilation (by srcversion) */
-
 
4745
		observationDomainName,
-
 
4746
 
-
 
4747
		/* useful to detect module reload */
-
 
4748
		flowStartMilliseconds,
-
 
4749
		flowEndMilliseconds,
-
 
4750
		0
-
 
4751
	}
-
 
4752
};
-
 
4753
 
-
 
4754
/* http://tools.ietf.org/html/rfc5101#section-4 */
-
 
4755
/* The Metering Process Statistics Option Template */
-
 
4756
static struct base_template template_meter_stat = {
-
 
4757
	.types = {
-
 
4758
		observationDomainId,
-
 
4759
		exportedMessageTotalCount,
-
 
4760
		exportedFlowRecordTotalCount,
-
 
4761
		exportedOctetTotalCount,
-
 
4762
		observedFlowTotalCount,
-
 
4763
		0
-
 
4764
	}
-
 
4765
};
-
 
4766
/* The Metering Process Reliability Statistics Option Template */
-
 
4767
static struct base_template template_meter_rel_stat = {
-
 
4768
	.types = {
-
 
4769
		observationDomainId,
-
 
4770
		ignoredPacketTotalCount,
-
 
4771
		ignoredOctetTotalCount,
-
 
4772
		flowStartMilliseconds, /* sampling start time */
-
 
4773
		flowEndMilliseconds,
-
 
4774
		0
-
 
4775
	}
-
 
4776
};
-
 
4777
/* The Exporting Process Reliability Statistics Option Template */
-
 
4778
static struct base_template template_exp_rel_stat = {
-
 
4779
	.types = {
-
 
4780
		exportingProcessId,
-
 
4781
		notSentFlowTotalCount,
-
 
4782
		notSentPacketTotalCount,
-
 
4783
		notSentOctetTotalCount,
-
 
4784
		flowStartMilliseconds, /* sampling start time */
-
 
4785
		flowEndMilliseconds,
-
 
4786
		0
-
 
4787
	}
-
 
4788
};
-
 
4789
 
-
 
4790
#ifdef ENABLE_SAMPLER
-
 
4791
static struct base_template template_samplerid = {
-
 
4792
	.types = { FLOW_SAMPLER_ID, 0 }
-
 
4793
};
-
 
4794
static struct base_template template_selectorid = {
-
 
4795
	.types = { selectorId, 0 }
-
 
4796
};
-
 
4797
 
-
 
4798
/* sampler for v9 */
-
 
4799
static struct base_template template_sampler = {
-
 
4800
	.types = {
-
 
4801
		observationDomainId,
-
 
4802
		FLOW_SAMPLER_ID,
-
 
4803
		FLOW_SAMPLER_MODE,
-
 
4804
		FLOW_SAMPLER_RANDOM_INTERVAL,
-
 
4805
		0
-
 
4806
	}
-
 
4807
};
-
 
4808
/* sampler for ipfix */
-
 
4809
static struct base_template template_selector_systematic = {
-
 
4810
	.types = {
-
 
4811
		observationDomainId,
-
 
4812
		selectorId,
-
 
4813
		flowSelectorAlgorithm,
-
 
4814
		samplingFlowInterval,
-
 
4815
		samplingFlowSpacing,
-
 
4816
		0
-
 
4817
	}
-
 
4818
};
-
 
4819
static struct base_template template_selector_random = {
-
 
4820
	.types = {
-
 
4821
		observationDomainId,
-
 
4822
		selectorId,
-
 
4823
		flowSelectorAlgorithm,
-
 
4824
		samplingSize,
-
 
4825
		samplingPopulation,
-
 
4826
		0
-
 
4827
	}
-
 
4828
};
-
 
4829
static struct base_template template_selector_stat = {
-
 
4830
	.types = {
-
 
4831
		selectorId,
-
 
4832
		selectorIDTotalFlowsObserved,
-
 
4833
		selectorIDTotalFlowsSelected,
-
 
4834
		selectorIdTotalPktsObserved,
-
 
4835
		selectorIdTotalPktsSelected,
-
 
4836
		flowStartMilliseconds,
-
 
4837
		flowEndMilliseconds,
-
 
4838
		0
-
 
4839
	}
-
 
4840
};
-
 
4841
/* can't calc selectorIDTotalFlowsObserved for hash sampling,
-
 
4842
 * because dropped flows are not accounted */
-
 
4843
static struct base_template template_selector_stat_hash = {
-
 
4844
	.types = {
-
 
4845
		selectorId,
-
 
4846
		selectorIDTotalFlowsSelected,
-
 
4847
		selectorIdTotalPktsObserved,
-
 
4848
		selectorIdTotalPktsSelected,
-
 
4849
		flowStartMilliseconds,
-
 
4850
		flowEndMilliseconds,
-
 
4851
		0
-
 
4852
	}
-
 
4853
};
-
 
4854
#endif
-
 
4855
 
-
 
4856
static struct base_template template_interfaces = {
-
 
4857
	.types = {
-
 
4858
		observationDomainId,
-
 
4859
		INPUT_SNMP,
-
 
4860
		IF_NAME,
-
 
4861
		IF_DESC,
-
 
4862
		0
-
 
4863
	}
-
 
4864
};
-
 
4865
 
-
 
4866
struct data_template {
-
 
4867
	struct hlist_node hlist;
-
 
4868
	unsigned int tpl_key;
-
 
4869
 
-
 
4870
	char options;	/* is it Options Template */
-
 
4871
	short length;	/* number of elements in template */
-
 
4872
	short tpl_size;	/* whole size of template itself (with header), for alloc */
-
 
4873
	short rec_size;	/* size of one template record (w/o header) */
-
 
4874
	int template_id_n; /* uassigned from template_ids, network order. */
-
 
4875
	int		exported_cnt;
-
 
4876
	unsigned long	exported_ts; /* last exported (jiffies) */
-
 
4877
	u_int16_t fields[]; /* {type, size} pairs */
-
 
4878
} __attribute__ ((packed));
-
 
4879
 
-
 
4880
#define TPL_FIELD_NSIZE 4 /* one complete template field's network size */
-
 
4881
 
-
 
4882
static void free_templates(void)
-
 
4883
{
-
 
4884
	int i;
-
 
4885
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
-
 
4886
	struct hlist_node *pos;
-
 
4887
#endif
-
 
4888
	struct hlist_node *tmp;
-
 
4889
 
-
 
4890
	for (i = 0; i < TEMPLATES_HASH_SIZE; i++) {
-
 
4891
		struct hlist_head *thead = &templates_hash[i];
-
 
4892
		struct data_template *tpl;
-
 
4893
 
-
 
4894
		compat_hlist_for_each_entry_safe(tpl, pos, tmp, thead, hlist)
-
 
4895
			kfree(tpl);
-
 
4896
		INIT_HLIST_HEAD(thead);
-
 
4897
	}
-
 
4898
	tpl_count = 0;
-
 
4899
 
-
 
4900
	/* reinitialize template timeouts */
-
 
4901
	ts_sysinf_last = ts_stat_last = 0;
-
 
4902
#ifdef ENABLE_SAMPLER
-
 
4903
	ts_sampler_last = 0;
-
 
4904
#endif
-
 
4905
}
-
 
4906
 
-
 
4907
/* find old, or create new combined template from template key (tmask) */
-
 
4908
static struct data_template *get_template(const unsigned int tmask)
-
 
4909
{
-
 
4910
	struct base_template *tlist[BTPL_MAX];
-
 
4911
	struct data_template *tpl;
-
 
4912
	int tnum;
-
 
4913
	int length;
-
 
4914
	int i, j, k;
-
 
4915
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
-
 
4916
	struct hlist_node *pos;
-
 
4917
#endif
-
 
4918
	int hash = hash_long(tmask, TEMPLATES_HASH_BSIZE);
-
 
4919
 
-
 
4920
	compat_hlist_for_each_entry(tpl, pos, &templates_hash[hash], hlist)
-
 
4921
		if (tpl->tpl_key == tmask)
-
 
4922
			return tpl;
-
 
4923
 
-
 
4924
	tnum = 0;
-
 
4925
	/* assemble array of base_templates from template key */
-
 
4926
	/* NB: this should not have exporting protocol dependent checks */
-
 
4927
	if (tmask & BTPL_OPTION) {
-
 
4928
		switch (tmask) {
-
 
4929
		case OTPL_SYSITIME:
-
 
4930
			tlist[tnum++] = &template_sys_init_time;
-
 
4931
			break;
-
 
4932
		case OTPL_MPSTAT:
-
 
4933
			tlist[tnum++] = &template_meter_stat;
-
 
4934
			break;
-
 
4935
		case OTPL_MPRSTAT:
-
 
4936
			tlist[tnum++] = &template_meter_rel_stat;
-
 
4937
			break;
-
 
4938
		case OTPL_EPRSTAT:
-
 
4939
			tlist[tnum++] = &template_exp_rel_stat;
-
 
4940
			break;
-
 
4941
#ifdef ENABLE_SAMPLER
-
 
4942
		case OTPL_SAMPLER:
-
 
4943
			tlist[tnum++] = &template_sampler;
-
 
4944
			break;
-
 
4945
		case OTPL_SEL_RAND:
-
 
4946
			tlist[tnum++] = &template_selector_random;
-
 
4947
			break;
-
 
4948
		case OTPL_SEL_COUNT:
-
 
4949
			tlist[tnum++] = &template_selector_systematic;
-
 
4950
			break;
-
 
4951
		case OTPL_SEL_STAT:
-
 
4952
			tlist[tnum++] = &template_selector_stat;
-
 
4953
			break;
-
 
4954
		case OTPL_SEL_STATH:
-
 
4955
			tlist[tnum++] = &template_selector_stat_hash;
-
 
4956
			break;
-
 
4957
#endif
-
 
4958
		case OTPL_IFNAMES:
-
 
4959
			tlist[tnum++] = &template_interfaces;
-
 
4960
			break;
-
 
4961
		}
-
 
4962
	} else {
-
 
4963
		if (tmask & BTPL_IP4) {
-
 
4964
			tlist[tnum++] = &template_ipv4;
-
 
4965
			if (tmask & BTPL_IP4OPTIONS)
-
 
4966
				tlist[tnum++] = &template_options4;
-
 
4967
			if (tmask & BTPL_MASK4)
-
 
4968
				tlist[tnum++] = &template_ipv4_mask;
-
 
4969
			if (tmask & BTPL_ICMPX4)
-
 
4970
				tlist[tnum++] = &template_icmp_ipv4;
-
 
4971
		} else if (tmask & BTPL_IP6) {
-
 
4972
			tlist[tnum++] = &template_ipv6;
-
 
4973
			if (tmask & BTPL_LABEL6)
-
 
4974
				tlist[tnum++] = &template_label6;
-
 
4975
			if (tmask & BTPL_IP6OPTIONS)
-
 
4976
				tlist[tnum++] = &template_options6;
-
 
4977
			if (tmask & BTPL_ICMPX6)
-
 
4978
				tlist[tnum++] = &template_icmp_ipv6;
-
 
4979
		} else if (tmask & BTPL_NAT4)
-
 
4980
			tlist[tnum++] = &template_nat4;
-
 
4981
		if (tmask & BTPL_PORTS)
-
 
4982
			tlist[tnum++] = &template_ports;
-
 
4983
		else if (tmask & BTPL_ICMP9)
-
 
4984
			tlist[tnum++] = &template_icmp_v9;
-
 
4985
		if (tmask & BTPL_BASE9)
-
 
4986
			tlist[tnum++] = &template_base_9;
-
 
4987
		else if (tmask & BTPL_BASEIPFIX)
-
 
4988
			tlist[tnum++] = &template_base_ipfix;
-
 
4989
		if (tmask & BTPL_TCPOPTIONS)
-
 
4990
			tlist[tnum++] = &template_tcpoptions;
-
 
4991
		if (tmask & BTPL_IGMP)
-
 
4992
			tlist[tnum++] = &template_igmp;
-
 
4993
		if (tmask & BTPL_IPSEC)
-
 
4994
			tlist[tnum++] = &template_ipsec;
-
 
4995
#ifdef ENABLE_MAC
-
 
4996
		if (tmask & BTPL_MAC)
-
 
4997
			tlist[tnum++] = &template_mac_ipfix;
-
 
4998
#endif
-
 
4999
#ifdef ENABLE_VLAN
-
 
5000
		if (tmask & BTPL_VLAN9)
-
 
5001
			tlist[tnum++] = &template_vlan_v9;
-
 
5002
		else {
-
 
5003
			if (tmask & BTPL_VLANX)
-
 
5004
				tlist[tnum++] = &template_vlan_ipfix;
-
 
5005
			if (tmask & BTPL_VLANI)
-
 
5006
				tlist[tnum++] = &template_vlan_inner;
-
 
5007
		}
-
 
5008
#endif
-
 
5009
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
5010
		if (tmask & BTPL_ETHERTYPE)
-
 
5011
			tlist[tnum++] = &template_ethertype;
-
 
5012
#endif
-
 
5013
#ifdef MPLS_DEPTH
-
 
5014
		if (tmask & BTPL_MPLS)
-
 
5015
			tlist[tnum++] = &template_mpls;
-
 
5016
#endif
-
 
5017
#ifdef ENABLE_DIRECTION
-
 
5018
		if (tmask & BTPL_DIRECTION)
-
 
5019
			tlist[tnum++] = &template_direction;
-
 
5020
#endif
-
 
5021
#ifdef ENABLE_SAMPLER
-
 
5022
		if (tmask & BTPL_SAMPLERID)
-
 
5023
			tlist[tnum++] = &template_samplerid;
-
 
5024
		else if (tmask & BTPL_SELECTORID)
-
 
5025
			tlist[tnum++] = &template_selectorid;
-
 
5026
#endif
-
 
5027
	} /* !BTPL_OPTION */
-
 
5028
 
-
 
5029
	/* calculate resulting template length
-
 
5030
	 * and update base_template array lengths  */
-
 
5031
	length = 0;
-
 
5032
	for (i = 0; i < tnum; i++) {
-
 
5033
		if (!tlist[i]->length) {
-
 
5034
			for (k = 0; tlist[i]->types[k]; k++);
-
 
5035
			tlist[i]->length = k;
-
 
5036
		}
-
 
5037
		length += tlist[i]->length;
-
 
5038
	}
-
 
5039
	/* elements are [type, len] pairs + one termiantor */
-
 
5040
	tpl = kmalloc(sizeof(struct data_template) + (length * 2 + 1) * sizeof(u_int16_t), GFP_KERNEL);
-
 
5041
	if (!tpl) {
-
 
5042
		printk(KERN_ERR "ipt_NETFLOW: unable to kmalloc template (%#x).\n", tmask);
-
 
5043
		return NULL;
-
 
5044
	}
-
 
5045
	tpl->tpl_key = tmask;
-
 
5046
	tpl->options = (tmask & BTPL_OPTION) != 0;
-
 
5047
	if (tpl->options)
-
 
5048
		tpl->tpl_size = sizeof(struct flowset_opt_tpl_v9); /* ipfix is of the same size */
-
 
5049
	else
-
 
5050
		tpl->tpl_size = sizeof(struct flowset_template);
-
 
5051
	tpl->length = length;
-
 
5052
	tpl->rec_size = 0;
-
 
5053
	tpl->template_id_n = htons(template_ids++);
-
 
5054
	tpl->exported_cnt = 0;
-
 
5055
	tpl->exported_ts = 0;
-
 
5056
 
-
 
5057
	/* construct resulting data_template and fill lengths */
-
 
5058
	j = 0;
-
 
5059
	for (i = 0; i < tnum; i++) {
-
 
5060
		struct base_template *btpl = tlist[i];
-
 
5061
 
-
 
5062
		for (k = 0; k < btpl->length; k++) {
-
 
5063
			int size;
-
 
5064
			int type = btpl->types[k];
-
 
5065
 
-
 
5066
			tpl->fields[j++] = type;
-
 
5067
			size = tpl_element_sizes[type];
-
 
5068
			tpl->fields[j++] = size;
-
 
5069
			tpl->rec_size += size;
-
 
5070
		}
-
 
5071
		tpl->tpl_size += btpl->length * TPL_FIELD_NSIZE;
-
 
5072
	}
-
 
5073
	tpl->fields[j++] = 0;
-
 
5074
 
-
 
5075
	hlist_add_head(&tpl->hlist, &templates_hash[hash]);
-
 
5076
	tpl_count++;
-
 
5077
 
-
 
5078
	return tpl;
-
 
5079
}
-
 
5080
 
-
 
5081
static u_int16_t scope_ipfix_to_v9(const u_int16_t elem)
-
 
5082
{
-
 
5083
	switch (elem) {
-
 
5084
	case observationDomainId:
-
 
5085
	case meteringProcessId:
-
 
5086
	case exportingProcessId:
-
 
5087
		return V9_SCOPE_SYSTEM;
-
 
5088
	case ingressInterface:
-
 
5089
	case portId:
-
 
5090
		return V9_SCOPE_INTERFACE;
-
 
5091
	case observationPointId:
-
 
5092
	case LineCardId:
-
 
5093
		return V9_SCOPE_LINECARD;
-
 
5094
	case TemplateId:
-
 
5095
		return V9_SCOPE_TEMPLATE;
-
 
5096
	default:
-
 
5097
		return -1;
-
 
5098
	}
-
 
5099
}
-
 
5100
 
-
 
5101
/* add template of any type and version */
-
 
5102
static void pdu_add_template(struct data_template *tpl)
-
 
5103
{
-
 
5104
	__u8 *ptr;
-
 
5105
	struct flowset_template *ntpl;
-
 
5106
	__be16 *sptr, *fields;
-
 
5107
	size_t added_size = 0;
-
 
5108
 
-
 
5109
	/* for options template we also make sure there is enough
-
 
5110
	 * room in the packet for one record, with flowset header */
-
 
5111
	if (tpl->options)
-
 
5112
		added_size = sizeof(struct flowset_data) + tpl->rec_size;
-
 
5113
	ptr = pdu_alloc_export(tpl->tpl_size + added_size);
-
 
5114
	pdu_rewind_space(added_size);
-
 
5115
	ntpl = (void *)ptr;
-
 
5116
 
-
 
5117
	/* first three fields are equal for all types of templates */
-
 
5118
	if (tpl->options)
-
 
5119
		ntpl->flowset_id = protocol == 9? htons(FLOWSET_OPTIONS) : htons(IPFIX_OPTIONS);
-
 
5120
	else
-
 
5121
		ntpl->flowset_id = protocol == 9? htons(FLOWSET_TEMPLATE) : htons(IPFIX_TEMPLATE);
-
 
5122
	ntpl->length	  = htons(tpl->tpl_size);
-
 
5123
	ntpl->template_id = tpl->template_id_n;
-
 
5124
 
-
 
5125
	if (tpl->options) {
-
 
5126
		/* option templates should be defined with first element being scope */
-
 
5127
		if (protocol == 9) {
-
 
5128
			struct flowset_opt_tpl_v9 *otpl = (void *)ptr;
-
 
5129
 
-
 
5130
			otpl->scope_len   = htons(TPL_FIELD_NSIZE);
-
 
5131
			otpl->opt_len     = htons((tpl->length - 1) * TPL_FIELD_NSIZE);
-
 
5132
			ptr += sizeof(struct flowset_opt_tpl_v9);
-
 
5133
		} else {
-
 
5134
			struct flowset_opt_tpl_ipfix *otpl = (void *)ptr;
-
 
5135
 
-
 
5136
			otpl->field_count = htons(tpl->length);
-
 
5137
			otpl->scope_count = htons(1);
-
 
5138
			ptr += sizeof(struct flowset_opt_tpl_ipfix);
-
 
5139
		}
-
 
5140
	} else {
-
 
5141
		ntpl->field_count = htons(tpl->length);
-
 
5142
		ptr += sizeof(struct flowset_template);
-
 
5143
	}
-
 
5144
 
-
 
5145
	sptr = (__be16 *)ptr;
-
 
5146
	fields = tpl->fields;
-
 
5147
	if (tpl->options && protocol == 9) {
-
 
5148
		/* v9 scope */
-
 
5149
		*sptr++ = htons(scope_ipfix_to_v9(*fields++));
-
 
5150
		*sptr++ = htons(*fields++);
-
 
5151
	}
-
 
5152
	for (;;) {
-
 
5153
		const int type = *fields++;
-
 
5154
		if (!type)
-
 
5155
			break;
-
 
5156
		*sptr++ = htons(type);
-
 
5157
		*sptr++ = htons(*fields++);
-
 
5158
	}
-
 
5159
 
-
 
5160
	tpl->exported_cnt = pdu_count;
-
 
5161
	tpl->exported_ts = jiffies;
-
 
5162
 
-
 
5163
	pdu_flowset = NULL;
-
 
5164
	pdu_tpl_records++;
-
 
5165
}
-
 
5166
 
-
 
5167
#ifdef ENABLE_DIRECTION
-
 
5168
static inline __u8 hook2dir(const __u8 hooknum)
-
 
5169
{
-
 
5170
	switch (hooknum) {
-
 
5171
	case NF_INET_PRE_ROUTING:
-
 
5172
	case NF_INET_LOCAL_IN:
-
 
5173
		return 0;
-
 
5174
	case NF_INET_LOCAL_OUT:
-
 
5175
	case NF_INET_POST_ROUTING:
-
 
5176
		return 1;
-
 
5177
	default:
-
 
5178
		return -1;
-
 
5179
	}
-
 
5180
}
-
 
5181
#endif
-
 
5182
 
-
 
5183
static inline void put_unaligned_be24(u32 val, unsigned char *p)
-
 
5184
{
-
 
5185
	*p++ = val >> 16;
-
 
5186
	put_unaligned_be16(val, p);
-
 
5187
}
-
 
5188
 
-
 
5189
static struct {
-
 
5190
	s64		ms;	 /* this much abs milliseconds */
-
 
5191
	unsigned long	jiffies; /* is that much jiffies */
-
 
5192
} jiffies_base;
-
 
5193
 
-
 
5194
/* prepare for jiffies_to_ms_abs() batch */
-
 
5195
static void set_jiffies_base(void)
-
 
5196
{
-
 
5197
	ktime_t ktime;
-
 
5198
 
-
 
5199
	/* try to get them atomically */
-
 
5200
	local_bh_disable();
-
 
5201
	jiffies_base.jiffies = jiffies;
-
 
5202
	ktime = ktime_get_real();
-
 
5203
	local_bh_enable();
-
 
5204
 
-
 
5205
	jiffies_base.ms = ktime_to_ms(ktime);
-
 
5206
}
-
 
5207
 
-
 
5208
/* convert jiffies to ktime and rebase to unix epoch */
-
 
5209
static inline s64 jiffies_to_ms_abs(unsigned long j)
-
 
5210
{
-
 
5211
	long jdiff = jiffies_base.jiffies - j;
-
 
5212
 
-
 
5213
	if (likely(jdiff >= 0))
-
 
5214
		return jiffies_base.ms - (s64)jiffies_to_msecs(jdiff);
-
 
5215
	else
-
 
5216
		return jiffies_base.ms + (s64)jiffies_to_msecs(-jdiff);
-
 
5217
}
-
 
5218
 
-
 
5219
typedef struct in6_addr in6_t;
-
 
5220
/* encode one field (data records only) */
-
 
5221
static inline void add_tpl_field(__u8 *ptr, const int type, const struct ipt_netflow *nf)
-
 
5222
{
-
 
5223
	switch (type) {
-
 
5224
	case IN_BYTES:	     put_unaligned_be32(nf->nr_bytes, ptr); break;
-
 
5225
	case IN_PKTS:	     put_unaligned_be32(nf->nr_packets, ptr); break;
-
 
5226
	case FIRST_SWITCHED: put_unaligned_be32(jiffies_to_msecs(nf->nf_ts_first), ptr); break;
-
 
5227
	case LAST_SWITCHED:  put_unaligned_be32(jiffies_to_msecs(nf->nf_ts_last), ptr); break;
-
 
5228
	case flowStartMilliseconds: put_unaligned_be64(jiffies_to_ms_abs(nf->nf_ts_first), ptr); break;
-
 
5229
	case flowEndMilliseconds:   put_unaligned_be64(jiffies_to_ms_abs(nf->nf_ts_last), ptr); break;
-
 
5230
	case IPV4_SRC_ADDR:  put_unaligned(nf->tuple.src.ip, (__be32 *)ptr); break;
-
 
5231
	case IPV4_DST_ADDR:  put_unaligned(nf->tuple.dst.ip, (__be32 *)ptr); break;
-
 
5232
	case IPV4_NEXT_HOP:  put_unaligned(nf->nh.ip, (__be32 *)ptr); break;
-
 
5233
	case L4_SRC_PORT:    put_unaligned(nf->tuple.s_port, (__be16 *)ptr); break;
-
 
5234
	case L4_DST_PORT:    put_unaligned(nf->tuple.d_port, (__be16 *)ptr); break;
-
 
5235
#ifdef SNMP_RULES
-
 
5236
	case INPUT_SNMP:     put_unaligned_be16(nf->i_ifcr, ptr); break;
-
 
5237
	case OUTPUT_SNMP:    put_unaligned_be16(nf->o_ifcr, ptr); break;
-
 
5238
#else
-
 
5239
	case INPUT_SNMP:     put_unaligned_be16(nf->tuple.i_ifc, ptr); break;
-
 
5240
	case OUTPUT_SNMP:    put_unaligned_be16(nf->o_ifc, ptr); break;
-
 
5241
#endif
-
 
5242
#ifdef ENABLE_PHYSDEV
-
 
5243
	case ingressPhysicalInterface:
-
 
5244
			     put_unaligned_be16(nf->i_ifphys, ptr); break;
-
 
5245
	case egressPhysicalInterface:
-
 
5246
			     put_unaligned_be16(nf->o_ifphys, ptr); break;
-
 
5247
#endif
-
 
5248
#ifdef ENABLE_VLAN
-
 
5249
#define EXTRACT_VLAN_PRIO(tag) ((ntohs(tag) & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT)
-
 
5250
	case SRC_VLAN:
-
 
5251
	case dot1qVlanId:    put_unaligned(nf->tuple.tag[0] & htons(VLAN_VID_MASK), (__be16 *)ptr); break;
-
 
5252
	case dot1qPriority:            *ptr = EXTRACT_VLAN_PRIO(nf->tuple.tag[0]); break;
-
 
5253
	case dot1qCustomerVlanId:
-
 
5254
			     put_unaligned(nf->tuple.tag[1] & htons(VLAN_VID_MASK), (__be16 *)ptr); break;
-
 
5255
	case dot1qCustomerPriority:    *ptr = EXTRACT_VLAN_PRIO(nf->tuple.tag[1]); break;
-
 
5256
#endif
-
 
5257
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
5258
	case ethernetType:   put_unaligned(nf->ethernetType, (__be16 *)ptr); break;
-
 
5259
#endif
-
 
5260
#ifdef ENABLE_MAC
-
 
5261
	case destinationMacAddress: memcpy(ptr, &nf->tuple.h_dst, ETH_ALEN); break;
-
 
5262
	case sourceMacAddress:	    memcpy(ptr, &nf->tuple.h_src, ETH_ALEN); break;
-
 
5263
#endif
-
 
5264
#ifdef MPLS_DEPTH
-
 
5265
# if __GNUC_PREREQ(4,6)
-
 
5266
#  pragma GCC diagnostic push
-
 
5267
#  pragma GCC diagnostic ignored "-Warray-bounds"
-
 
5268
# endif
-
 
5269
	case MPLS_LABEL_1:    memcpy(ptr, &nf->tuple.mpls[0], 3); break;
-
 
5270
	case MPLS_LABEL_2:    memcpy(ptr, &nf->tuple.mpls[1], 3); break;
-
 
5271
	case MPLS_LABEL_3:    memcpy(ptr, &nf->tuple.mpls[2], 3); break;
-
 
5272
# if MPLS_DEPTH > 3
-
 
5273
	case MPLS_LABEL_4:    memcpy(ptr, &nf->tuple.mpls[3], 3); break;
-
 
5274
	case MPLS_LABEL_5:    memcpy(ptr, &nf->tuple.mpls[4], 3); break;
-
 
5275
	case MPLS_LABEL_6:    memcpy(ptr, &nf->tuple.mpls[5], 3); break;
-
 
5276
	case MPLS_LABEL_7:    memcpy(ptr, &nf->tuple.mpls[6], 3); break;
-
 
5277
	case MPLS_LABEL_8:    memcpy(ptr, &nf->tuple.mpls[7], 3); break;
-
 
5278
	case MPLS_LABEL_9:    memcpy(ptr, &nf->tuple.mpls[8], 3); break;
-
 
5279
	case MPLS_LABEL_10:   memcpy(ptr, &nf->tuple.mpls[9], 3); break;
-
 
5280
# endif
-
 
5281
# if __GNUC_PREREQ(4,6)
-
 
5282
#  pragma GCC diagnostic pop
-
 
5283
# endif
-
 
5284
	case mplsTopLabelTTL: *ptr = ntohl(nf->tuple.mpls[0]); break;
-
 
5285
#endif
-
 
5286
#ifdef ENABLE_DIRECTION
-
 
5287
	case DIRECTION:		       *ptr = hook2dir(nf->hooknumx - 1); break;
-
 
5288
#endif
-
 
5289
	case PROTOCOL:	               *ptr = nf->tuple.protocol; break;
-
 
5290
	case TCP_FLAGS:	               *ptr = nf->tcp_flags; break;
-
 
5291
	case TOS:	               *ptr = nf->tuple.tos; break;
-
 
5292
	case IPV6_SRC_ADDR:   *(in6_t *)ptr = nf->tuple.src.in6; break;
-
 
5293
	case IPV6_DST_ADDR:   *(in6_t *)ptr = nf->tuple.dst.in6; break;
-
 
5294
	case IPV6_NEXT_HOP:   *(in6_t *)ptr = nf->nh.in6; break;
-
 
5295
	case IPV6_FLOW_LABEL: put_unaligned_be24(nf->flow_label, ptr); break;
-
 
5296
	case tcpOptions:      put_unaligned_be32(nf->tcpoptions, ptr); break;
-
 
5297
	case ipv4Options:     put_unaligned_be32(nf->options, ptr); break;
-
 
5298
	case IPV6_OPTION_HEADERS:
-
 
5299
			      put_unaligned_be16(nf->options, ptr); break;
-
 
5300
	case SRC_MASK:	               *ptr = nf->s_mask; break;
-
 
5301
	case DST_MASK:	               *ptr = nf->d_mask; break;
-
 
5302
	case icmpTypeCodeIPv4:	/*FALLTHROUGH*/
-
 
5303
	case icmpTypeCodeIPv6:	put_unaligned(nf->tuple.d_port, (__be16 *)ptr); break;
-
 
5304
	case MUL_IGMP_TYPE:            *ptr = nf->tuple.d_port; break;
-
 
5305
	case flowEndReason: 	       *ptr = nf->flowEndReason; break;
-
 
5306
#ifdef CONFIG_NF_NAT_NEEDED
-
 
5307
	case postNATSourceIPv4Address:	       put_unaligned(nf->nat->post.s_addr, (__be32 *)ptr); break;
-
 
5308
	case postNATDestinationIPv4Address:    put_unaligned(nf->nat->post.d_addr, (__be32 *)ptr); break;
-
 
5309
	case postNAPTSourceTransportPort:      put_unaligned(nf->nat->post.s_port, (__be16 *)ptr); break;
-
 
5310
	case postNAPTDestinationTransportPort: put_unaligned(nf->nat->post.d_port, (__be16 *)ptr); break;
-
 
5311
	case natEvent:		       *ptr = nf->nat->nat_event; break;
-
 
5312
#endif
-
 
5313
	case IPSecSPI:       put_unaligned(EXTRACT_SPI(nf->tuple), (__be32 *)ptr); break;
-
 
5314
	case observationTimeMilliseconds:
-
 
5315
			     put_unaligned_be64(ktime_to_ms(nf->nf_ts_obs), ptr); break;
-
 
5316
	case observationTimeMicroseconds:
-
 
5317
			     put_unaligned_be64(ktime_to_us(nf->nf_ts_obs), ptr); break;
-
 
5318
	case observationTimeNanoseconds:
-
 
5319
			     put_unaligned_be64(ktime_to_ns(nf->nf_ts_obs), ptr); break;
-
 
5320
#ifdef ENABLE_SAMPLER
-
 
5321
	case FLOW_SAMPLER_ID:
-
 
5322
	case selectorId:
-
 
5323
			     *ptr = get_sampler_mode(); break;
-
 
5324
#endif
-
 
5325
	default:
-
 
5326
			     WARN_ONCE(1, "NETFLOW: Unknown Element id %d\n", type);
-
 
5327
			     memset(ptr, 0, tpl_element_sizes[type]);
-
 
5328
	}
-
 
5329
}
-
 
5330
 
-
 
5331
#define PAD_SIZE 4 /* rfc prescribes flowsets to be padded */
-
 
5332
 
-
 
5333
/* cache timeout_rate in jiffies */
-
 
5334
static inline unsigned long timeout_rate_j(void)
-
 
5335
{
-
 
5336
	static unsigned int t_rate = 0;
-
 
5337
	static unsigned long t_rate_j = 0;
-
 
5338
 
-
 
5339
	if (unlikely(timeout_rate != t_rate)) {
-
 
5340
		struct timeval tv = { .tv_sec = timeout_rate * 60, .tv_usec = 0 };
-
 
5341
 
-
 
5342
		t_rate = timeout_rate;
-
 
5343
		t_rate_j = timeval_to_jiffies(&tv);
-
 
5344
	}
-
 
5345
	return t_rate_j;
-
 
5346
}
-
 
5347
 
-
 
5348
/* return buffer where to write records data */
-
 
5349
static unsigned char *alloc_record_tpl(struct data_template *tpl)
-
 
5350
{
-
 
5351
	unsigned char *ptr;
-
 
5352
 
-
 
5353
	/* If previous write was to the same template and there is room, then we just add new record,
-
 
5354
	 * otherwise we (re)allocate flowset (and/or whole pdu). */
-
 
5355
	if (!pdu_flowset ||
-
 
5356
	    pdu_flowset->flowset_id != tpl->template_id_n ||
-
 
5357
	    !(ptr = pdu_alloc_fail_export(tpl->rec_size))) {
-
 
5358
 
-
 
5359
		/* if there was previous data template we should pad it to 4 bytes */
-
 
5360
		if (pdu_flowset) {
-
 
5361
			int padding = (PAD_SIZE - ntohs(pdu_flowset->length) % PAD_SIZE) % PAD_SIZE;
-
 
5362
			if (padding && (ptr = pdu_alloc_fail_export(padding))) {
-
 
5363
				pdu_flowset->length = htons(ntohs(pdu_flowset->length) + padding);
-
 
5364
				for (; padding; padding--)
-
 
5365
					*ptr++ = 0;
-
 
5366
			}
-
 
5367
		}
-
 
5368
 
-
 
5369
		/* export template if needed */
-
 
5370
		if (!tpl->exported_ts ||
-
 
5371
		    pdu_count > (tpl->exported_cnt + refresh_rate) ||
-
 
5372
		    time_is_before_jiffies(tpl->exported_ts + timeout_rate_j())) {
-
 
5373
			pdu_add_template(tpl);
-
 
5374
		}
-
 
5375
 
-
 
5376
		/* new flowset */
-
 
5377
		ptr = pdu_alloc_export(sizeof(struct flowset_data) + tpl->rec_size);
-
 
5378
		pdu_flowset		= (struct flowset_data *)ptr;
-
 
5379
		pdu_flowset->flowset_id = tpl->template_id_n;
-
 
5380
		pdu_flowset->length	= htons(sizeof(struct flowset_data));
-
 
5381
		ptr += sizeof(struct flowset_data);
-
 
5382
	}
-
 
5383
	return ptr;
-
 
5384
}
-
 
5385
 
-
 
5386
static unsigned char *alloc_record_key(const unsigned int t_key, struct data_template **ptpl)
-
 
5387
{
-
 
5388
	struct data_template *tpl;
-
 
5389
 
-
 
5390
	tpl = get_template(t_key);
-
 
5391
	if (unlikely(!tpl)) {
-
 
5392
		printk(KERN_INFO "ipt_NETFLOW: template %#x allocation failed.\n", t_key);
-
 
5393
		NETFLOW_STAT_INC_ATOMIC(alloc_err);
-
 
5394
		return NULL;
-
 
5395
	}
-
 
5396
	*ptpl = tpl;
-
 
5397
	return alloc_record_tpl(tpl);
-
 
5398
}
-
 
5399
 
-
 
5400
static void netflow_export_flow_tpl(struct ipt_netflow *nf)
-
 
5401
{
-
 
5402
	unsigned char *ptr;
-
 
5403
	struct data_template *tpl;
-
 
5404
	unsigned int tpl_mask;
-
 
5405
	int i;
-
 
5406
 
-
 
5407
	if (unlikely(debug > 2))
-
 
5408
		printk(KERN_INFO "adding flow to export (%d)\n",
-
 
5409
		    pdu_data_records + pdu_tpl_records);
-
 
5410
 
-
 
5411
	/* build the template key */
-
 
5412
#ifdef CONFIG_NF_NAT_NEEDED
-
 
5413
	if (nf->nat) {
-
 
5414
		tpl_mask = BTPL_NAT4;
-
 
5415
		goto ready;
-
 
5416
	}
-
 
5417
#endif
-
 
5418
	tpl_mask = (protocol == 9)? BTPL_BASE9 : BTPL_BASEIPFIX;
-
 
5419
	if (likely(nf->tuple.l3proto == AF_INET)) {
-
 
5420
		tpl_mask |= BTPL_IP4;
-
 
5421
		if (unlikely(nf->options))
-
 
5422
			tpl_mask |= BTPL_IP4OPTIONS;
-
 
5423
	} else {
-
 
5424
		tpl_mask |= BTPL_IP6;
-
 
5425
		if (unlikely(nf->options))
-
 
5426
			tpl_mask |= BTPL_IP6OPTIONS;
-
 
5427
		if (unlikely(nf->flow_label))
-
 
5428
			tpl_mask |= BTPL_LABEL6;
-
 
5429
	}
-
 
5430
	if (unlikely(nf->tcpoptions))
-
 
5431
		tpl_mask |= BTPL_TCPOPTIONS;
-
 
5432
	if (unlikely(nf->s_mask || nf->d_mask))
-
 
5433
		tpl_mask |= BTPL_MASK4;
-
 
5434
	if (likely(nf->tuple.protocol == IPPROTO_TCP ||
-
 
5435
		    nf->tuple.protocol == IPPROTO_UDP ||
-
 
5436
		    nf->tuple.protocol == IPPROTO_SCTP ||
-
 
5437
		    nf->tuple.protocol == IPPROTO_UDPLITE))
-
 
5438
		tpl_mask |= BTPL_PORTS;
-
 
5439
	else if (nf->tuple.protocol == IPPROTO_ICMP ||
-
 
5440
		 nf->tuple.protocol == IPPROTO_ICMPV6) {
-
 
5441
		if (protocol == 9)
-
 
5442
			tpl_mask |= BTPL_ICMP9;
-
 
5443
		else if (likely(nf->tuple.l3proto == AF_INET))
-
 
5444
			tpl_mask |= BTPL_ICMPX4;
-
 
5445
		else
-
 
5446
			tpl_mask |= BTPL_ICMPX6;
-
 
5447
	} else if (nf->tuple.protocol == IPPROTO_IGMP)
-
 
5448
		tpl_mask |= BTPL_IGMP;
-
 
5449
        else if (nf->tuple.protocol == IPPROTO_AH ||
-
 
5450
                    nf->tuple.protocol == IPPROTO_ESP)
-
 
5451
                tpl_mask |= BTPL_IPSEC;
-
 
5452
#ifdef ENABLE_MAC
-
 
5453
	if (!is_zero_ether_addr(nf->tuple.h_src) ||
-
 
5454
	    !is_zero_ether_addr(nf->tuple.h_dst))
-
 
5455
		tpl_mask |= BTPL_MAC;
-
 
5456
#endif
-
 
5457
#ifdef ENABLE_VLAN
-
 
5458
	if (nf->tuple.tag[0]) {
-
 
5459
		if (protocol == 9)
-
 
5460
			tpl_mask |= BTPL_VLAN9;
-
 
5461
		else {
-
 
5462
			tpl_mask |= BTPL_VLANX;
-
 
5463
			if (nf->tuple.tag[1])
-
 
5464
				tpl_mask |= BTPL_VLANI;
-
 
5465
		}
-
 
5466
	}
-
 
5467
#endif
-
 
5468
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
5469
	if (nf->ethernetType)
-
 
5470
		tpl_mask |= BTPL_ETHERTYPE;
-
 
5471
#endif
-
 
5472
#ifdef MPLS_DEPTH
-
 
5473
	if (nf->tuple.mpls[0])
-
 
5474
		tpl_mask |= BTPL_MPLS;
-
 
5475
#endif
-
 
5476
#ifdef ENABLE_DIRECTION
-
 
5477
	if (nf->hooknumx)
-
 
5478
		tpl_mask |= BTPL_DIRECTION;
-
 
5479
#endif
-
 
5480
#ifdef ENABLE_SAMPLER
-
 
5481
	if (get_sampler_mode())
-
 
5482
		tpl_mask |= (protocol == 9)? BTPL_SAMPLERID : BTPL_SELECTORID;
-
 
5483
#endif
-
 
5484
 
-
 
5485
#ifdef CONFIG_NF_NAT_NEEDED
-
 
5486
ready:
-
 
5487
#endif
-
 
5488
	ptr = alloc_record_key(tpl_mask, &tpl);
-
 
5489
	if (unlikely(!ptr)) {
-
 
5490
		NETFLOW_STAT_ADD(pkt_lost, nf->nr_packets);
-
 
5491
		NETFLOW_STAT_ADD(traf_lost, nf->nr_bytes);
-
 
5492
		NETFLOW_STAT_INC(flow_lost);
-
 
5493
		NETFLOW_STAT_TS(lost);
-
 
5494
		ipt_netflow_free(nf);
-
 
5495
		return;
-
 
5496
	}
-
 
5497
 
-
 
5498
	/* encode all fields */
-
 
5499
	for (i = 0; ; ) {
-
 
5500
		int type = tpl->fields[i++];
-
 
5501
 
-
 
5502
		if (!type)
-
 
5503
			break;
-
 
5504
		add_tpl_field(ptr, type, nf);
-
 
5505
		ptr += tpl->fields[i++];
-
 
5506
	}
-
 
5507
 
-
 
5508
	pdu_data_records++;
-
 
5509
	pdu_flow_records++;
-
 
5510
	pdu_flowset->length = htons(ntohs(pdu_flowset->length) + tpl->rec_size);
-
 
5511
 
-
 
5512
	pdu_packets += nf->nr_packets;
-
 
5513
	pdu_traf    += nf->nr_bytes;
-
 
5514
	pdu_ts_mod = jiffies;
-
 
5515
 
-
 
5516
	ipt_netflow_free(nf);
-
 
5517
}
-
 
5518
 
-
 
5519
static u64 get_sys_init_time_ms(void)
-
 
5520
{
-
 
5521
	static u64 sys_init_time = 0;
-
 
5522
 
-
 
5523
	if (!sys_init_time)
-
 
5524
		sys_init_time = ktime_to_ms(ktime_get_real()) - jiffies_to_msecs(jiffies);
-
 
5525
	return sys_init_time;
-
 
5526
}
-
 
5527
 
-
 
5528
#ifdef ENABLE_SAMPLER
-
 
5529
/* http://www.iana.org/assignments/ipfix/ipfix.xml#ipfix-flowselectoralgorithm */
-
 
5530
static unsigned char get_flowselectoralgo(void)
-
 
5531
{
-
 
5532
	switch (get_sampler_mode()) {
-
 
5533
	case SAMPLER_DETERMINISTIC:
-
 
5534
		return 1; /* Systematic count-based Sampling */
-
 
5535
	case SAMPLER_HASH:
-
 
5536
	case SAMPLER_RANDOM:
-
 
5537
		return 3; /* Random n-out-of-N Sampling */
-
 
5538
	default:
-
 
5539
		return 0; /* Unassigned */
-
 
5540
	}
-
 
5541
}
-
 
5542
#endif
-
 
5543
 
-
 
5544
static void export_stat_st_ts(const unsigned int tpl_mask, struct ipt_netflow_stat *st, struct duration *ts)
-
 
5545
{
-
 
5546
	unsigned char *ptr;
-
 
5547
	struct data_template *tpl;
-
 
5548
	int i;
-
 
5549
 
-
 
5550
	ptr = alloc_record_key(tpl_mask, &tpl);
-
 
5551
	if (unlikely(!ptr))
-
 
5552
		return;
-
 
5553
 
-
 
5554
	/* encode all fields */
-
 
5555
	for (i = 0; ; ) {
-
 
5556
		int type = tpl->fields[i++];
-
 
5557
 
-
 
5558
		if (!type)
-
 
5559
			break;
-
 
5560
		switch (type) {
-
 
5561
		case observationDomainId:	put_unaligned_be32(engine_id, ptr); break;
-
 
5562
		case exportingProcessId:	put_unaligned_be32(engine_id, ptr); break;
-
 
5563
		case observedFlowTotalCount:	put_unaligned_be64(st->notfound, ptr); break;
-
 
5564
		case exportedMessageTotalCount:	put_unaligned_be64(st->exported_pkt, ptr); break;
-
 
5565
		case exportedOctetTotalCount:	put_unaligned_be64(st->exported_traf, ptr); break;
-
 
5566
		case exportedFlowRecordTotalCount: put_unaligned_be64(st->exported_flow, ptr); break;
-
 
5567
		case ignoredPacketTotalCount:	put_unaligned_be64(st->pkt_drop, ptr); break;
-
 
5568
		case ignoredOctetTotalCount:	put_unaligned_be64(st->traf_drop, ptr); break;
-
 
5569
		case notSentFlowTotalCount:	put_unaligned_be64(st->flow_lost, ptr); break;
-
 
5570
		case notSentPacketTotalCount:	put_unaligned_be64(st->pkt_lost, ptr); break;
-
 
5571
		case notSentOctetTotalCount:	put_unaligned_be64(st->traf_lost, ptr); break;
-
 
5572
		case flowStartMilliseconds:	put_unaligned_be64(ktime_to_ms(ts->first), ptr); break;
-
 
5573
		case flowEndMilliseconds:	put_unaligned_be64(ktime_to_ms(ts->last), ptr); break;
-
 
5574
		case systemInitTimeMilliseconds: put_unaligned_be64(get_sys_init_time_ms(), ptr); break;
-
 
5575
		case observationDomainName:     memcpy(ptr, version_string, version_string_size + 1); break;
-
 
5576
#ifdef ENABLE_SAMPLER
-
 
5577
		case FLOW_SAMPLER_ID:
-
 
5578
		case selectorId:
-
 
5579
						*ptr = get_sampler_mode(); break;
-
 
5580
		case FLOW_SAMPLER_MODE:
-
 
5581
						*ptr = get_sampler_mode_nf(); break;
-
 
5582
		case flowSelectorAlgorithm:	*ptr = get_flowselectoralgo(); break;
-
 
5583
		case samplingSize:
-
 
5584
		case samplingFlowInterval:
-
 
5585
						*ptr = 1 /* always 'one-out-of' */; break;
-
 
5586
		case samplingFlowSpacing:
-
 
5587
		case samplingPopulation:
-
 
5588
		case FLOW_SAMPLER_RANDOM_INTERVAL:
-
 
5589
						put_unaligned_be16(get_sampler_interval(), ptr); break;
-
 
5590
		case selectorIDTotalFlowsObserved: put_unaligned_be64(atomic64_read(&flows_observed), ptr); break;
-
 
5591
		case selectorIDTotalFlowsSelected: put_unaligned_be64(atomic64_read(&flows_selected), ptr); break;
-
 
5592
		case selectorIdTotalPktsObserved:  put_unaligned_be64(st->pkts_observed, ptr); break;
-
 
5593
		case selectorIdTotalPktsSelected:  put_unaligned_be64(st->pkts_selected, ptr); break;
-
 
5594
#endif
-
 
5595
		default:
-
 
5596
			WARN_ONCE(1, "NETFLOW: Unknown Element id %d\n", type);
-
 
5597
		}
-
 
5598
		ptr += tpl->fields[i++];
-
 
5599
	}
-
 
5600
 
-
 
5601
	pdu_data_records++;
-
 
5602
	pdu_flowset->length = htons(ntohs(pdu_flowset->length) + tpl->rec_size);
-
 
5603
 
-
 
5604
	pdu_ts_mod = jiffies;
-
 
5605
}
-
 
5606
 
-
 
5607
static inline void export_stat_ts(const unsigned int tpl_mask, struct duration *ts)
-
 
5608
{
-
 
5609
	export_stat_st_ts(tpl_mask, NULL, ts);
-
 
5610
}
-
 
5611
 
-
 
5612
static inline void export_stat_st(const unsigned int tpl_mask, struct ipt_netflow_stat *st)
-
 
5613
{
-
 
5614
	export_stat_st_ts(tpl_mask, st, NULL);
-
 
5615
}
-
 
5616
 
-
 
5617
static inline void export_stat(const unsigned int tpl_mask)
-
 
5618
{
-
 
5619
	export_stat_st(tpl_mask, NULL);
-
 
5620
}
-
 
5621
 
-
 
5622
static void netflow_export_stats(void)
-
 
5623
{
-
 
5624
	struct ipt_netflow_stat t = { 0 };
-
 
5625
	int cpu;
-
 
5626
 
-
 
5627
	if (unlikely(!ts_sysinf_last) ||
-
 
5628
	    time_is_before_jiffies(ts_sysinf_last + SYSINFO_INTERVAL * HZ)) {
-
 
5629
		start_ts.last = ktime_get_real();
-
 
5630
		export_stat_ts(OTPL_SYSITIME, &start_ts);
-
 
5631
		ts_sysinf_last = jiffies;
-
 
5632
		pdu_needs_export++;
-
 
5633
	}
-
 
5634
 
-
 
5635
	if (unlikely(!ts_stat_last))
-
 
5636
		ts_stat_last = jiffies;
-
 
5637
	if (likely(time_is_after_jiffies(ts_stat_last + STAT_INTERVAL * HZ)))
-
 
5638
		return;
-
 
5639
 
-
 
5640
	for_each_present_cpu(cpu) {
-
 
5641
		struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
5642
 
-
 
5643
		t.notfound	+= st->notfound; // observedFlowTotalCount
-
 
5644
		t.exported_pkt	+= st->exported_pkt;  // exportedMessageTotalCount
-
 
5645
		t.exported_traf	+= st->exported_traf; // exportedOctetTotalCount
-
 
5646
		t.exported_flow	+= st->exported_flow; // exportedFlowRecordTotalCount
-
 
5647
		t.pkt_drop	+= st->pkt_drop;  // ignoredPacketTotalCount
-
 
5648
		t.traf_drop	+= st->traf_drop; // ignoredOctetTotalCount
-
 
5649
		t.flow_lost	+= st->flow_lost; // notSentFlowTotalCount
-
 
5650
		t.pkt_lost	+= st->pkt_lost;  // notSentPacketTotalCount
-
 
5651
		t.traf_lost	+= st->traf_lost; // notSentOctetTotalCount
-
 
5652
#ifdef ENABLE_SAMPLER
-
 
5653
		t.pkts_selected	+= st->pkts_selected;
-
 
5654
		t.pkts_observed	+= st->pkts_observed;
-
 
5655
#endif
-
 
5656
		t.drop.first_tv64 = min_not_zero(t.drop.first_tv64, st->drop.first_tv64);
-
 
5657
		t.drop.last_tv64  = max(t.drop.last_tv64, st->drop.last_tv64);
-
 
5658
		t.lost.first_tv64 = min_not_zero(t.lost.first_tv64, st->lost.first_tv64);
-
 
5659
		t.lost.last_tv64  = max(t.lost.last_tv64, st->lost.last_tv64);
-
 
5660
	}
-
 
5661
 
-
 
5662
	export_stat_st(OTPL_MPSTAT, &t);
-
 
5663
	if (t.pkt_drop)
-
 
5664
		export_stat_st_ts(OTPL_MPRSTAT, &t, &t.drop);
-
 
5665
	if (t.pkt_lost)
-
 
5666
		export_stat_st_ts(OTPL_EPRSTAT, &t, &t.lost);
-
 
5667
#ifdef ENABLE_SAMPLER
-
 
5668
	if (protocol == 10) {
-
 
5669
		sampling_ts.last = ktime_get_real();
-
 
5670
		switch (get_sampler_mode()) {
-
 
5671
		case SAMPLER_HASH:
-
 
5672
			export_stat_st_ts(OTPL_SEL_STATH, &t, &sampling_ts);
-
 
5673
			break;
-
 
5674
		case SAMPLER_DETERMINISTIC:
-
 
5675
		case SAMPLER_RANDOM:
-
 
5676
			export_stat_st_ts(OTPL_SEL_STAT, &t, &sampling_ts);
-
 
5677
		}
-
 
5678
	}
-
 
5679
#endif
-
 
5680
 
-
 
5681
	ts_stat_last = jiffies;
-
 
5682
	pdu_needs_export++;
-
 
5683
}
-
 
5684
 
-
 
5685
#ifdef ENABLE_SAMPLER
-
 
5686
static void export_sampler_parameters(void)
-
 
5687
{
-
 
5688
	if (get_sampler_mode() &&
-
 
5689
	    (unlikely(!ts_sampler_last) ||
-
 
5690
	     time_is_before_jiffies(ts_sampler_last + SAMPLER_INFO_INTERVAL * HZ))) {
-
 
5691
		if (protocol == 9)
-
 
5692
			export_stat(OTPL_SAMPLER);
-
 
5693
		else {
-
 
5694
			const unsigned char mode = get_sampler_mode();
-
 
5695
 
-
 
5696
			if (mode == SAMPLER_DETERMINISTIC)
-
 
5697
				export_stat(OTPL_SEL_COUNT);
-
 
5698
			else
-
 
5699
				export_stat(OTPL_SEL_RAND);
-
 
5700
		}
-
 
5701
		ts_sampler_last = jiffies;
-
 
5702
	}
-
 
5703
}
-
 
5704
#endif
-
 
5705
 
-
 
5706
static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *dev)
-
 
5707
{
-
 
5708
	struct ethtool_drvinfo info = { 0 };
-
 
5709
	const struct ethtool_ops *ops = dev->ethtool_ops;
-
 
5710
#ifndef ETHTOOL_GLINKSETTINGS
-
 
5711
	struct ethtool_cmd ecmd;
-
 
5712
#define _KSETTINGS(x, y) (x)
-
 
5713
#else
-
 
5714
	struct ethtool_link_ksettings ekmd;
-
 
5715
#define _KSETTINGS(x, y) (y)
-
 
5716
#endif
-
 
5717
	int len = size;
-
 
5718
	int n;
-
 
5719
 
-
 
5720
	if (len <= 0 || !ops)
-
 
5721
		return 0;
-
 
5722
	if (ops->begin) {
-
 
5723
		/* was not called before __ethtool_get_settings() though */
-
 
5724
		if (ops->begin(dev) < 0)
-
 
5725
			return 0;
-
 
5726
	}
-
 
5727
 
-
 
5728
	/* driver name */
-
 
5729
	if (ops->get_drvinfo)
-
 
5730
		ops->get_drvinfo(dev, &info);
-
 
5731
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
-
 
5732
	else if (dev->dev.parent && dev->dev.parent->driver) {
-
 
5733
		strlcpy(info.driver, dev->dev.parent->driver->name, sizeof(info.driver));
-
 
5734
	}
-
 
5735
#endif
-
 
5736
	n = scnprintf(ptr, len, "%s", info.driver);
-
 
5737
	ptr += n;
-
 
5738
	len -= n;
-
 
5739
	if (!n || len <= 1) /* have room for separator too */
-
 
5740
		goto ret;
-
 
5741
 
-
 
5742
	/* only get_settings for running devices to not trigger link negotiation */
-
 
5743
	if (dev->flags & IFF_UP &&
-
 
5744
	    dev->flags & IFF_RUNNING &&
-
 
5745
	    !_KSETTINGS(__ethtool_get_settings(dev, &ecmd), __ethtool_get_link_ksettings(dev, &ekmd))) {
-
 
5746
		char *units, *p;
-
 
5747
		__u32 speed = _KSETTINGS(ethtool_cmd_speed(&ecmd), ekmd.base.speed);
-
 
5748
 
-
 
5749
		if (speed == SPEED_UNKNOWN)
-
 
5750
			units = "";
-
 
5751
		else if (speed <= 1000)
-
 
5752
			units = "MbE";
-
 
5753
		else {
-
 
5754
			speed /= 1000;
-
 
5755
			units = "GbE";
-
 
5756
		}
-
 
5757
		switch (_KSETTINGS(ecmd.port, ekmd.base.port)) {
-
 
5758
		case PORT_TP:     p = "tp"; break;
-
 
5759
		case PORT_AUI:    p = "aui"; break;
-
 
5760
		case PORT_MII:    p = "mii"; break;
-
 
5761
		case PORT_FIBRE:  p = "fb"; break;
-
 
5762
		case PORT_BNC:    p = "bnc"; break;
-
 
5763
#ifdef PORT_DA
-
 
5764
		case PORT_DA:     p = "da"; break;
-
 
5765
#endif
-
 
5766
		default:          p = "";
-
 
5767
		}
-
 
5768
		n = scnprintf(ptr, len, ",%d%s,%s", speed, units, p);
-
 
5769
		len -= n;
-
 
5770
	}
-
 
5771
ret:
-
 
5772
	if (ops->complete)
-
 
5773
		ops->complete(dev);
-
 
5774
	return size - len;
-
 
5775
}
-
 
5776
#undef _KSETTINGS
-
 
5777
 
-
 
5778
static const unsigned short netdev_type[] =
-
 
5779
{ARPHRD_NETROM, ARPHRD_ETHER, ARPHRD_AX25,
-
 
5780
	ARPHRD_IEEE802, ARPHRD_ARCNET,
-
 
5781
	ARPHRD_DLCI, ARPHRD_ATM, ARPHRD_METRICOM,
-
 
5782
	ARPHRD_IEEE1394, ARPHRD_EUI64, ARPHRD_INFINIBAND,
-
 
5783
	ARPHRD_SLIP, ARPHRD_CSLIP, ARPHRD_SLIP6, ARPHRD_CSLIP6,
-
 
5784
	ARPHRD_ROSE, ARPHRD_X25, ARPHRD_HWX25,
-
 
5785
	ARPHRD_PPP, ARPHRD_CISCO, ARPHRD_LAPB, ARPHRD_DDCMP,
-
 
5786
	ARPHRD_RAWHDLC, ARPHRD_TUNNEL, ARPHRD_TUNNEL6, ARPHRD_FRAD,
-
 
5787
	ARPHRD_LOOPBACK, ARPHRD_LOCALTLK, ARPHRD_FDDI,
-
 
5788
	ARPHRD_SIT, ARPHRD_IPDDP, ARPHRD_IPGRE,
-
 
5789
	ARPHRD_PIMREG, ARPHRD_HIPPI, ARPHRD_IRDA,
-
 
5790
	ARPHRD_IEEE80211, ARPHRD_IEEE80211_PRISM,
-
 
5791
	ARPHRD_IEEE80211_RADIOTAP, ARPHRD_PHONET, ARPHRD_PHONET_PIPE,
-
 
5792
	ARPHRD_IEEE802154, ARPHRD_VOID, ARPHRD_NONE};
-
 
5793
 
-
 
5794
static const char *const netdev_type_name[] =
-
 
5795
{"NET/ROM", "Ethernet", "AX.25 Level 2",
-
 
5796
	"IEEE 802.2 Ethernet", "ARCnet",
-
 
5797
	"Frame Relay DLCI", "ATM", "Metricom STRIP",
-
 
5798
	"IEEE 1394 IPv4", "EUI-64", "InfiniBand",
-
 
5799
	"SLIP", "CSLIP", "SLIP6", "CSLIP6",
-
 
5800
	"ROSE", "X.25", "HW X.25",
-
 
5801
	"PPP", "Cisco HDLC", "LAPB", "DDCMP",
-
 
5802
	"Raw HDLC", "IPIP Tunnel", "IP6IP6 Tunnel", "FRAD",
-
 
5803
	"Loopback", "Localtalk", "FDDI",
-
 
5804
	"SIT Tunnel", "IP over DDP", "GRE over IP",
-
 
5805
	"PISM Register", "HIPPI", "IrDA",
-
 
5806
	"IEEE 802.11", "IEEE 802.11 Prism2",
-
 
5807
	"IEEE 802.11 Radiotap", "PhoNet", "PhoNet pipe",
-
 
5808
	"IEEE 802.15.4", "void", "none"};
-
 
5809
 
-
 
5810
static const char *dev_type(int dev_type)
-
 
5811
{
-
 
5812
	int i;
-
 
5813
 
-
 
5814
	BUG_ON(ARRAY_SIZE(netdev_type) != ARRAY_SIZE(netdev_type_name));
-
 
5815
	for (i = 0; i < ARRAY_SIZE(netdev_type); i++)
-
 
5816
		if (netdev_type[i] == dev_type)
-
 
5817
			return netdev_type_name[i];
-
 
5818
	return "";
-
 
5819
}
-
 
5820
 
-
 
5821
static void export_dev(struct net_device *dev)
-
 
5822
{
-
 
5823
	unsigned char *ptr;
-
 
5824
	struct data_template *tpl;
-
 
5825
	int i;
-
 
5826
 
-
 
5827
	ptr = alloc_record_key(OTPL_IFNAMES, &tpl);
-
 
5828
	if (unlikely(!ptr))
-
 
5829
		return;
-
 
5830
 
-
 
5831
	/* encode all fields */
-
 
5832
	for (i = 0; ; ) {
-
 
5833
		int type = tpl->fields[i++];
-
 
5834
		int size = tpl->fields[i++];
-
 
5835
		int n;
-
 
5836
 
-
 
5837
		if (!type)
-
 
5838
			break;
-
 
5839
		switch (type) {
-
 
5840
		case observationDomainId:
-
 
5841
			put_unaligned_be32(engine_id, ptr);
-
 
5842
			break;
-
 
5843
		case IF_NAME:
-
 
5844
			n = scnprintf(ptr, size, "%s", dev->name);
-
 
5845
			memset(ptr + n, 0, size - n);
-
 
5846
			break;
-
 
5847
		case IF_DESC:
-
 
5848
			/* manual dev 'alias' setting is a first priority,
-
 
5849
			 * then ethtool driver name with basic info,
-
 
5850
			 * finally net_device.type is a last resort */
-
 
5851
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
-
 
5852
			if (dev->ifalias)
-
 
5853
				n = scnprintf(ptr, size, "%s", dev->ifalias);
-
 
5854
			else
-
 
5855
#endif
-
 
5856
				n = ethtool_drvinfo(ptr, size, dev);
-
 
5857
			if (!n)
-
 
5858
				n = scnprintf(ptr, size, "%s", dev_type(dev->type));
-
 
5859
			memset(ptr + n, 0, size - n);
-
 
5860
			break;
-
 
5861
		case INPUT_SNMP:
-
 
5862
#ifdef SNMP_RULES
-
 
5863
			rcu_read_lock();
-
 
5864
			put_unaligned_be16(resolve_snmp(dev), ptr);
-
 
5865
			rcu_read_unlock();
-
 
5866
#else
-
 
5867
			put_unaligned_be16(dev->ifindex, ptr);
-
 
5868
#endif
-
 
5869
			break;
-
 
5870
		default:
-
 
5871
			WARN_ONCE(1, "NETFLOW: Unknown Element id %d\n", type);
-
 
5872
		}
-
 
5873
		ptr += size;
-
 
5874
	}
-
 
5875
 
-
 
5876
	pdu_data_records++;
-
 
5877
	pdu_flowset->length = htons(ntohs(pdu_flowset->length) + tpl->rec_size);
-
 
5878
 
-
 
5879
	pdu_ts_mod = jiffies;
-
 
5880
}
-
 
5881
 
-
 
5882
static void export_ifnames(void)
-
 
5883
{
-
 
5884
	struct net_device *dev;
-
 
5885
 
-
 
5886
	if (likely(ts_ifnames_last) &&
-
 
5887
	    time_is_after_jiffies(ts_ifnames_last + SYSINFO_INTERVAL * HZ))
-
 
5888
		return;
-
 
5889
 
-
 
5890
	rtnl_lock();
-
 
5891
	for_each_netdev_ns(&init_net, dev) {
-
 
5892
		export_dev(dev);
-
 
5893
	}
-
 
5894
	rtnl_unlock();
-
 
5895
	ts_ifnames_last = jiffies;
-
 
5896
}
-
 
5897
 
-
 
5898
/* under pause_scan_worker() */
-
 
5899
static void netflow_switch_version(const int ver)
-
 
5900
{
-
 
5901
	protocol = ver;
-
 
5902
	if (protocol == 5) {
-
 
5903
		memset(&pdu, 0, sizeof(pdu));
-
 
5904
		pdu_data_used	    = NULL;
-
 
5905
		pdu_high_wm	    = NULL;
-
 
5906
		netflow_export_flow = &netflow_export_flow_v5;
-
 
5907
		netflow_export_pdu  = &netflow_export_pdu_v5;
-
 
5908
	} else if (protocol == 9) {
-
 
5909
		pdu_data_used	    = pdu.v9.data;
-
 
5910
		pdu_high_wm	    = (unsigned char *)&pdu + sizeof(pdu.v9);
-
 
5911
		netflow_export_flow = &netflow_export_flow_tpl;
-
 
5912
		netflow_export_pdu  = &netflow_export_pdu_v9;
-
 
5913
	} else { /* IPFIX */
-
 
5914
		pdu_data_used	    = pdu.ipfix.data;
-
 
5915
		pdu_high_wm	    = (unsigned char *)&pdu + sizeof(pdu.ipfix);
-
 
5916
		netflow_export_flow = &netflow_export_flow_tpl;
-
 
5917
		netflow_export_pdu  = &netflow_export_pdu_ipfix;
-
 
5918
	}
-
 
5919
	pdu.version = htons(protocol);
-
 
5920
	free_templates();
-
 
5921
	pdu_flow_records = pdu_data_records = pdu_tpl_records = 0;
-
 
5922
	pdu_flowset = NULL;
-
 
5923
	printk(KERN_INFO "ipt_NETFLOW protocol version %d (%s) enabled.\n",
-
 
5924
	    protocol, protocol == 10? "IPFIX" : "NetFlow");
-
 
5925
}
-
 
5926
 
-
 
5927
#ifdef CONFIG_NF_NAT_NEEDED
-
 
5928
static void export_nat_event(struct nat_event *nel)
-
 
5929
{
-
 
5930
	static struct ipt_netflow nf = { { NULL } };
-
 
5931
 
-
 
5932
	nf.tuple.l3proto = AF_INET;
-
 
5933
	nf.tuple.protocol = nel->protocol;
-
 
5934
	nf.nat = nel; /* this is also flag of dummy flow */
-
 
5935
	nf.tcp_flags = (nel->nat_event == NAT_DESTROY)? TCP_FIN_RST : TCP_SYN_ACK;
-
 
5936
	if (protocol >= 9) {
-
 
5937
		nf.nf_ts_obs = nel->ts_ktime;
-
 
5938
		nf.tuple.src.ip = nel->pre.s_addr;
-
 
5939
		nf.tuple.dst.ip = nel->pre.d_addr;
-
 
5940
		nf.tuple.s_port = nel->pre.s_port;
-
 
5941
		nf.tuple.d_port = nel->pre.d_port;
-
 
5942
		netflow_export_flow(&nf);
-
 
5943
	} else { /* v5 */
-
 
5944
		/* The weird v5 packet(s).
-
 
5945
		 * src and dst will be same as in data flow from the FORWARD chain
-
 
5946
		 * where src is pre-nat src ip and dst is post-nat dst ip.
-
 
5947
		 * What we lacking here is external src ip for SNAT, or
-
 
5948
		 * pre-nat dst ip for DNAT. We will put this into Nexthop field
-
 
5949
		 * with port into src/dst AS field. tcp_flags will distinguish it's
-
 
5950
		 * start or stop event. Two flows in case of full nat. */
-
 
5951
		nf.tuple.src.ip = nel->pre.s_addr;
-
 
5952
		nf.tuple.s_port = nel->pre.s_port;
-
 
5953
		nf.tuple.dst.ip = nel->post.d_addr;
-
 
5954
		nf.tuple.d_port = nel->post.d_port;
-
 
5955
 
-
 
5956
		nf.nf_ts_first = nel->ts_jiffies;
-
 
5957
		nf.nf_ts_last = nel->ts_jiffies;
-
 
5958
		if (nel->pre.s_addr != nel->post.s_addr ||
-
 
5959
		    nel->pre.s_port != nel->post.s_port) {
-
 
5960
			nf.nh.ip = nel->post.s_addr;
-
 
5961
			nf.s_as  = nel->post.s_port;
-
 
5962
			nf.d_as  = 0;
-
 
5963
			netflow_export_flow(&nf);
-
 
5964
		}
-
 
5965
		if (nel->pre.d_addr != nel->post.d_addr ||
-
 
5966
		    nel->pre.d_port != nel->post.d_port) {
-
 
5967
			nf.nh.ip = nel->pre.d_addr;
-
 
5968
			nf.s_as  = 0;
-
 
5969
			nf.d_as  = nel->pre.d_port;
-
 
5970
			netflow_export_flow(&nf);
-
 
5971
		}
-
 
5972
	}
-
 
5973
	kfree(nel);
-
 
5974
}
-
 
5975
#endif /* CONFIG_NF_NAT_NEEDED */
-
 
5976
 
-
 
5977
static inline int active_needs_export(const struct ipt_netflow *nf, const long a_timeout,
-
 
5978
    const unsigned long j)
-
 
5979
{
-
 
5980
	return ((j - nf->nf_ts_first) > a_timeout) ||
-
 
5981
	    nf->nr_bytes >= FLOW_FULL_WATERMARK;
-
 
5982
}
-
 
5983
 
-
 
5984
/* return flowEndReason (rfc5102) */
-
 
5985
/* i_timeout == 0 is flush */
-
 
5986
static inline int inactive_needs_export(const struct ipt_netflow *nf, const long i_timeout,
-
 
5987
    const unsigned long j)
-
 
5988
{
-
 
5989
	if (likely(i_timeout)) {
-
 
5990
		if (unlikely((j - nf->nf_ts_last) > i_timeout)) {
-
 
5991
			if (nf->tuple.protocol == IPPROTO_TCP &&
-
 
5992
			    (nf->tcp_flags & TCP_FIN_RST))
-
 
5993
				return 0x03; /* end of Flow detected */
-
 
5994
			else
-
 
5995
				return 0x01; /* idle timeout */
-
 
5996
		} else
-
 
5997
			return 0;
-
 
5998
	} else
-
 
5999
		return 0x04; /* forced end */
-
 
6000
}
-
 
6001
 
-
 
6002
/* helper which also record to nf->flowEndReason */
-
 
6003
static inline int needs_export_rec(struct ipt_netflow *nf, const long i_timeout,
-
 
6004
    const long a_timeout, const unsigned long j)
-
 
6005
{
-
 
6006
	int reason = inactive_needs_export(nf, i_timeout, j);
-
 
6007
 
-
 
6008
	if (!reason && active_needs_export(nf, a_timeout, j))
-
 
6009
		reason = 0x02; /* active timeout or just active flow */
-
 
6010
	return (nf->flowEndReason = reason);
-
 
6011
}
-
 
6012
 
-
 
6013
/* could be called with zero to flush cache and pdu */
-
 
6014
/* this function is guaranteed to be called non-concurrently */
-
 
6015
/* return number of pdus sent */
-
 
6016
static int netflow_scan_and_export(const int flush)
-
 
6017
{
-
 
6018
	const long i_timeout = flush? 0 : inactive_timeout * HZ;
-
 
6019
	const long a_timeout = active_timeout * HZ;
-
 
6020
#ifdef HAVE_LLIST
-
 
6021
	struct llist_node *node;
-
 
6022
#endif
-
 
6023
	const int pdu_c = pdu_count;
-
 
6024
	LIST_HEAD(export_list);
-
 
6025
	struct ipt_netflow *nf, *tmp;
-
 
6026
	int i;
-
 
6027
#ifdef ENABLE_SAMPLER
-
 
6028
	unsigned char mode;
-
 
6029
#endif
-
 
6030
 
-
 
6031
	if (protocol >= 9) {
-
 
6032
		netflow_export_stats();
-
 
6033
#ifdef ENABLE_SAMPLER
-
 
6034
		export_sampler_parameters();
-
 
6035
#endif
-
 
6036
		export_ifnames();
-
 
6037
	}
-
 
6038
 
-
 
6039
	read_lock_bh(&htable_rwlock);
-
 
6040
	for (i = 0; i < LOCK_COUNT; i++) {
-
 
6041
		struct stripe_entry *stripe = &htable_stripes[i];
-
 
6042
 
-
 
6043
		if (!spin_trylock(&stripe->lock)) {
-
 
6044
			++wk_trylock;
-
 
6045
			continue;
-
 
6046
		}
-
 
6047
		list_for_each_entry_safe_reverse(nf, tmp, &stripe->list, flows_list) {
-
 
6048
			++wk_count;
-
 
6049
			if (needs_export_rec(nf, i_timeout, a_timeout, jiffies)) {
-
 
6050
				hlist_del(&nf->hlist);
-
 
6051
				list_del(&nf->flows_list);
-
 
6052
				list_add(&nf->flows_list, &export_list);
-
 
6053
			} else {
-
 
6054
				/* all flows which need to be exported is always at the tail
-
 
6055
				 * so if no more exportable flows we can break */
-
 
6056
				break;
-
 
6057
			}
-
 
6058
		}
-
 
6059
		spin_unlock(&stripe->lock);
-
 
6060
	}
-
 
6061
	read_unlock_bh(&htable_rwlock);
-
 
6062
 
-
 
6063
#ifdef HAVE_LLIST
-
 
6064
	node = llist_del_all(&export_llist);
-
 
6065
	while (node) {
-
 
6066
		struct llist_node *next = node->next;
-
 
6067
		nf = llist_entry(node, struct ipt_netflow, flows_llnode);
-
 
6068
		++wk_llist;
-
 
6069
		list_add(&nf->flows_list, &export_list);
-
 
6070
		node = next;
-
 
6071
	}
-
 
6072
#endif
-
 
6073
 
-
 
6074
#ifdef ENABLE_SAMPLER
-
 
6075
	mode = get_sampler_mode();
-
 
6076
#endif
-
 
6077
	set_jiffies_base();
-
 
6078
	list_for_each_entry_safe(nf, tmp, &export_list, flows_list) {
-
 
6079
		NETFLOW_STAT_ADD(pkt_out, nf->nr_packets);
-
 
6080
		NETFLOW_STAT_ADD(traf_out, nf->nr_bytes);
-
 
6081
		list_del(&nf->flows_list);
-
 
6082
#ifdef ENABLE_SAMPLER
-
 
6083
		if (mode) {
-
 
6084
			const unsigned int interval = get_sampler_interval();
-
 
6085
			unsigned int val; /* [0..interval) */
-
 
6086
 
-
 
6087
			atomic64_inc(&flows_observed);
-
 
6088
			NETFLOW_STAT_ADD_ATOMIC(pkts_observed, nf->nr_packets);
-
 
6089
			switch (mode) {
-
 
6090
			case SAMPLER_DETERMINISTIC:
-
 
6091
				val = nf->sampler_count % interval;
-
 
6092
				break;
-
 
6093
			case SAMPLER_RANDOM:
-
 
6094
				val = prandom_u32_max(interval);
-
 
6095
				break;
-
 
6096
			default: /* SAMPLER_HASH */
-
 
6097
				val = 0;
-
 
6098
			}
-
 
6099
			if (val) {
-
 
6100
				ipt_netflow_free(nf);
-
 
6101
				continue;
-
 
6102
			}
-
 
6103
			atomic64_inc(&flows_selected);
-
 
6104
			NETFLOW_STAT_ADD_ATOMIC(pkts_selected, nf->nr_packets);
-
 
6105
		}
-
 
6106
#endif
-
 
6107
		netflow_export_flow(nf);
-
 
6108
	}
-
 
6109
 
-
 
6110
#ifdef CONFIG_NF_NAT_NEEDED
-
 
6111
	spin_lock_bh(&nat_lock);
-
 
6112
	while (!list_empty(&nat_list)) {
-
 
6113
		struct nat_event *nel;
-
 
6114
 
-
 
6115
		nel = list_entry(nat_list.next, struct nat_event, list);
-
 
6116
		list_del(&nel->list);
-
 
6117
		spin_unlock_bh(&nat_lock);
-
 
6118
		export_nat_event(nel);
-
 
6119
		spin_lock_bh(&nat_lock);
-
 
6120
	}
-
 
6121
	spin_unlock_bh(&nat_lock);
-
 
6122
#endif
-
 
6123
	/* flush flows stored in pdu if there no new flows for too long */
-
 
6124
	/* Note: using >= to allow flow purge on zero timeout */
-
 
6125
	if ((jiffies - pdu_ts_mod) >= i_timeout || pdu_needs_export) {
-
 
6126
		netflow_export_pdu();
-
 
6127
		pdu_needs_export = 0;
-
 
6128
	}
-
 
6129
 
-
 
6130
	return pdu_count - pdu_c;
-
 
6131
}
-
 
6132
 
-
 
6133
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-
 
6134
static void netflow_work_fn(void *dummy)
-
 
6135
#else
-
 
6136
static void netflow_work_fn(struct work_struct *dummy)
-
 
6137
#endif
-
 
6138
{
-
 
6139
	int pdus;
-
 
6140
 
-
 
6141
	wk_count = 0;
-
 
6142
	wk_trylock = 0;
-
 
6143
	wk_llist = 0;
-
 
6144
	wk_cpu = smp_processor_id();
-
 
6145
	wk_start = jiffies;
-
 
6146
 
-
 
6147
	pdus = netflow_scan_and_export(DONT_FLUSH);
-
 
6148
 
-
 
6149
	_schedule_scan_worker(pdus);
-
 
6150
	wk_busy = jiffies - wk_start;
-
 
6151
}
-
 
6152
 
-
 
6153
#define RATESHIFT 2
-
 
6154
#define SAMPLERATE (RATESHIFT*RATESHIFT)
-
 
6155
#define NUMSAMPLES(minutes) (minutes * 60 / SAMPLERATE)
-
 
6156
#define _A(v, m) (v) * (1024 * 2 / (NUMSAMPLES(m) + 1)) >> 10
-
 
6157
// x * (1024 / y) >> 10 is because I can not just divide long long integer
-
 
6158
 
-
 
6159
// Note that CALC_RATE arguments should never be unsigned.
-
 
6160
#define CALC_RATE(ewma, cur, minutes) ewma += _A(cur - ewma, minutes)
-
 
6161
 
-
 
6162
// calculate EWMA throughput rate for whole module
-
 
6163
static void rate_timer_calc(unsigned long dummy)
-
 
6164
{
-
 
6165
	static u64 old_pkt_total = 0;
-
 
6166
	static u64 old_traf_total = 0;
-
 
6167
	static u64 old_searched = 0;
-
 
6168
	static u64 old_found = 0;
-
 
6169
	static u64 old_notfound = 0;
-
 
6170
	u64 searched = 0;
-
 
6171
	u64 found = 0;
-
 
6172
	u64 notfound = 0;
-
 
6173
	int dsrch, dfnd, dnfnd;
-
 
6174
	u64 pkt_total = 0;
-
 
6175
	u64 traf_total = 0;
-
 
6176
	int cpu;
-
 
6177
 
-
 
6178
	for_each_present_cpu(cpu) {
-
 
6179
		int metrt;
-
 
6180
		struct ipt_netflow_stat *st = &per_cpu(ipt_netflow_stat, cpu);
-
 
6181
		u64 pkt_t = st->pkt_total;
-
 
6182
 
-
 
6183
		pkt_total += pkt_t;
-
 
6184
		st->pkt_total_rate = (pkt_t - st->pkt_total_prev) >> RATESHIFT;
-
 
6185
		st->pkt_total_prev = pkt_t;
-
 
6186
		traf_total += st->traf_total;
-
 
6187
		searched += st->searched;
-
 
6188
		found += st->found;
-
 
6189
		notfound += st->notfound;
-
 
6190
		st->exported_rate = (st->exported_traf - st->exported_trafo) >> RATESHIFT;
-
 
6191
		st->exported_trafo = st->exported_traf;
-
 
6192
		/* calculate hash metric per cpu */
-
 
6193
		dsrch = st->searched - st->old_searched;
-
 
6194
		dfnd  = st->found - st->old_found;
-
 
6195
		dnfnd = st->notfound - st->old_notfound;
-
 
6196
		/* zero values are not accounted, becasue only usage is interesting, not nonusage */
-
 
6197
		metrt = (dfnd + dnfnd)? 100 * (dsrch + dfnd + dnfnd) / (dfnd + dnfnd) : st->metric;
-
 
6198
		CALC_RATE(st->metric, metrt, 1);
-
 
6199
		st->old_searched = st->searched;
-
 
6200
		st->old_found    = st->found;
-
 
6201
		st->old_notfound = st->notfound;
-
 
6202
	}
-
 
6203
 
-
 
6204
	sec_prate = (pkt_total - old_pkt_total) >> RATESHIFT;
-
 
6205
	CALC_RATE(min5_prate, sec_prate, 5);
-
 
6206
	CALC_RATE(min_prate, sec_prate, 1);
-
 
6207
	old_pkt_total = pkt_total;
-
 
6208
 
-
 
6209
	sec_brate = ((traf_total - old_traf_total) * 8) >> RATESHIFT;
-
 
6210
	CALC_RATE(min5_brate, sec_brate, 5);
-
 
6211
	CALC_RATE(min_brate, sec_brate, 1);
-
 
6212
	old_traf_total = traf_total;
-
 
6213
 
-
 
6214
	/* hash stat */
-
 
6215
	dsrch = searched - old_searched;
-
 
6216
	dfnd  = found - old_found;
-
 
6217
	dnfnd = notfound - old_notfound;
-
 
6218
	old_searched = searched;
-
 
6219
	old_found    = found;
-
 
6220
	old_notfound = notfound;
-
 
6221
	/* if there is no access to hash keep rate steady */
-
 
6222
	metric = (dfnd + dnfnd)? 100 * (dsrch + dfnd + dnfnd) / (dfnd + dnfnd) : metric;
-
 
6223
	CALC_RATE(min15_metric, metric, 15);
-
 
6224
	CALC_RATE(min5_metric, metric, 5);
-
 
6225
	CALC_RATE(min_metric, metric, 1);
-
 
6226
 
-
 
6227
	/* yes, timer delay is not accounted, but this stat is just estimational */
-
 
6228
	mod_timer(&rate_timer, jiffies + (HZ * SAMPLERATE));
-
 
6229
}
-
 
6230
 
-
 
6231
#ifdef CONFIG_NF_NAT_NEEDED
-
 
6232
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
6233
static struct nf_ct_event_notifier *saved_event_cb __read_mostly = NULL;
-
 
6234
static int netflow_conntrack_event(const unsigned int events, struct nf_ct_event *item)
-
 
6235
#else
-
 
6236
static int netflow_conntrack_event(struct notifier_block *this, unsigned long events, void *ptr)
-
 
6237
#endif
-
 
6238
{
-
 
6239
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
6240
	struct nf_conn *ct = item->ct;
-
 
6241
#else
-
 
6242
	struct nf_conn *ct = (struct nf_conn *)ptr;
-
 
6243
#endif
-
 
6244
	struct nat_event *nel;
-
 
6245
	const struct nf_conntrack_tuple *t;
-
 
6246
	int ret = NOTIFY_DONE;
-
 
6247
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
6248
	struct nf_ct_event_notifier *notifier;
-
 
6249
 
-
 
6250
	/* Call netlink first. */
-
 
6251
	notifier = rcu_dereference(saved_event_cb);
-
 
6252
	if (likely(notifier))
-
 
6253
		ret = notifier->fcn(events, item);
-
 
6254
#endif
-
 
6255
	if (unlikely(!natevents))
-
 
6256
		return ret;
-
 
6257
 
-
 
6258
	if (!(events & ((1 << IPCT_NEW) | (1 << IPCT_RELATED) | (1 << IPCT_DESTROY))))
-
 
6259
		return ret;
-
 
6260
 
-
 
6261
	if (!(ct->status & IPS_NAT_MASK))
-
 
6262
		return ret;
-
 
6263
 
-
 
6264
	if (unlikely(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num != AF_INET ||
-
 
6265
		    ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num != AF_INET)) {
-
 
6266
		/* Well, there is no linux NAT for IPv6 anyway. */
-
 
6267
		return ret;
-
 
6268
	}
-
 
6269
 
-
 
6270
	if (!(nel = kmalloc(sizeof(struct nat_event), GFP_ATOMIC))) {
-
 
6271
		printk(KERN_ERR "ipt_NETFLOW: can't kmalloc nat event\n");
-
 
6272
		return ret;
-
 
6273
	}
-
 
6274
	memset(nel, 0, sizeof(struct nat_event));
-
 
6275
	nel->ts_ktime = ktime_get_real();
-
 
6276
	nel->ts_jiffies = jiffies;
-
 
6277
	t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
-
 
6278
	nel->protocol = t->dst.protonum;
-
 
6279
	nel->pre.s_addr = t->src.u3.ip;
-
 
6280
	nel->pre.d_addr = t->dst.u3.ip;
-
 
6281
	nel->pre.s_port = t->src.u.all;
-
 
6282
	nel->pre.d_port = t->dst.u.all;
-
 
6283
	t = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
-
 
6284
	/* reply is reversed */
-
 
6285
	nel->post.s_addr = t->dst.u3.ip;
-
 
6286
	nel->post.d_addr = t->src.u3.ip;
-
 
6287
	nel->post.s_port = t->dst.u.all;
-
 
6288
	nel->post.d_port = t->src.u.all;
-
 
6289
	if (events & (1 << IPCT_DESTROY)) {
-
 
6290
		nel->nat_event = NAT_DESTROY;
-
 
6291
		nat_events_stop++;
-
 
6292
	} else {
-
 
6293
		nel->nat_event = NAT_CREATE;
-
 
6294
		nat_events_start++;
-
 
6295
	}
-
 
6296
 
-
 
6297
	spin_lock_bh(&nat_lock);
-
 
6298
	list_add_tail(&nel->list, &nat_list);
-
 
6299
	spin_unlock_bh(&nat_lock);
-
 
6300
 
-
 
6301
	return ret;
-
 
6302
}
-
 
6303
 
-
 
6304
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
-
 
6305
static struct notifier_block ctnl_notifier = {
-
 
6306
	.notifier_call = netflow_conntrack_event
-
 
6307
};
-
 
6308
#else
-
 
6309
static struct nf_ct_event_notifier ctnl_notifier = {
-
 
6310
	.fcn = netflow_conntrack_event
-
 
6311
};
-
 
6312
#endif /* since 2.6.31 */
-
 
6313
#endif /* CONFIG_NF_NAT_NEEDED */
-
 
6314
 
-
 
6315
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) && \
-
 
6316
    LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
-
 
6317
static bool
-
 
6318
#else
-
 
6319
static int
-
 
6320
#endif
-
 
6321
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
-
 
6322
netflow_target_check(const char *tablename, const void *entry, const struct xt_target *target,
-
 
6323
    void *targinfo,
-
 
6324
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
-
 
6325
    unsigned int targinfosize,
-
 
6326
#endif
-
 
6327
    unsigned int hook_mask)
-
 
6328
{
-
 
6329
#else
-
 
6330
netflow_target_check(const struct xt_tgchk_param *par)
-
 
6331
{
-
 
6332
	const char *tablename = par->table;
-
 
6333
	const struct xt_target *target = par->target;
-
 
6334
#endif
-
 
6335
	if (strcmp("nat", tablename) == 0) {
-
 
6336
		/* In the nat table we only see single packet per flow, which is useless. */
-
 
6337
		printk(KERN_ERR "%s target: is not valid in %s table\n", target->name, tablename);
-
 
6338
		return CHECK_FAIL;
-
 
6339
	}
-
 
6340
	if (target->family == AF_INET6 && protocol == 5) {
-
 
6341
		printk(KERN_ERR "ip6tables NETFLOW target is meaningful for protocol 9 or 10 only.\n");
-
 
6342
		return CHECK_FAIL;
-
 
6343
	}
-
 
6344
	return CHECK_OK;
-
 
6345
}
-
 
6346
 
-
 
6347
#define SetXBit(x) (0x8000 >> (x)) /* Proper bit for htons later. */
-
 
6348
static inline __u16 observed_hdrs(const __u8 currenthdr)
-
 
6349
{
-
 
6350
	switch (currenthdr) {
-
 
6351
	case IPPROTO_TCP:
-
 
6352
	case IPPROTO_UDP:
-
 
6353
		/* For speed, in case switch is not optimized. */
-
 
6354
		return 0;
-
 
6355
	case IPPROTO_DSTOPTS:  return SetXBit(0);
-
 
6356
	case IPPROTO_HOPOPTS:  return SetXBit(1);
-
 
6357
	case IPPROTO_ROUTING:  return SetXBit(5);
-
 
6358
	case IPPROTO_MH:       return SetXBit(12);
-
 
6359
	case IPPROTO_ESP:      return SetXBit(13);
-
 
6360
	case IPPROTO_AH:       return SetXBit(14);
-
 
6361
	case IPPROTO_COMP:     return SetXBit(15);
-
 
6362
	case IPPROTO_FRAGMENT: /* Handled elsewhere. */
-
 
6363
		/* Next is known headers. */
-
 
6364
	case IPPROTO_ICMPV6:
-
 
6365
	case IPPROTO_UDPLITE:
-
 
6366
	case IPPROTO_IPIP:
-
 
6367
	case IPPROTO_PIM:
-
 
6368
	case IPPROTO_GRE:
-
 
6369
	case IPPROTO_SCTP:
-
 
6370
#ifdef IPPROTO_L2TP
-
 
6371
	case IPPROTO_L2TP:
-
 
6372
#endif
-
 
6373
	case IPPROTO_DCCP:
-
 
6374
	       return 0;
-
 
6375
	}
-
 
6376
	return SetXBit(3); /* Unknown header. */
-
 
6377
}
-
 
6378
 
-
 
6379
/* http://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml */
-
 
6380
static const __u8 ip4_opt_table[] = {
-
 
6381
	[7]	= 0,	/* RR */ /* parsed manually because of 0 */
-
 
6382
	[134]	= 1,	/* CIPSO */
-
 
6383
	[133]	= 2,	/* E-SEC */
-
 
6384
	[68]	= 3,	/* TS */
-
 
6385
	[131]	= 4,	/* LSR */
-
 
6386
	[130]	= 5,	/* SEC */
-
 
6387
	[1]	= 6,	/* NOP */
-
 
6388
	[0]	= 7,	/* EOOL */
-
 
6389
	[15]	= 8,	/* ENCODE */
-
 
6390
	[142]	= 9,	/* VISA */
-
 
6391
	[205]	= 10,	/* FINN */
-
 
6392
	[12]	= 11,	/* MTUR */
-
 
6393
	[11]	= 12,	/* MTUP */
-
 
6394
	[10]	= 13,	/* ZSU */
-
 
6395
	[137]	= 14,	/* SSR */
-
 
6396
	[136]	= 15,	/* SID */
-
 
6397
	[151]	= 16,	/* DPS */
-
 
6398
	[150]	= 17,	/* NSAPA */
-
 
6399
	[149]	= 18,	/* SDB */
-
 
6400
	[147]	= 19,	/* ADDEXT */
-
 
6401
	[148]	= 20,	/* RTRALT */
-
 
6402
	[82]	= 21,	/* TR */
-
 
6403
	[145]	= 22,	/* EIP */
-
 
6404
	[144]	= 23,	/* IMITD */
-
 
6405
	[30]	= 25,	/* EXP */
-
 
6406
	[94]	= 25,	/* EXP */
-
 
6407
	[158]	= 25,	/* EXP */
-
 
6408
	[222]	= 25,	/* EXP */
-
 
6409
	[25]	= 30,	/* QS */
-
 
6410
	[152]	= 31,	/* UMP */
-
 
6411
};
-
 
6412
/* Parse IPv4 Options array int ipv4Options IPFIX value. */
-
 
6413
static inline __u32 ip4_options(const u_int8_t *p, const unsigned int optsize)
-
 
6414
{
-
 
6415
	__u32 ret = 0;
-
 
6416
	unsigned int i;
-
 
6417
 
-
 
6418
	for (i = 0; likely(i < optsize); ) {
-
 
6419
		u_int8_t op = p[i++];
-
 
6420
 
-
 
6421
		if (op == 7) /* RR: bit 0 */
-
 
6422
			ret |= 1;
-
 
6423
		else if (likely(op < ARRAY_SIZE(ip4_opt_table))) {
-
 
6424
			/* Btw, IANA doc is messed up in a crazy way:
-
 
6425
			 *   http://www.ietf.org/mail-archive/web/ipfix/current/msg06008.html (2011)
-
 
6426
			 * I decided to follow IANA _text_ description from
-
 
6427
			 *   http://www.iana.org/assignments/ipfix/ipfix.xhtml (2013-09-18)
-
 
6428
			 *
-
 
6429
			 * Set proper bit for htonl later. */
-
 
6430
			if (ip4_opt_table[op])
-
 
6431
				ret |= 1 << (32 - ip4_opt_table[op]);
-
 
6432
		}
-
 
6433
		if (likely(i >= optsize || op == 0))
-
 
6434
			break;
-
 
6435
		else if (unlikely(op == 1))
-
 
6436
			continue;
-
 
6437
		else if (unlikely(p[i] < 2))
-
 
6438
			break;
-
 
6439
		else
-
 
6440
			i += p[i] - 1;
-
 
6441
	}
-
 
6442
	return ret;
-
 
6443
}
-
 
6444
 
-
 
6445
#define TCPHDR_MAXSIZE (4 * 15)
-
 
6446
/* List of options: http://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml */
-
 
6447
static inline __u32 tcp_options(const struct sk_buff *skb, const unsigned int ptr, const struct tcphdr *th)
-
 
6448
{
-
 
6449
	const unsigned int optsize = th->doff * 4 - sizeof(struct tcphdr);
-
 
6450
	__u8 _opt[TCPHDR_MAXSIZE];
-
 
6451
	const u_int8_t *p;
-
 
6452
	__u32 ret;
-
 
6453
	unsigned int i;
-
 
6454
 
-
 
6455
	p = skb_header_pointer(skb, ptr + sizeof(struct tcphdr), optsize, _opt);
-
 
6456
	if (unlikely(!p))
-
 
6457
		return 0;
-
 
6458
	ret = 0;
-
 
6459
	for (i = 0; likely(i < optsize); ) {
-
 
6460
		u_int8_t opt = p[i++];
-
 
6461
 
-
 
6462
		if (likely(opt < 32)) {
-
 
6463
			/* IANA doc is messed up, see above. */
-
 
6464
			ret |= 1 << (32 - opt);
-
 
6465
		}
-
 
6466
		if (likely(i >= optsize || opt == 0))
-
 
6467
			break;
-
 
6468
		else if (unlikely(opt == 1))
-
 
6469
			continue;
-
 
6470
		else if (unlikely(p[i] < 2)) /* "silly options" */
-
 
6471
			break;
-
 
6472
		else
-
 
6473
			i += p[i] - 1;
-
 
6474
	}
-
 
6475
	return ret;
-
 
6476
}
-
 
6477
 
-
 
6478
/* check if data region is in header boundary */
-
 
6479
inline static int skb_in_header(const struct sk_buff *skb, const void *ptr, size_t off)
-
 
6480
{
-
 
6481
	return ((unsigned char *)ptr + off) <= skb->data;
-
 
6482
}
-
 
6483
 
-
 
6484
static inline int eth_p_vlan(__be16 eth_type)
-
 
6485
{
-
 
6486
	return eth_type == htons(ETH_P_8021Q) ||
-
 
6487
		eth_type == htons(ETH_P_8021AD);
-
 
6488
}
-
 
6489
 
-
 
6490
/* Extract all L2 header data, currently (in iptables) skb->data is
-
 
6491
 * pointing to network_header, so we use mac_header instead. */
-
 
6492
/* Parse eth header, then vlans, then mpls. */
-
 
6493
static void parse_l2_header(const struct sk_buff *skb, struct ipt_netflow_tuple *tuple)
-
 
6494
{
-
 
6495
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN) || defined(MPLS_DEPTH)
-
 
6496
#define ENABLE_L2
-
 
6497
	unsigned char *mac_header = skb_mac_header(skb);
-
 
6498
# if defined(ENABLE_VLAN) || defined(MPLS_DEPTH)
-
 
6499
	unsigned int hdr_depth;
-
 
6500
	__be16 proto;
-
 
6501
# endif
-
 
6502
# ifdef ENABLE_VLAN
-
 
6503
	int tag_num = 0;
-
 
6504
 
-
 
6505
	/* get vlan tag that is saved in skb->vlan_tci */
-
 
6506
	if (vlan_tx_tag_present(skb))
-
 
6507
		tuple->tag[tag_num++] = htons(vlan_tx_tag_get(skb));
-
 
6508
# endif
-
 
6509
	if (mac_header < skb->head ||
-
 
6510
	    mac_header + ETH_HLEN > skb->data)
-
 
6511
		return;
-
 
6512
# ifdef ENABLE_MAC
-
 
6513
	memcpy(&tuple->h_dst, eth_hdr(skb)->h_dest, ETH_ALEN);
-
 
6514
	memcpy(&tuple->h_src, eth_hdr(skb)->h_source, ETH_ALEN);
-
 
6515
# endif
-
 
6516
# if defined(ENABLE_VLAN) || defined(MPLS_DEPTH)
-
 
6517
	hdr_depth = ETH_HLEN;
-
 
6518
	proto = eth_hdr(skb)->h_proto;
-
 
6519
	if (eth_p_vlan(proto)) {
-
 
6520
		do {
-
 
6521
			const struct vlan_hdr *vh;
-
 
6522
 
-
 
6523
			vh = (struct vlan_hdr *)(mac_header + hdr_depth);
-
 
6524
			if (!skb_in_header(skb, vh, VLAN_HLEN))
-
 
6525
				return;
-
 
6526
			proto = vh->h_vlan_encapsulated_proto;
-
 
6527
#  ifdef ENABLE_VLAN
-
 
6528
			if (tag_num < MAX_VLAN_TAGS)
-
 
6529
				tuple->tag[tag_num++] = vh->h_vlan_TCI;
-
 
6530
#  endif
-
 
6531
			hdr_depth += VLAN_HLEN;
-
 
6532
		} while (eth_p_vlan(proto));
-
 
6533
	}
-
 
6534
#  ifdef MPLS_DEPTH
-
 
6535
	if (eth_p_mpls(proto)) {
-
 
6536
		const struct mpls_label *mpls;
-
 
6537
		int label_num = 0;
-
 
6538
 
-
 
6539
		do {
-
 
6540
			mpls = (struct mpls_label *)(mac_header + hdr_depth);
-
 
6541
			if (!skb_in_header(skb, mpls, MPLS_HLEN))
-
 
6542
				return;
-
 
6543
			if (label_num < MPLS_DEPTH)
-
 
6544
				tuple->mpls[label_num++] = mpls->entry;
-
 
6545
			hdr_depth += MPLS_HLEN;
-
 
6546
		} while (!(mpls->entry & htonl(MPLS_LS_S_MASK)));
-
 
6547
	}
-
 
6548
#  endif
-
 
6549
# endif /* defined(ENABLE_VLAN) || defined(MPLS_DEPTH) */
-
 
6550
#endif /* defined(ENABLE_MAC) || defined(ENABLE_VLAN) || defined(MPLS_DEPTH) */
-
 
6551
}
-
 
6552
 
-
 
6553
/* packet receiver */
-
 
6554
static unsigned int netflow_target(
-
 
6555
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
-
 
6556
			   struct sk_buff **pskb,
-
 
6557
#else
-
 
6558
			   struct sk_buff *skb,
-
 
6559
#endif
-
 
6560
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
-
 
6561
			   const struct net_device *if_in,
-
 
6562
			   const struct net_device *if_out,
-
 
6563
			   unsigned int hooknum,
-
 
6564
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
-
 
6565
			   const struct xt_target *target,
-
 
6566
# endif
-
 
6567
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-
 
6568
			   const void *targinfo,
-
 
6569
			   void *userinfo
-
 
6570
# else
-
 
6571
			   const void *targinfo
-
 
6572
# endif
-
 
6573
#else /* since 2.6.28 */
-
 
6574
# define if_in  xt_in(par)
-
 
6575
# define if_out xt_out(par)
-
 
6576
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
-
 
6577
			   const struct xt_target_param *par
-
 
6578
# else
-
 
6579
			   const struct xt_action_param *par
-
 
6580
# endif
-
 
6581
#endif
-
 
6582
		)
-
 
6583
{
-
 
6584
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
-
 
6585
# ifndef ENABLE_L2
-
 
6586
	/* pskb_may_pull() may modify skb */
-
 
6587
	const
-
 
6588
# endif
-
 
6589
		struct sk_buff *skb = *pskb;
-
 
6590
#endif
-
 
6591
	union {
-
 
6592
		struct iphdr ip;
-
 
6593
		struct ipv6hdr ip6;
-
 
6594
	} _iph, *iph;
-
 
6595
	u_int32_t hash;
-
 
6596
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
-
 
6597
	const int family = target->family;
-
 
6598
#else
-
 
6599
# ifdef ENABLE_DIRECTION
-
 
6600
	const int hooknum = xt_hooknum(par);
-
 
6601
# endif
-
 
6602
	const int family = xt_family(par);
-
 
6603
#endif
-
 
6604
	struct ipt_netflow_tuple tuple;
-
 
6605
	struct ipt_netflow *nf;
-
 
6606
	__u8 tcp_flags;
-
 
6607
#ifdef ENABLE_AGGR
-
 
6608
	struct netflow_aggr_n *aggr_n;
-
 
6609
	struct netflow_aggr_p *aggr_p;
-
 
6610
#endif
-
 
6611
	__u8 s_mask, d_mask;
-
 
6612
	unsigned int ptr;
-
 
6613
	int fragment;
-
 
6614
	size_t pkt_len;
-
 
6615
	int options = 0;
-
 
6616
	int tcpoptions = 0;
-
 
6617
	struct stripe_entry *stripe;
-
 
6618
 
-
 
6619
	if (unlikely(
-
 
6620
#ifdef ENABLE_L2
-
 
6621
	    /* to ensure that full L2 headers are present */
-
 
6622
	    unlikely(!pskb_may_pull(skb, 0)) ||
-
 
6623
#endif
-
 
6624
	    !(iph = skb_header_pointer(skb, 0,
-
 
6625
			    (likely(family == AF_INET))? sizeof(_iph.ip) : sizeof(_iph.ip6),
-
 
6626
			    &iph)))) {
-
 
6627
		NETFLOW_STAT_INC(truncated);
-
 
6628
		NETFLOW_STAT_INC(pkt_drop);
-
 
6629
		NETFLOW_STAT_ADD(traf_drop, skb->len);
-
 
6630
		NETFLOW_STAT_TS(drop);
-
 
6631
		return IPT_CONTINUE;
-
 
6632
	}
-
 
6633
 
-
 
6634
	memset(&tuple, 0, sizeof(tuple));
-
 
6635
	tuple.l3proto = family;
-
 
6636
#ifdef ENABLE_PHYSDEV_OVER
-
 
6637
	if (skb->nf_bridge && skb->nf_bridge->physindev)
-
 
6638
		tuple.i_ifc = skb->nf_bridge->physindev->ifindex;
-
 
6639
	else /* FALLTHROUGH */
-
 
6640
#endif
-
 
6641
	tuple.i_ifc	= if_in? if_in->ifindex : -1;
-
 
6642
	tcp_flags	= 0;
-
 
6643
	s_mask		= 0;
-
 
6644
	d_mask		= 0;
-
 
6645
	parse_l2_header(skb, &tuple);
-
 
6646
 
-
 
6647
	if (likely(family == AF_INET)) {
-
 
6648
		tuple.src	= (union nf_inet_addr){ .ip = iph->ip.saddr };
-
 
6649
		tuple.dst	= (union nf_inet_addr){ .ip = iph->ip.daddr };
-
 
6650
		tuple.tos	= iph->ip.tos;
-
 
6651
		tuple.protocol	= iph->ip.protocol;
-
 
6652
		fragment	= unlikely(iph->ip.frag_off & htons(IP_OFFSET));
-
 
6653
		ptr		= iph->ip.ihl * 4;
-
 
6654
		pkt_len		= ntohs(iph->ip.tot_len);
-
 
6655
 
-
 
6656
#define IPHDR_MAXSIZE (4 * 15)
-
 
6657
		if (unlikely(iph->ip.ihl * 4 > sizeof(struct iphdr))) {
-
 
6658
			u_int8_t _opt[IPHDR_MAXSIZE - sizeof(struct iphdr)];
-
 
6659
			const u_int8_t *op;
-
 
6660
			unsigned int optsize = iph->ip.ihl * 4 - sizeof(struct iphdr);
-
 
6661
 
-
 
6662
			op = skb_header_pointer(skb, sizeof(struct iphdr), optsize, _opt);
-
 
6663
			if (likely(op))
-
 
6664
				options = ip4_options(op, optsize);
-
 
6665
		}
-
 
6666
	} else { /* AF_INET6 */
-
 
6667
		__u8 currenthdr;
-
 
6668
 
-
 
6669
		tuple.src.in6	= iph->ip6.saddr;
-
 
6670
		tuple.dst.in6	= iph->ip6.daddr;
-
 
6671
		tuple.tos	= iph->ip6.priority;
-
 
6672
		fragment	= 0;
-
 
6673
		ptr		= sizeof(struct ipv6hdr);
-
 
6674
		pkt_len		= ntohs(iph->ip6.payload_len) + sizeof(struct ipv6hdr);
-
 
6675
 
-
 
6676
		currenthdr	= iph->ip6.nexthdr;
-
 
6677
		while (currenthdr != NEXTHDR_NONE && ipv6_ext_hdr(currenthdr)) {
-
 
6678
			struct ipv6_opt_hdr _hdr;
-
 
6679
			const struct ipv6_opt_hdr *hp;
-
 
6680
			unsigned int hdrlen = 0;
-
 
6681
 
-
 
6682
			options |= observed_hdrs(currenthdr);
-
 
6683
			hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
-
 
6684
			if (hp == NULL) {
-
 
6685
				/* We have src/dst, so must account something. */
-
 
6686
				tuple.protocol = currenthdr;
-
 
6687
				fragment = 3;
-
 
6688
				goto do_protocols;
-
 
6689
			}
-
 
6690
 
-
 
6691
			switch (currenthdr) {
-
 
6692
			case IPPROTO_FRAGMENT: {
-
 
6693
				struct frag_hdr _fhdr;
-
 
6694
				const struct frag_hdr *fh;
-
 
6695
 
-
 
6696
				fh = skb_header_pointer(skb, ptr, sizeof(_fhdr),
-
 
6697
						&_fhdr);
-
 
6698
				if (fh == NULL) {
-
 
6699
					tuple.protocol = currenthdr;
-
 
6700
					fragment = 2;
-
 
6701
					goto do_protocols;
-
 
6702
				}
-
 
6703
				fragment = 1;
-
 
6704
#define FRA0 SetXBit(4) /* Fragment header - first fragment */
-
 
6705
#define FRA1 SetXBit(6) /* Fragmentation header - not first fragment */
-
 
6706
				options |= (ntohs(fh->frag_off) & 0xFFF8)? FRA1 : FRA0;
-
 
6707
				hdrlen = 8;
-
 
6708
				break;
-
 
6709
			}
-
 
6710
			case IPPROTO_AH: {
-
 
6711
				struct ip_auth_hdr _ahdr, *ap;
-
 
6712
 
-
 
6713
				if (likely(ap = skb_header_pointer(skb, ptr, 8, &_ahdr)))
-
 
6714
					SAVE_SPI(tuple, ap->spi);
-
 
6715
				hdrlen = (ap->hdrlen + 2) << 2;
-
 
6716
				break;
-
 
6717
			}
-
 
6718
			case IPPROTO_ESP:
-
 
6719
				/* After this header everything is encrypted. */
-
 
6720
				tuple.protocol = currenthdr;
-
 
6721
				goto do_protocols;
-
 
6722
			default:
-
 
6723
				hdrlen = ipv6_optlen(hp);
-
 
6724
			}
-
 
6725
			currenthdr = hp->nexthdr;
-
 
6726
			ptr += hdrlen;
-
 
6727
		}
-
 
6728
		tuple.protocol	= currenthdr;
-
 
6729
		options |= observed_hdrs(currenthdr);
-
 
6730
	}
-
 
6731
 
-
 
6732
do_protocols:
-
 
6733
	if (fragment) {
-
 
6734
		/* if conntrack is enabled it should defrag on pre-routing and local-out */
-
 
6735
		NETFLOW_STAT_INC(frags);
-
 
6736
	} else {
-
 
6737
		switch (tuple.protocol) {
-
 
6738
		    case IPPROTO_TCP: {
-
 
6739
			struct tcphdr _hdr, *hp;
-
 
6740
 
-
 
6741
			if (likely(hp = skb_header_pointer(skb, ptr, 14, &_hdr))) {
-
 
6742
				tuple.s_port = hp->source;
-
 
6743
				tuple.d_port = hp->dest;
-
 
6744
				tcp_flags = (u_int8_t)(ntohl(tcp_flag_word(hp)) >> 16);
-
 
6745
 
-
 
6746
				if (unlikely(hp->doff * 4 > sizeof(struct tcphdr)))
-
 
6747
					tcpoptions = tcp_options(skb, ptr, hp);
-
 
6748
			}
-
 
6749
			break;
-
 
6750
		    }
-
 
6751
		    case IPPROTO_UDP:
-
 
6752
		    case IPPROTO_UDPLITE:
-
 
6753
		    case IPPROTO_SCTP: {
-
 
6754
			struct udphdr _hdr, *hp;
-
 
6755
 
-
 
6756
			if (likely(hp = skb_header_pointer(skb, ptr, 4, &_hdr))) {
-
 
6757
				tuple.s_port = hp->source;
-
 
6758
				tuple.d_port = hp->dest;
-
 
6759
			}
-
 
6760
			break;
-
 
6761
		    }
-
 
6762
		    case IPPROTO_ICMP: {
-
 
6763
			struct icmphdr _hdr, *hp;
-
 
6764
 
-
 
6765
			if (likely(family == AF_INET) &&
-
 
6766
				    likely(hp = skb_header_pointer(skb, ptr, 2, &_hdr)))
-
 
6767
				tuple.d_port = htons((hp->type << 8) | hp->code);
-
 
6768
			break;
-
 
6769
		    }
-
 
6770
		    case IPPROTO_ICMPV6: {
-
 
6771
			struct icmp6hdr _icmp6h, *ic;
-
 
6772
 
-
 
6773
			if (likely(family == AF_INET6) &&
-
 
6774
				    likely(ic = skb_header_pointer(skb, ptr, 2, &_icmp6h)))
-
 
6775
				tuple.d_port = htons((ic->icmp6_type << 8) | ic->icmp6_code);
-
 
6776
			break;
-
 
6777
		    }
-
 
6778
		    case IPPROTO_IGMP: {
-
 
6779
			struct igmphdr _hdr, *hp;
-
 
6780
 
-
 
6781
			if (likely(hp = skb_header_pointer(skb, ptr, 1, &_hdr)))
-
 
6782
				tuple.d_port = hp->type;
-
 
6783
			break;
-
 
6784
		    }
-
 
6785
		    case IPPROTO_AH: { /* IPSEC */
-
 
6786
			struct ip_auth_hdr _hdr, *hp;
-
 
6787
 
-
 
6788
			/* This is for IPv4 only. IPv6 it's parsed above. */
-
 
6789
			if (likely(family == AF_INET) &&
-
 
6790
				    likely(hp = skb_header_pointer(skb, ptr, 8, &_hdr)))
-
 
6791
				SAVE_SPI(tuple, hp->spi);
-
 
6792
			break;
-
 
6793
		    }
-
 
6794
		    case IPPROTO_ESP: {
-
 
6795
			struct ip_esp_hdr _hdr, *hp;
-
 
6796
 
-
 
6797
			/* This is for both IPv4 and IPv6. */
-
 
6798
			if (likely(hp = skb_header_pointer(skb, ptr, 4, &_hdr)))
-
 
6799
				SAVE_SPI(tuple, hp->spi);
-
 
6800
			break;
-
 
6801
		    }
-
 
6802
	       	}
-
 
6803
	} /* not fragmented */
-
 
6804
 
-
 
6805
#ifdef ENABLE_AGGR
-
 
6806
	/* aggregate networks */
-
 
6807
	read_lock(&aggr_lock);
-
 
6808
	if (family == AF_INET) {
-
 
6809
		list_for_each_entry(aggr_n, &aggr_n_list, list)
-
 
6810
			if (unlikely((ntohl(tuple.src.ip) & aggr_n->mask) == aggr_n->addr)) {
-
 
6811
				tuple.src.ip &= htonl(aggr_n->aggr_mask);
-
 
6812
				s_mask = aggr_n->prefix;
-
 
6813
				atomic_inc(&aggr_n->usage);
-
 
6814
				break;
-
 
6815
			}
-
 
6816
		list_for_each_entry(aggr_n, &aggr_n_list, list)
-
 
6817
			if (unlikely((ntohl(tuple.dst.ip) & aggr_n->mask) == aggr_n->addr)) {
-
 
6818
				tuple.dst.ip &= htonl(aggr_n->aggr_mask);
-
 
6819
				d_mask = aggr_n->prefix;
-
 
6820
				atomic_inc(&aggr_n->usage);
-
 
6821
				break;
-
 
6822
			}
-
 
6823
	}
-
 
6824
 
-
 
6825
	if (tuple.protocol == IPPROTO_TCP ||
-
 
6826
	    tuple.protocol == IPPROTO_UDP ||
-
 
6827
	    tuple.protocol == IPPROTO_SCTP ||
-
 
6828
	    tuple.protocol == IPPROTO_UDPLITE) {
-
 
6829
		/* aggregate ports */
-
 
6830
		list_for_each_entry(aggr_p, &aggr_p_list, list)
-
 
6831
			if (unlikely(ntohs(tuple.s_port) >= aggr_p->port1 &&
-
 
6832
			    ntohs(tuple.s_port) <= aggr_p->port2)) {
-
 
6833
				tuple.s_port = htons(aggr_p->aggr_port);
-
 
6834
				atomic_inc(&aggr_p->usage);
-
 
6835
				break;
-
 
6836
			}
-
 
6837
 
-
 
6838
		list_for_each_entry(aggr_p, &aggr_p_list, list)
-
 
6839
			if (unlikely(ntohs(tuple.d_port) >= aggr_p->port1 &&
-
 
6840
			    ntohs(tuple.d_port) <= aggr_p->port2)) {
-
 
6841
				tuple.d_port = htons(aggr_p->aggr_port);
-
 
6842
				atomic_inc(&aggr_p->usage);
-
 
6843
				break;
-
 
6844
			}
-
 
6845
	}
-
 
6846
	read_unlock(&aggr_lock);
-
 
6847
#endif
-
 
6848
 
-
 
6849
#ifdef SAMPLING_HASH
-
 
6850
	hash = __hash_netflow(&tuple);
-
 
6851
	{
-
 
6852
		struct sampling hs = samp;
-
 
6853
 
-
 
6854
		if (hs.mode == SAMPLER_HASH) {
-
 
6855
			NETFLOW_STAT_INC(pkts_observed);
-
 
6856
			if ((u32)(((u64)hash * hs.interval) >> 32))
-
 
6857
				return IPT_CONTINUE;
-
 
6858
			NETFLOW_STAT_INC(pkts_selected);
-
 
6859
		}
-
 
6860
	}
-
 
6861
	hash %= htable_size;
-
 
6862
#else /* !SAMPLING_HASH */
-
 
6863
	hash = hash_netflow(&tuple);
-
 
6864
#endif
-
 
6865
	read_lock(&htable_rwlock);
-
 
6866
	stripe = &htable_stripes[hash & LOCK_COUNT_MASK];
-
 
6867
	spin_lock(&stripe->lock);
-
 
6868
	/* record */
-
 
6869
	nf = ipt_netflow_find(&tuple, hash);
-
 
6870
	if (unlikely(!nf)) {
-
 
6871
		struct rtable *rt;
-
 
6872
 
-
 
6873
		if (unlikely(maxflows > 0 && atomic_read(&ipt_netflow_count) >= maxflows)) {
-
 
6874
			/* This is DOS attack prevention */
-
 
6875
			NETFLOW_STAT_INC(maxflows_err);
-
 
6876
			NETFLOW_STAT_INC(pkt_drop);
-
 
6877
			NETFLOW_STAT_ADD(traf_drop, pkt_len);
-
 
6878
			NETFLOW_STAT_TS(drop);
-
 
6879
			goto unlock_return;
-
 
6880
		}
-
 
6881
 
-
 
6882
		nf = ipt_netflow_alloc(&tuple);
-
 
6883
		if (unlikely(!nf || IS_ERR(nf))) {
-
 
6884
			NETFLOW_STAT_INC(alloc_err);
-
 
6885
			NETFLOW_STAT_INC(pkt_drop);
-
 
6886
			NETFLOW_STAT_ADD(traf_drop, pkt_len);
-
 
6887
			NETFLOW_STAT_TS(drop);
-
 
6888
			goto unlock_return;
-
 
6889
		}
-
 
6890
		hlist_add_head(&nf->hlist, &htable[hash]);
-
 
6891
 
-
 
6892
#ifdef ENABLE_SAMPLER
-
 
6893
		/* I only increment if deterministic sampler is enabled to
-
 
6894
		 * avoid cache conflict by default. */
-
 
6895
		if (get_sampler_mode() == SAMPLER_DETERMINISTIC)
-
 
6896
			nf->sampler_count = atomic_inc_return(&flow_count);
-
 
6897
#endif
-
 
6898
		nf->nf_ts_first = jiffies;
-
 
6899
		nf->tcp_flags = tcp_flags;
-
 
6900
		nf->o_ifc = if_out? if_out->ifindex : -1;
-
 
6901
#ifdef ENABLE_PHYSDEV_OVER
-
 
6902
		if (skb->nf_bridge && skb->nf_bridge->physoutdev)
-
 
6903
			nf->o_ifc = skb->nf_bridge->physoutdev->ifindex;
-
 
6904
#endif
-
 
6905
 
-
 
6906
#ifdef SNMP_RULES
-
 
6907
		rcu_read_lock();
-
 
6908
#else
-
 
6909
# define resolve_snmp(dev) ((dev)? (dev)->ifindex : -1)
-
 
6910
#endif
-
 
6911
/* copy and snmp-resolve device with physdev overriding normal dev */
-
 
6912
#define copy_dev(out, physdev, dev) \
-
 
6913
		if (skb->nf_bridge && skb->nf_bridge->physdev) \
-
 
6914
			out = resolve_snmp(skb->nf_bridge->physdev); \
-
 
6915
		else \
-
 
6916
			out = resolve_snmp(dev);
-
 
6917
#ifdef ENABLE_PHYSDEV
-
 
6918
		copy_dev(nf->o_ifphys, physoutdev, if_out);
-
 
6919
		copy_dev(nf->i_ifphys, physindev, if_in);
-
 
6920
#endif
-
 
6921
#ifdef SNMP_RULES
-
 
6922
# ifdef ENABLE_PHYSDEV_OVER
-
 
6923
		copy_dev(nf->o_ifcr, physoutdev, if_out);
-
 
6924
		copy_dev(nf->i_ifcr, physindev, if_in);
-
 
6925
# else
-
 
6926
		nf->o_ifcr = resolve_snmp(if_out);
-
 
6927
		nf->i_ifcr = resolve_snmp(if_in);
-
 
6928
# endif
-
 
6929
		rcu_read_unlock();
-
 
6930
 
-
 
6931
#endif
-
 
6932
		nf->s_mask = s_mask;
-
 
6933
		nf->d_mask = d_mask;
-
 
6934
 
-
 
6935
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
6936
		nf->ethernetType = skb->protocol;
-
 
6937
#endif
-
 
6938
 
-
 
6939
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
-
 
6940
		rt = (struct rtable *)skb->dst;
-
 
6941
#else /* since 2.6.26 */
-
 
6942
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
-
 
6943
		rt = skb->rtable;
-
 
6944
#else /* since 2.6.31 */
-
 
6945
		rt = skb_rtable(skb);
-
 
6946
#endif
-
 
6947
#endif
-
 
6948
#ifdef ENABLE_DIRECTION
-
 
6949
		nf->hooknumx = hooknum + 1;
-
 
6950
#endif
-
 
6951
		if (likely(family == AF_INET)) {
-
 
6952
			if (rt)
-
 
6953
				nf->nh.ip = rt->rt_gateway;
-
 
6954
		} else {
-
 
6955
			if (rt)
-
 
6956
				nf->nh.in6 = ((struct rt6_info *)rt)->rt6i_gateway;
-
 
6957
			nf->flow_label = (iph->ip6.flow_lbl[0] << 16) |
-
 
6958
			       	(iph->ip6.flow_lbl[1] << 8) | (iph->ip6.flow_lbl[2]);
-
 
6959
		}
-
 
6960
#if 0
-
 
6961
		if (unlikely(debug > 2))
-
 
6962
			printk(KERN_INFO "ipt_NETFLOW: new (%u) %hd:%hd SRC=%u.%u.%u.%u:%u DST=%u.%u.%u.%u:%u\n",
-
 
6963
			       atomic_read(&ipt_netflow_count),
-
 
6964
			       tuple.i_ifc, nf->o_ifc,
-
 
6965
			       NIPQUAD(tuple.src.ip), ntohs(tuple.s_port),
-
 
6966
			       NIPQUAD(tuple.dst.ip), ntohs(tuple.d_port));
-
 
6967
#endif
-
 
6968
	}
-
 
6969
 
-
 
6970
	nf->nr_packets++;
-
 
6971
	nf->nr_bytes += pkt_len;
-
 
6972
	nf->nf_ts_last = jiffies;
-
 
6973
	nf->tcp_flags |= tcp_flags;
-
 
6974
	nf->options |= options;
-
 
6975
	if (tuple.protocol == IPPROTO_TCP)
-
 
6976
		nf->tcpoptions |= tcpoptions;
-
 
6977
 
-
 
6978
	NETFLOW_STAT_INC(pkt_total);
-
 
6979
	NETFLOW_STAT_ADD(traf_total, pkt_len);
-
 
6980
 
-
 
6981
#define LIST_IS_NULL(name) (!(name)->next)
-
 
6982
 
-
 
6983
	if (unlikely(active_needs_export(nf, active_timeout * HZ, jiffies))) {
-
 
6984
		/* ok, if this is active flow to be exported */
-
 
6985
#ifdef HAVE_LLIST
-
 
6986
		/* delete from hash and add to the export llist */
-
 
6987
		hlist_del(&nf->hlist);
-
 
6988
		if (!LIST_IS_NULL(&nf->flows_list))
-
 
6989
			list_del(&nf->flows_list);
-
 
6990
		llist_add(&nf->flows_llnode, &export_llist);
-
 
6991
#else
-
 
6992
		/* bubble it to the tail */
-
 
6993
		if (LIST_IS_NULL(&nf->flows_list))
-
 
6994
			list_add_tail(&nf->flows_list, &stripe->list);
-
 
6995
		else
-
 
6996
			list_move_tail(&nf->flows_list, &stripe->list);
-
 
6997
#endif
-
 
6998
		/* Blog: I thought about forcing timer to wake up sooner if we have
-
 
6999
		 * enough exportable flows, but in fact this doesn't have much sense,
-
 
7000
		 * because this would only move flow data from one memory to another
-
 
7001
		 * (from our buffers to socket buffers, and socket buffers even have
-
 
7002
		 * limited size). But yes, this is disputable. */
-
 
7003
	} else {
-
 
7004
		/* most recently accessed flows go to the head, old flows remain at the tail */
-
 
7005
		if (LIST_IS_NULL(&nf->flows_list))
-
 
7006
			list_add(&nf->flows_list, &stripe->list);
-
 
7007
		else
-
 
7008
			list_move(&nf->flows_list, &stripe->list);
-
 
7009
	}
-
 
7010
 
-
 
7011
unlock_return:
-
 
7012
	spin_unlock(&stripe->lock);
-
 
7013
	read_unlock(&htable_rwlock);
-
 
7014
 
-
 
7015
	return IPT_CONTINUE;
-
 
7016
}
-
 
7017
 
-
 
7018
#ifdef CONFIG_NF_NAT_NEEDED
-
 
7019
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
7020
	/* Below 2.6.31 we don't need to handle callback chain manually. */
-
 
7021
 
-
 
7022
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-
 
7023
#define NET_STRUCT struct net *net
-
 
7024
#define NET_ARG net,
-
 
7025
#define nf_conntrack_event_cb net->ct.nf_conntrack_event_cb
-
 
7026
#else
-
 
7027
#define NET_STRUCT void
-
 
7028
#define NET_ARG
-
 
7029
#endif
-
 
7030
static int set_notifier_cb(NET_STRUCT)
-
 
7031
{
-
 
7032
	struct nf_ct_event_notifier *notifier;
-
 
7033
 
-
 
7034
	notifier = rcu_dereference(nf_conntrack_event_cb);
-
 
7035
	if (notifier == NULL) {
-
 
7036
		/* Polite mode. */
-
 
7037
		nf_conntrack_register_notifier(NET_ARG &ctnl_notifier);
-
 
7038
	} else if (notifier != &ctnl_notifier) {
-
 
7039
		if (!saved_event_cb)
-
 
7040
			saved_event_cb = notifier;
-
 
7041
		else if (saved_event_cb != notifier)
-
 
7042
			printk(KERN_ERR "natevents_net_init: %p != %p (report error.)\n",
-
 
7043
			    saved_event_cb, notifier);
-
 
7044
		rcu_assign_pointer(nf_conntrack_event_cb, &ctnl_notifier);
-
 
7045
	} else
-
 
7046
		printk(KERN_ERR "ipt_NETFLOW: natevents already enabled.\n");
-
 
7047
	return 0;
-
 
7048
}
-
 
7049
static void unset_notifier_cb(NET_STRUCT)
-
 
7050
{
-
 
7051
	struct nf_ct_event_notifier *notifier;
-
 
7052
 
-
 
7053
	notifier = rcu_dereference(nf_conntrack_event_cb);
-
 
7054
	if (notifier == &ctnl_notifier) {
-
 
7055
		if (saved_event_cb == NULL)
-
 
7056
			nf_conntrack_unregister_notifier(NET_ARG &ctnl_notifier);
-
 
7057
		else
-
 
7058
			rcu_assign_pointer(nf_conntrack_event_cb, saved_event_cb);
-
 
7059
	} else
-
 
7060
		printk(KERN_ERR "ipt_NETFLOW: natevents already disabled.\n");
-
 
7061
}
-
 
7062
 
-
 
7063
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-
 
7064
#undef nf_conntrack_event_cb
-
 
7065
static struct pernet_operations natevents_net_ops = {
-
 
7066
	.init = set_notifier_cb,
-
 
7067
	.exit = unset_notifier_cb
-
 
7068
};
-
 
7069
#endif
-
 
7070
#endif /* since 2.6.31 */
-
 
7071
 
-
 
7072
static DEFINE_MUTEX(events_lock);
-
 
7073
/* Both functions may be called multiple times. */
-
 
7074
static void register_ct_events(void)
-
 
7075
{
-
 
7076
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
7077
#define NETLINK_M "nf_conntrack_netlink"
-
 
7078
	struct module *netlink_m;
-
 
7079
	static int referenced = 0;
-
 
7080
#endif
-
 
7081
 
-
 
7082
	printk(KERN_INFO "ipt_NETFLOW: enable natevents.\n");
-
 
7083
	mutex_lock(&events_lock);
-
 
7084
 
-
 
7085
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
7086
	/* Pre-load netlink module who will be first notifier
-
 
7087
	 * user, and then hijack nf_conntrack_event_cb from it. */
-
 
7088
	if (
-
 
7089
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
-
 
7090
	    !rcu_dereference(nf_conntrack_event_cb) ||
-
 
7091
#endif
-
 
7092
	    !(netlink_m = find_module(NETLINK_M))) {
-
 
7093
		printk("Loading " NETLINK_M "\n");
-
 
7094
		request_module(NETLINK_M);
-
 
7095
	}
-
 
7096
	/* Reference netlink module to prevent it's unsafe unload before us. */
-
 
7097
	if (!referenced && (netlink_m = find_module(NETLINK_M))) {
-
 
7098
		referenced++;
-
 
7099
		use_module(THIS_MODULE, netlink_m);
-
 
7100
	}
-
 
7101
 
-
 
7102
	/* Register ct events callback. */
-
 
7103
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-
 
7104
	register_pernet_subsys(&natevents_net_ops);
-
 
7105
#else
-
 
7106
	set_notifier_cb();
-
 
7107
#endif
-
 
7108
#else /* below v2.6.31 */
-
 
7109
	if (!natevents && nf_conntrack_register_notifier(&ctnl_notifier) < 0)
-
 
7110
		printk(KERN_ERR "Can't register conntrack notifier, natevents disabled.\n");
-
 
7111
	else
-
 
7112
#endif
-
 
7113
	natevents = 1;
-
 
7114
	mutex_unlock(&events_lock);
-
 
7115
}
-
 
7116
 
-
 
7117
static void unregister_ct_events(void)
-
 
7118
{
-
 
7119
	printk(KERN_INFO "ipt_NETFLOW: disable natevents.\n");
-
 
7120
	mutex_lock(&events_lock);
-
 
7121
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
-
 
7122
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
-
 
7123
	unregister_pernet_subsys(&natevents_net_ops);
-
 
7124
#else /* < v3.2 */
-
 
7125
	unset_notifier_cb();
-
 
7126
#endif /* v3.2 */
-
 
7127
	rcu_assign_pointer(saved_event_cb, NULL);
-
 
7128
#else /* < v2.6.31 */
-
 
7129
	nf_conntrack_unregister_notifier(&ctnl_notifier);
-
 
7130
#endif
-
 
7131
	natevents = 0;
-
 
7132
	mutex_unlock(&events_lock);
-
 
7133
}
-
 
7134
#endif /* CONFIG_NF_NAT_NEEDED */
-
 
7135
 
-
 
7136
static struct ipt_target ipt_netflow_reg[] __read_mostly = {
-
 
7137
	{
-
 
7138
		.name		= "NETFLOW",
-
 
7139
		.target		= netflow_target,
-
 
7140
		.checkentry	= netflow_target_check,
-
 
7141
		.family		= AF_INET,
-
 
7142
		.hooks		=
-
 
7143
		       	(1 << NF_IP_PRE_ROUTING) |
-
 
7144
		       	(1 << NF_IP_LOCAL_IN) |
-
 
7145
		       	(1 << NF_IP_FORWARD) |
-
 
7146
			(1 << NF_IP_LOCAL_OUT) |
-
 
7147
			(1 << NF_IP_POST_ROUTING),
-
 
7148
		.me		= THIS_MODULE
-
 
7149
	},
-
 
7150
	{
-
 
7151
		.name		= "NETFLOW",
-
 
7152
		.target		= netflow_target,
-
 
7153
		.checkentry	= netflow_target_check,
-
 
7154
		.family		= AF_INET6,
-
 
7155
		.hooks		=
-
 
7156
		       	(1 << NF_IP_PRE_ROUTING) |
-
 
7157
		       	(1 << NF_IP_LOCAL_IN) |
-
 
7158
		       	(1 << NF_IP_FORWARD) |
-
 
7159
			(1 << NF_IP_LOCAL_OUT) |
-
 
7160
			(1 << NF_IP_POST_ROUTING),
-
 
7161
		.me		= THIS_MODULE
-
 
7162
	},
-
 
7163
};
-
 
7164
 
-
 
7165
#ifdef CONFIG_PROC_FS
-
 
7166
static int register_stat(const char *name, struct file_operations *fops)
-
 
7167
{
-
 
7168
	struct proc_dir_entry *proc_stat;
-
 
7169
 
-
 
7170
	printk(KERN_INFO "netflow: registering: /proc/net/stat/%s\n", name);
-
 
7171
 
-
 
7172
# if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
-
 
7173
	proc_stat = create_proc_entry(name, S_IRUGO, INIT_NET(proc_net_stat));
-
 
7174
# else
-
 
7175
	proc_stat = proc_create(name, S_IRUGO, INIT_NET(proc_net_stat), fops);
-
 
7176
# endif
-
 
7177
	if (!proc_stat) {
-
 
7178
		printk(KERN_ERR "Unable to create /proc/net/stat/%s entry\n", name);
-
 
7179
		return 0;
-
 
7180
	}
-
 
7181
# if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
-
 
7182
	proc_stat->proc_fops = fops;
-
 
7183
# endif
-
 
7184
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
-
 
7185
	proc_stat->owner = THIS_MODULE;
-
 
7186
# endif
-
 
7187
	printk(KERN_INFO "netflow: registered: /proc/net/stat/%s\n", name);
-
 
7188
	return 1;
-
 
7189
}
-
 
7190
#else
-
 
7191
# define register_stat(x, y) 1
-
 
7192
#endif
-
 
7193
 
-
 
7194
static int __init ipt_netflow_init(void)
-
 
7195
{
-
 
7196
	int i;
-
 
7197
 
-
 
7198
	printk(KERN_INFO "ipt_NETFLOW version %s, srcversion %s\n",
-
 
7199
		IPT_NETFLOW_VERSION, THIS_MODULE->srcversion);
-
 
7200
 
-
 
7201
	version_string_size = scnprintf(version_string, sizeof(version_string),
-
 
7202
		"ipt_NETFLOW " IPT_NETFLOW_VERSION " %s", THIS_MODULE->srcversion);
-
 
7203
	tpl_element_sizes[observationDomainName] = version_string_size + 1;
-
 
7204
 
-
 
7205
	start_ts.first = ktime_get_real();
-
 
7206
	clear_ipt_netflow_stat();
-
 
7207
 
-
 
7208
	if (!hashsize) {
-
 
7209
		/* use 1/1024 of memory, 1M for hash table on 1G box */
-
 
7210
		unsigned long memksize = (num_physpages << PAGE_SHIFT) / 1024;
-
 
7211
 
-
 
7212
		if (memksize > (5 * 1024 * 1024))
-
 
7213
			memksize = 5 * 1024 * 1024;
-
 
7214
		hashsize = memksize / sizeof(struct hlist_head);
-
 
7215
	}
-
 
7216
	if (hashsize < LOCK_COUNT)
-
 
7217
		hashsize = LOCK_COUNT;
-
 
7218
	printk(KERN_INFO "ipt_NETFLOW: hashsize %u (%luK)\n", hashsize,
-
 
7219
		hashsize * sizeof(struct hlist_head) / 1024);
-
 
7220
 
-
 
7221
	htable_size = hashsize;
-
 
7222
	htable = alloc_hashtable(htable_size);
-
 
7223
	if (!htable) {
-
 
7224
		printk(KERN_ERR "Unable to create ipt_neflow_hash\n");
-
 
7225
		goto err;
-
 
7226
	}
-
 
7227
 
-
 
7228
#ifdef MPLS_DEPTH
-
 
7229
	/* template_mpls is terminated on the MPLS_DEPTH mark, so, it
-
 
7230
	 * never send Element which can access mpls labels array above
-
 
7231
	 * its defined MPLS_DEPTH value. */
-
 
7232
	if (MPLS_DEPTH >= 0 && MPLS_DEPTH < 10)
-
 
7233
		template_mpls.types[MPLS_LABELS_BASE_INDEX + MPLS_DEPTH] = 0;
-
 
7234
#endif
-
 
7235
 
-
 
7236
	for (i = 0; i < LOCK_COUNT; i++) {
-
 
7237
		spin_lock_init(&htable_stripes[i].lock);
-
 
7238
		INIT_LIST_HEAD(&htable_stripes[i].list);
-
 
7239
	}
-
 
7240
 
-
 
7241
	ipt_netflow_cachep = kmem_cache_create("ipt_netflow",
-
 
7242
						sizeof(struct ipt_netflow), 0,
-
 
7243
						0, NULL
-
 
7244
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-
 
7245
						, NULL
-
 
7246
#endif
-
 
7247
					      );
-
 
7248
	if (!ipt_netflow_cachep) {
-
 
7249
		printk(KERN_ERR "Unable to create ipt_netflow slab cache\n");
-
 
7250
		goto err_free_hash;
-
 
7251
	}
-
 
7252
 
-
 
7253
	if (!register_stat("ipt_netflow", &nf_seq_fops))
-
 
7254
		goto err_free_netflow_slab;
-
 
7255
	if (!register_stat("ipt_netflow_snmp", &snmp_seq_fops))
-
 
7256
		goto err_free_proc_stat1;
-
 
7257
	if (!register_stat("ipt_netflow_flows", &flows_seq_fops))
-
 
7258
		goto err_free_proc_stat2;
-
 
7259
 
-
 
7260
#ifdef CONFIG_SYSCTL
-
 
7261
	ctl_table_renumber(netflow_sysctl_table);
-
 
7262
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
-
 
7263
	netflow_sysctl_header = register_sysctl_table(netflow_net_table
-
 
7264
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
-
 
7265
						      , 0 /* insert_at_head */
-
 
7266
#endif
-
 
7267
						      );
-
 
7268
#else /* 2.6.25 */
-
 
7269
	netflow_sysctl_header = register_sysctl_paths(netflow_sysctl_path, netflow_sysctl_table);
-
 
7270
#endif
-
 
7271
	if (!netflow_sysctl_header) {
-
 
7272
		printk(KERN_ERR "netflow: can't register to sysctl\n");
-
 
7273
		goto err_free_proc_stat3;
-
 
7274
	} else
-
 
7275
		printk(KERN_INFO "netflow: registered: sysctl net.netflow\n");
-
 
7276
#endif
-
 
7277
 
-
 
7278
	if (!destination)
-
 
7279
		destination = destination_buf;
-
 
7280
	if (destination != destination_buf) {
-
 
7281
		strlcpy(destination_buf, destination, sizeof(destination_buf));
-
 
7282
		destination = destination_buf;
-
 
7283
	}
-
 
7284
	if (add_destinations(destination) < 0)
-
 
7285
		goto err_free_sysctl;
-
 
7286
 
-
 
7287
#ifdef ENABLE_AGGR
-
 
7288
	if (!aggregation)
-
 
7289
		aggregation = aggregation_buf;
-
 
7290
	if (aggregation != aggregation_buf) {
-
 
7291
		strlcpy(aggregation_buf, aggregation, sizeof(aggregation_buf));
-
 
7292
		aggregation = aggregation_buf;
-
 
7293
	}
-
 
7294
	add_aggregation(aggregation);
-
 
7295
#endif
-
 
7296
 
-
 
7297
#ifdef ENABLE_SAMPLER
-
 
7298
	if (!sampler)
-
 
7299
		sampler = sampler_buf;
-
 
7300
	if (sampler != sampler_buf) {
-
 
7301
		strlcpy(sampler_buf, sampler, sizeof(sampler_buf));
-
 
7302
		sampler = sampler_buf;
-
 
7303
	}
-
 
7304
	parse_sampler(sampler);
-
 
7305
#ifdef SAMPLING_HASH
-
 
7306
	hash_seed = prandom_u32();
-
 
7307
#endif
-
 
7308
#endif
-
 
7309
 
-
 
7310
#ifdef SNMP_RULES
-
 
7311
	if (!snmp_rules)
-
 
7312
		snmp_rules = snmp_rules_buf;
-
 
7313
	if (snmp_rules != snmp_rules_buf) {
-
 
7314
		strlcpy(snmp_rules_buf, snmp_rules, sizeof(snmp_rules_buf));
-
 
7315
		snmp_rules = snmp_rules_buf;
-
 
7316
	}
-
 
7317
	add_snmp_rules(snmp_rules);
-
 
7318
#endif
-
 
7319
 
-
 
7320
#ifdef ENABLE_PROMISC
-
 
7321
	{
-
 
7322
		int newpromisc = promisc;
-
 
7323
 
-
 
7324
		promisc = 0;
-
 
7325
		switch_promisc(newpromisc);
-
 
7326
	}
-
 
7327
#endif
-
 
7328
 
-
 
7329
	netflow_switch_version(protocol);
-
 
7330
	_schedule_scan_worker(0);
-
 
7331
	setup_timer(&rate_timer, rate_timer_calc, 0);
-
 
7332
	mod_timer(&rate_timer, jiffies + (HZ * SAMPLERATE));
-
 
7333
 
-
 
7334
	peakflows_at = jiffies;
-
 
7335
	if (xt_register_targets(ipt_netflow_reg, ARRAY_SIZE(ipt_netflow_reg)))
-
 
7336
		goto err_stop_timer;
-
 
7337
 
-
 
7338
#ifdef CONFIG_NF_NAT_NEEDED
-
 
7339
	if (natevents)
-
 
7340
		register_ct_events();
-
 
7341
#endif
-
 
7342
 
-
 
7343
	printk(KERN_INFO "ipt_NETFLOW is loaded.\n");
-
 
7344
	return 0;
-
 
7345
 
-
 
7346
err_stop_timer:
-
 
7347
	_unschedule_scan_worker();
-
 
7348
	netflow_scan_and_export(AND_FLUSH);
-
 
7349
	del_timer_sync(&rate_timer);
-
 
7350
	free_templates();
-
 
7351
	destination_removeall();
-
 
7352
#ifdef ENABLE_AGGR
-
 
7353
	aggregation_remove(&aggr_n_list);
-
 
7354
	aggregation_remove(&aggr_p_list);
-
 
7355
#endif
-
 
7356
err_free_sysctl:
-
 
7357
#ifdef CONFIG_SYSCTL
-
 
7358
	unregister_sysctl_table(netflow_sysctl_header);
-
 
7359
#endif
-
 
7360
err_free_proc_stat3:
-
 
7361
#ifdef CONFIG_PROC_FS
-
 
7362
	remove_proc_entry("ipt_netflow_flows", INIT_NET(proc_net_stat));
-
 
7363
err_free_proc_stat2:
-
 
7364
	remove_proc_entry("ipt_netflow_snmp", INIT_NET(proc_net_stat));
-
 
7365
err_free_proc_stat1:
-
 
7366
	remove_proc_entry("ipt_netflow", INIT_NET(proc_net_stat));
-
 
7367
err_free_netflow_slab:
-
 
7368
#endif
-
 
7369
	kmem_cache_destroy(ipt_netflow_cachep);
-
 
7370
err_free_hash:
-
 
7371
	vfree(htable);
-
 
7372
err:
-
 
7373
	printk(KERN_INFO "ipt_NETFLOW is not loaded.\n");
-
 
7374
	return -ENOMEM;
-
 
7375
}
-
 
7376
 
-
 
7377
static void __exit ipt_netflow_fini(void)
-
 
7378
{
-
 
7379
	printk(KERN_INFO "ipt_NETFLOW unloading..\n");
-
 
7380
 
-
 
7381
#ifdef CONFIG_SYSCTL
-
 
7382
	unregister_sysctl_table(netflow_sysctl_header);
-
 
7383
#endif
-
 
7384
#ifdef CONFIG_PROC_FS
-
 
7385
	remove_proc_entry("ipt_netflow_flows", INIT_NET(proc_net_stat));
-
 
7386
	remove_proc_entry("ipt_netflow_snmp", INIT_NET(proc_net_stat));
-
 
7387
	remove_proc_entry("ipt_netflow", INIT_NET(proc_net_stat));
-
 
7388
#endif
-
 
7389
#ifdef ENABLE_PROMISC
-
 
7390
	switch_promisc(0);
-
 
7391
#endif
-
 
7392
	xt_unregister_targets(ipt_netflow_reg, ARRAY_SIZE(ipt_netflow_reg));
-
 
7393
#ifdef CONFIG_NF_NAT_NEEDED
-
 
7394
	if (natevents)
-
 
7395
		unregister_ct_events();
-
 
7396
#endif
-
 
7397
	_unschedule_scan_worker();
-
 
7398
	netflow_scan_and_export(AND_FLUSH);
-
 
7399
	del_timer_sync(&rate_timer);
-
 
7400
 
-
 
7401
	synchronize_sched();
-
 
7402
 
-
 
7403
	free_templates();
-
 
7404
	destination_removeall();
-
 
7405
#ifdef ENABLE_AGGR
-
 
7406
	aggregation_remove(&aggr_n_list);
-
 
7407
	aggregation_remove(&aggr_p_list);
-
 
7408
#endif
-
 
7409
#ifdef SNMP_RULES
-
 
7410
	kfree(snmp_ruleset);
-
 
7411
#endif
-
 
7412
 
-
 
7413
	kmem_cache_destroy(ipt_netflow_cachep);
-
 
7414
	vfree(htable);
-
 
7415
 
-
 
7416
	printk(KERN_INFO "ipt_NETFLOW unloaded.\n");
-
 
7417
}
-
 
7418
 
-
 
7419
module_init(ipt_netflow_init);
-
 
7420
module_exit(ipt_netflow_fini);
-
 
7421
 
-
 
7422
/* vim: set sw=8: */
-
 
7423
ipt-netflow-2.2/raw_promisc.patch0000644000000000000000000000147613213006644015700 0ustar  rootroot
-
 
7424
 This simple hack will allow to see promisc traffic in raw table of
-
 
7425
 iptables. Of course you will need to enable promisc on the interface.
-
 
7426
 Refer to README.promisc for details.
-
 
7427
 
-
 
7428
 Example how to catch desired traffic:
-
 
7429
   iptables -A PREROUTING -t raw -i eth2 -j NETFLOW
-
 
7430
 
-
 
7431
 
-
 
7432
--- linux-2.6.26/net/ipv4/ip_input.old.c        2008-07-14 01:51:29.000000000 +0400
-
 
7433
+++ linux-2.6.26/net/ipv4/ip_input.c        2008-08-06 14:02:16.000000000 +0400
-
 
7434
@@ -378,12 +378,6 @@
-
 
7435
        struct iphdr *iph;
-
 
7436
        u32 len;
-
 
7437
 
-
 
7438
-       /* When the interface is in promisc. mode, drop all the crap
-
 
7439
-        * that it receives, do not try to analyse it.
-
 
7440
-        */
-
 
7441
-       if (skb->pkt_type == PACKET_OTHERHOST)
-
 
7442
-               goto drop;
-
 
7443
-
-
 
7444
        IP_INC_STATS_BH(IPSTATS_MIB_INRECEIVES);
-
 
7445
 
-
 
7446
        if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
-
 
7447
ipt-netflow-2.2/testing.sh0000755000000000000000000000171713213006644014344 0ustar  rootroot#!/bin/bash
-
 
7448
 
-
 
7449
set -e
-
 
7450
 
-
 
7451
if [ "$1" = "" ]; then
-
 
7452
  echo Maintainer only tool.
-
 
7453
  exit 1
-
 
7454
elif [ "$1" = all ]; then
-
 
7455
  exec bash $0 linux-2.6.18 centos5 linux-3.11.2 centos6 linux-3.4.66 linux-3.9.11 centos7 linux-3.14 linux-3.17 linux-3.19
-
 
7456
  exit 1
-
 
7457
fi
-
 
7458
 
-
 
7459
smilint IPT-NETFLOW-MIB.my
-
 
7460
 
-
 
7461
cfg=()
-
 
7462
echo -n Testing for:
-
 
7463
for k in "$@"; do
-
 
7464
  if [ ! -d /usr/src/$k ]; then continue; fi
-
 
7465
  echo -n " $k"
-
 
7466
  cfg+=("./configure --kdir=/usr/src/$k")
-
 
7467
done
-
 
7468
echo
-
 
7469
 
-
 
7470
readarray -t opts <<EOF
-
 
7471
  --disable-snmp-agent
-
 
7472
  --enable-aggregation
-
 
7473
  --enable-natevents
-
 
7474
  --enable-snmp-rules
-
 
7475
  --enable-macaddress
-
 
7476
  --enable-vlan
-
 
7477
  --promisc-mpls
-
 
7478
  --enable-direction
-
 
7479
  --enable-sampler
-
 
7480
  --enable-sampler=hash
-
 
7481
  --enable-promisc --promisc-mpls
-
 
7482
  --enable-physdev
-
 
7483
  --enable-physdev-override
-
 
7484
EOF
-
 
7485
if [ "$SHORT" ]; then
-
 
7486
  opts=("$SHORT")
-
 
7487
fi
-
 
7488
 
-
 
7489
colorecho() {
-
 
7490
  echo -e "\033[1;32m$@\033[m"
-
 
7491
}
-
 
7492
for i in "${cfg[@]}"; do
-
 
7493
  for j in "${opts[@]}"; do
-
 
7494
    echo
-
 
7495
    colorecho == $i $j
-
 
7496
    echo
-
 
7497
    $i $j -Werror
-
 
7498
    make
-
 
7499
  done
-
 
7500
done
-
 
7501
 
-
 
7502
ipt-netflow-2.2/NEWS0000644000000000000000000000552713213006644013032 0ustar  rootrootipt-netflow NEWS
-
 
7503
================
-
 
7504
 
-
 
7505
2.2 (2016-02-21)
-
 
7506
 
-
 
7507
    * Minor feature and Maintenance release.
-
 
7508
       - Decapsulate MPLS in promisc mode and MPLS-aware NetFlow feature.
-
 
7509
       - Export flowEndReason for IPFIX.
-
 
7510
       - Promics mode improvements.
-
 
7511
       - Allow export destination to be IPv6 address.
-
 
7512
       - Move flows list from debugfs to proc.
-
 
7513
       - Compilation compatibility with latest kernels.
-
 
7514
       - Code is Coverity scanned.
-
 
7515
 
-
 
7516
2.1 (2014-02-08)
-
 
7517
 
-
 
7518
    * Options Templates support (V9 and IPFIX). Which let to implement:
-
 
7519
       - Flow Sampling (random, deterministic, and hash modes) for all types
-
 
7520
	 of NetFlow protocols (V5, V9, IPFIX).
-
 
7521
       - Export Statistics (metering, exporting, sampling) and Configuration.
-
 
7522
       - Export Interface list (ifName, ifDescr).
-
 
7523
    * Promisc hack (no need to patch kernel anymore).
-
 
7524
    * SNMP monitoring interface and agent (via net-snmp dlmod).
-
 
7525
    * More compilation compatibility with recent kernels, grsecurity kernels,
-
 
7526
      Gentoo, Debian, Centos. DKMS install support.
-
 
7527
    * Minor features: IPSec flows, Direction Element. Removed support for
-
 
7528
      CONNMARK. Bug fixes and improvements.
-
 
7529
    * irqtop tool (ruby).
-
 
7530
 
-
 
7531
2.0.1 (2014-09-04)
-
 
7532
 
-
 
7533
    * Minor fixes for 2.0 release.
-
 
7534
 
-
 
7535
2.0 (2014-08-07)
-
 
7536
 
-
 
7537
    * This is major release with a lot of new features and improvements, such
-
 
7538
      as:
-
 
7539
	- Support of NetFlow v9 and IPFIX.
-
 
7540
	- IPv6 support.
-
 
7541
	- NAT translation events (NEL).
-
 
7542
	- Additional options is SNMP-index translation rules, Ethernet Type,
-
 
7543
	  VLAN, and MAC addresses exporting.
-
 
7544
        - Performance improvements (tested to work well on 10Gbit load).
-
 
7545
	- Stability improvements and bug fixes.
-
 
7546
 
-
 
7547
1.8 (2012-07-02)
-
 
7548
 
-
 
7549
    * This is minor bug fix release with small improvements.
-
 
7550
 
-
 
7551
1.7.1 (2011-04-04)
-
 
7552
 
-
 
7553
    * This is minor release with improved compilation compatibility and small
-
 
7554
      improvements.
-
 
7555
 
-
 
7556
1.7 (2011-01-30)
-
 
7557
 
-
 
7558
    * This version have improved compilation compatibility with latest Linux
-
 
7559
      kernels (2.6.36.3 and 2.6.27) and bunch of small improvements.
-
 
7560
 
-
 
7561
    * Since version 1.7 ipt-netflow's repository moved to Git SCM. Use of CVS
-
 
7562
      repository is deprecated.
-
 
7563
 
-
 
7564
1.5.1 (2009-03-14)
-
 
7565
 
-
 
7566
    * This version have improved compliance to NetFlow standard and
-
 
7567
      compatibility with iptables/xtables 1.4.x. Added options to configure
-
 
7568
      script for manual customization.
-
 
7569
 
-
 
7570
1.4 (2008-12-23)
-
 
7571
 
-
 
7572
    * This version have restored compatibility with popular kernel 2.6.18,
-
 
7573
      added configure script, statistics improvements, some fixes for 64-bit
-
 
7574
      platforms, and minor performance tune up.
-
 
7575
 
-
 
7576
1.2 (2008-11-15)
-
 
7577
 
-
 
7578
    * This version have stability enhancements, documentation improvements, IP
-
 
7579
      frag support, better statistics.
-
 
7580
 
-
 
7581
1.1 (2008-08-06)
-
 
7582
 
-
 
7583
    * This version updated compatibility with latest (2.6.26) Linux kernel, have
-
 
7584
      more support for promisc patch, and minor fixes.
-
 
7585
 
-
 
7586
1.0 (2008-07-12)
-
 
7587
 
-
 
7588
    * First release tested in production environment.
-
 
7589
ipt-netflow-2.2/libipt_NETFLOW.c0000644000000000000000000000500713213006644015151 0ustar  rootroot/*
-
 
7590
 * iptables helper for NETFLOW target
-
 
7591
 * <abc@telekom.ru>
-
 
7592
 *
-
 
7593
 *
-
 
7594
 *   This file is part of NetFlow exporting module.
-
 
7595
 *
-
 
7596
 *   This program is free software: you can redistribute it and/or modify
-
 
7597
 *   it under the terms of the GNU General Public License as published by
-
 
7598
 *   the Free Software Foundation, either version 2 of the License, or
-
 
7599
 *   (at your option) any later version.
-
 
7600
 *
-
 
7601
 *   This program is distributed in the hope that it will be useful,
-
 
7602
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
7603
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
7604
 *   GNU General Public License for more details.
-
 
7605
 *
-
 
7606
 *   You should have received a copy of the GNU General Public License
-
 
7607
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 
7608
 *
-
 
7609
 */
-
 
7610
 
-
 
7611
#include <stdio.h>
-
 
7612
#include <string.h>
-
 
7613
#include <stdlib.h>
-
 
7614
#include <getopt.h>
-
 
7615
#include <net/if.h>
-
 
7616
#include <sys/socket.h>
-
 
7617
#include <netinet/in.h>
-
 
7618
#include <arpa/inet.h>
-
 
7619
 
-
 
7620
#define __EXPORTED_HEADERS__
-
 
7621
#ifdef XTABLES
-
 
7622
#include <xtables.h>
-
 
7623
#else
-
 
7624
#include <iptables.h>
-
 
7625
#endif
-
 
7626
 
-
 
7627
#ifdef XTABLES_VERSION_CODE	// since 1.4.1
-
 
7628
#define MOD140
-
 
7629
#define iptables_target         xtables_target
-
 
7630
#endif
-
 
7631
 
-
 
7632
#ifdef iptables_target		// only in 1.4.0
-
 
7633
#define MOD140
-
 
7634
#endif
-
 
7635
 
-
 
7636
#ifdef MOD140
-
 
7637
#define ipt_entry_target	xt_entry_target
-
 
7638
#define register_target		xtables_register_target
-
 
7639
#define _IPT_ENTRY		void
-
 
7640
#define _IPT_IP			void
-
 
7641
#ifndef IPT_ALIGN
-
 
7642
#define IPT_ALIGN		XT_ALIGN
-
 
7643
#endif
-
 
7644
#else // before 1.3.x
-
 
7645
#define _IPT_ENTRY struct ipt_entry
-
 
7646
#define _IPT_IP struct ipt_ip
-
 
7647
#endif
-
 
7648
 
-
 
7649
#ifndef IPTABLES_VERSION
-
 
7650
#define IPTABLES_VERSION XTABLES_VERSION
-
 
7651
#endif
-
 
7652
 
-
 
7653
static struct option opts[] = {
-
 
7654
  { 0 }
-
 
7655
};
-
 
7656
 
-
 
7657
static void help(void)
-
 
7658
{
-
 
7659
	printf("NETFLOW target\n");
-
 
7660
}
-
 
7661
 
-
 
7662
static int parse(int c, char **argv, int invert, unsigned int *flags,
-
 
7663
	     const _IPT_ENTRY  *entry,
-
 
7664
	     struct ipt_entry_target **targetinfo)
-
 
7665
 
-
 
7666
{
-
 
7667
	return 1;
-
 
7668
}
-
 
7669
 
-
 
7670
static void final_check(unsigned int flags)
-
 
7671
{
-
 
7672
}
-
 
7673
 
-
 
7674
static void save(const _IPT_IP *ip, const struct ipt_entry_target *match)
-
 
7675
{
-
 
7676
}
-
 
7677
 
-
 
7678
static void print(const _IPT_IP *ip,
-
 
7679
      const struct ipt_entry_target *target,
-
 
7680
      int numeric)
-
 
7681
{
-
 
7682
	printf("NETFLOW ");
-
 
7683
}
-
 
7684
 
-
 
7685
static struct iptables_target netflow = { 
-
 
7686
	.next		= NULL,
-
 
7687
	.name		= "NETFLOW",
-
 
7688
	.version	= IPTABLES_VERSION,
-
 
7689
	.size           = IPT_ALIGN(0),
-
 
7690
	.userspacesize  = IPT_ALIGN(0),
-
 
7691
	.help		= &help,
-
 
7692
	.parse		= &parse,
-
 
7693
	.final_check    = &final_check,
-
 
7694
	.print		= &print,
-
 
7695
	.save		= &save,
-
 
7696
	.extra_opts     = opts
-
 
7697
};
-
 
7698
 
-
 
7699
#ifndef _init
-
 
7700
#define _init __attribute__((constructor)) _INIT
-
 
7701
#endif
-
 
7702
void _init(void)
-
 
7703
{
-
 
7704
	register_target(&netflow);
-
 
7705
}
-
 
7706
ipt-netflow-2.2/configure0000755000000000000000000004317513213006644014243 0ustar  rootroot#!/bin/sh
-
 
7707
 
-
 
7708
PATH=$PATH:/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/sbin
-
 
7709
 
-
 
7710
case "$1" in
-
 
7711
  --from-dkms-conf*)
-
 
7712
    KDKMS=`echo "$1" | sed 's/[^=]*.//'`
-
 
7713
    # restore options from existing Makefile, if present
-
 
7714
    if [ -e Makefile ]; then
-
 
7715
      set -- `sed -n 's/^CARGS = \(.*\)/\1/p' Makefile`
-
 
7716
      FROMDKMSCONF=1
-
 
7717
    fi
-
 
7718
    ;;
-
 
7719
esac
-
 
7720
 
-
 
7721
error() {
-
 
7722
  printf "! Error: $*\n"
-
 
7723
  exit 1
-
 
7724
}
-
 
7725
 
-
 
7726
iptables_src_version() {
-
 
7727
  test "$IPTSRC" || return 1
-
 
7728
 
-
 
7729
  echo -n "Checking iptables sources version: "
-
 
7730
  SRC="$IPTSRC/Makefile"
-
 
7731
  test -s "$SRC" || error "Please build iptables first."
-
 
7732
  VER=`sed -n 's/^\(IPTABLES_\)\?VERSION[ :]= \?//p' "$SRC"`
-
 
7733
  test "$VER" || error "Unknown version of iptables."
-
 
7734
  if [ "$VER" = "$IPTVER" ]; then
-
 
7735
    echo "$VER (ok)"
-
 
7736
  else
-
 
7737
    echo "$VER"
-
 
7738
    error "Source version ($VER) doesn't match binary ($IPTVER)"
-
 
7739
  fi
-
 
7740
}
-
 
7741
 
-
 
7742
get_lib_dir() {
-
 
7743
  test -s "$1" && LIB=`sed -n 's/.*_LIB_DIR "\(.*\)"/\1/p' "$1"`
-
 
7744
  if [ "$LIB" ]; then
-
 
7745
    IPTLIB=$LIB
-
 
7746
    echo "$IPTLIB (from sources)"
-
 
7747
    return 0
-
 
7748
  fi
-
 
7749
  return 1
-
 
7750
}
-
 
7751
 
-
 
7752
get_lib_from_bin() {
-
 
7753
  LIB=`strings $IPTBIN | grep ^/.*lib.*/.*tables`
-
 
7754
  if [ "$LIB" ]; then
-
 
7755
    IPTLIB=$LIB
-
 
7756
    echo "$IPTLIB (from binary)"
-
 
7757
    return 0
-
 
7758
  fi
-
 
7759
  return 1
-
 
7760
}
-
 
7761
 
-
 
7762
get_lib_from_lib() {
-
 
7763
  XLIB=`/usr/bin/ldd $IPTBIN | grep libxtables | sed -n 's!.* \(/[^ ]\+\).*!\1!p'`
-
 
7764
  test "$XLIB" || return 1
-
 
7765
  LIB=`strings $XLIB | grep ^/.*lib.*/.*tables`
-
 
7766
  if [ "$LIB" ]; then
-
 
7767
    IPTLIB=$LIB
-
 
7768
    echo "$IPTLIB (from libxtables.so, from binary)"
-
 
7769
    return 0
-
 
7770
  fi
-
 
7771
  return 1
-
 
7772
}
-
 
7773
 
-
 
7774
iptables_inc() {
-
 
7775
  echo -n "Iptables include flags: "
-
 
7776
  if [ "$IPTINC" ]; then
-
 
7777
    echo "$IPTINC (user specified)"
-
 
7778
  elif [ "$PKGVER" ]; then
-
 
7779
    IPTINC="$PKGINC"
-
 
7780
    echo "$IPTINC (pkg-config)"
-
 
7781
  elif [ "$NOIPTSRC" ]; then
-
 
7782
    IPTINC=
-
 
7783
    echo "none (default)"
-
 
7784
  else
-
 
7785
    IPTINC="$IPTSRC/include"
-
 
7786
    IPTINC="-I$IPTINC"
-
 
7787
    echo "$IPTINC (from source)"
-
 
7788
  fi
-
 
7789
}
-
 
7790
 
-
 
7791
iptables_modules() {
-
 
7792
  echo -n "Iptables module path: "
-
 
7793
  if [ "$IPTLIB" ]; then
-
 
7794
    echo "$IPTLIB (user specified)"
-
 
7795
  else
-
 
7796
    if [ "$PKGLIB" ]; then
-
 
7797
      IPTLIB="$PKGLIB"
-
 
7798
      echo "$IPTLIB (pkg-config)"
-
 
7799
    else
-
 
7800
      get_lib_dir "$IPTSRC/include/iptables.h" && return 0
-
 
7801
      get_lib_dir "$IPTSRC/include/xtables.h" && return 0
-
 
7802
      get_lib_dir "$IPTSRC/xtables/internal.h" && return 0
-
 
7803
      get_lib_from_bin && return 0
-
 
7804
      get_lib_from_lib && return 0
-
 
7805
      error "can not find, try setting it with --ipt-lib="
-
 
7806
    fi
-
 
7807
  fi
-
 
7808
}
-
 
7809
 
-
 
7810
try_dir() {
-
 
7811
  if [ -d "$1/include" ]; then
-
 
7812
    echo "Found iptables sources at $1"
-
 
7813
    IPTSRC=$1
-
 
7814
    return 0
-
 
7815
  fi
-
 
7816
  return 1
-
 
7817
}
-
 
7818
 
-
 
7819
try_dirg() {
-
 
7820
  try_dir "$1" && return 0
-
 
7821
  try_dir "$1.git" && return 0
-
 
7822
}
-
 
7823
 
-
 
7824
try_dir2() {
-
 
7825
  test -d "$1" && try_dir `dirname $1` && return 0
-
 
7826
}
-
 
7827
 
-
 
7828
check_pkg_config() {
-
 
7829
  test "$PKGWARN" && return 1
-
 
7830
  if ! which pkg-config >/dev/null 2>&1; then
-
 
7831
    echo "! You don't have pkg-config, it may be useful to install it."
-
 
7832
    PKGWARN=1
-
 
7833
    return 1
-
 
7834
  fi
-
 
7835
  return 0
-
 
7836
}
-
 
7837
iptables_find_version() {
-
 
7838
  echo -n "Iptables binary version: "
-
 
7839
  if [ "$IPTVER" ]; then
-
 
7840
    echo "$IPTVER (user specified)"
-
 
7841
  else
-
 
7842
    IPTVER=`$IPTBIN -V 2>/dev/null | sed -n s/iptables.v//p`
-
 
7843
    if [ "$IPTVER" ]; then
-
 
7844
      echo "$IPTVER (detected from $IPTBIN)"
-
 
7845
      return
-
 
7846
    else
-
 
7847
      echo "no iptables binary found"
-
 
7848
    fi
-
 
7849
    check_pkg_config
-
 
7850
    PKGVER=`pkg-config --modversion xtables 2>/dev/null`
-
 
7851
    if [ "$PKGVER" ]; then
-
 
7852
      IPTVER="$PKGVER"
-
 
7853
      echo "Xtables version: $IPTVER (detected from `which pkg-config`)"
-
 
7854
      return
-
 
7855
    fi
-
 
7856
    error "Can not find iptables version, try setting it with --ipt-ver="
-
 
7857
  fi
-
 
7858
}
-
 
7859
 
-
 
7860
compiler_presence_test() {
-
 
7861
  echo -n "Check for working gcc: "
-
 
7862
  $CC -v >/dev/null 2>&1
-
 
7863
  if [ $? = 0 ]; then
-
 
7864
    echo Yes "($CC)"
-
 
7865
  else
-
 
7866
    echo No
-
 
7867
 
-
 
7868
    echo "! You need gcc to install module from source"
-
 
7869
    if [ -s /etc/debian_version ]; then
-
 
7870
      NAME=Debian
-
 
7871
      if [ -e /etc/os-release ]; then
-
 
7872
	. /etc/os-release >/dev/null 2>&1
-
 
7873
      fi
-
 
7874
      echo "! "
-
 
7875
      echo "! Under $NAME try to run this:"
-
 
7876
      echo "!   root# apt-get install gcc"
-
 
7877
      echo "! "
-
 
7878
    elif [ -s /etc/redhat-release ]; then
-
 
7879
      echo "! "
-
 
7880
      echo "! Under Centos try to run this:"
-
 
7881
      echo "!   root# yum install gcc"
-
 
7882
      echo "! "
-
 
7883
    fi
-
 
7884
    exit 1
-
 
7885
  fi
-
 
7886
}
-
 
7887
 
-
 
7888
compile_libitp_test() {
-
 
7889
  local FLAGS
-
 
7890
  local MSG
-
 
7891
  echo -n "Checking for presence of $@... "
-
 
7892
  if [ "$IPTINC" ]; then
-
 
7893
    FLAGS=$IPTINC
-
 
7894
    MSG="(using ipt-inc)"
-
 
7895
  elif [ "$PKGINC" ]; then
-
 
7896
    FLAGS=$PKGINC
-
 
7897
    MSG="(using pkg-config)"
-
 
7898
  else
-
 
7899
    FLAGS=
-
 
7900
    MSG=
-
 
7901
  fi
-
 
7902
  echo "
-
 
7903
#define __EXPORTED_HEADERS__
-
 
7904
#include <$*>" > test.c
-
 
7905
  $CC -c test.c $FLAGS >/dev/null 2>&1
-
 
7906
  RET=$?
-
 
7907
  if [ $RET = 0 ]; then
-
 
7908
    echo Yes $MSG;
-
 
7909
  else
-
 
7910
    echo No;
-
 
7911
  fi
-
 
7912
  rm -f test.c test.o
-
 
7913
  return $RET
-
 
7914
}
-
 
7915
 
-
 
7916
iptables_try_pkgconfig() {
-
 
7917
  if [ ! "$PKGVER" ]; then
-
 
7918
    check_pkg_config
-
 
7919
    PKGVER=`pkg-config --modversion xtables 2>/dev/null`
-
 
7920
    TRYPKGVER=`pkg-config --modversion xtables 2>/dev/null`
-
 
7921
    echo -n "pkg-config for version $IPTVER exists: "
-
 
7922
    pkg-config --exact-version=$IPTVER xtables 2>/dev/null
-
 
7923
    if [ $? = 0 ]; then
-
 
7924
      echo "Yes"
-
 
7925
      PKGVER=$TRYPKGVER
-
 
7926
    else
-
 
7927
      if [ "$TRYPKGVER" ]; then
-
 
7928
	echo "No (reported: $TRYPKGVER)"
-
 
7929
      else
-
 
7930
	echo "No"
-
 
7931
      fi
-
 
7932
      PKGVER=
-
 
7933
    fi
-
 
7934
  fi
-
 
7935
  if [ "$PKGVER" ]; then
-
 
7936
    check_pkg_config
-
 
7937
    PKGVER=`pkg-config --modversion xtables 2>/dev/null`
-
 
7938
    PKGINC=`pkg-config --cflags xtables`
-
 
7939
    PKGLIB=`pkg-config --variable=xtlibdir xtables`
-
 
7940
  elif expr "$IPTVER" : '^1\.3' >/dev/null; then
-
 
7941
    echo "! This version of iptables ($IPTVER) will be treated as old version."
-
 
7942
    # Newer versions of iptables should not have -I/kernel/include!
-
 
7943
    # So I assume that newer version will have correct pkg-config set up
-
 
7944
    # and if not, then it's older who need it.
-
 
7945
    IPTCFLAGS="-I$KDIR/include -DIPTABLES_VERSION=\\\\\"$IPTVER\\\\\""
-
 
7946
  fi
-
 
7947
  compiler_presence_test
-
 
7948
  if compile_libitp_test xtables.h; then
-
 
7949
    IPTCFLAGS="-DXTABLES $IPTCFLAGS"
-
 
7950
  elif ! compile_libitp_test iptables.h; then
-
 
7951
    echo "! Iptables headers not found. You may need to specify --ipt-inc=..."
-
 
7952
    if [ -s /etc/debian_version ]; then
-
 
7953
      echo "! "
-
 
7954
      echo "! Under Debian simply run this:"
-
 
7955
      echo "!   root# apt-get install iptables-dev pkg-config"
-
 
7956
    elif [ -s /etc/redhat-release ]; then
-
 
7957
      echo "! "
-
 
7958
      arch=.`uname -m`
-
 
7959
      echo "! Under Centos simply run this:"
-
 
7960
      echo "!   root# yum install iptables-devel$arch pkgconfig"
-
 
7961
    fi
-
 
7962
    exit 1
-
 
7963
  fi
-
 
7964
 
-
 
7965
}
-
 
7966
 
-
 
7967
iptables_find_src() {
-
 
7968
  test "$IPTINC" && return 1
-
 
7969
  test "$PKGVER" && return 1
-
 
7970
 
-
 
7971
  VER="iptables-$IPTVER"
-
 
7972
  if [ "$IPTSRC" ]; then
-
 
7973
    echo "User specified source directory: $IPTSRC"
-
 
7974
    try_dir $IPTSRC || error "Specified directory is not iptables source.."
-
 
7975
  else
-
 
7976
    echo "Searching for $VER sources.."
-
 
7977
    try_dir "./$VER" && return 0
-
 
7978
    try_dir "../$VER" && return 0
-
 
7979
    try_dir "/usr/src/$VER" && return 0
-
 
7980
    try_dirg "iptables" && return 0
-
 
7981
    try_dirg "../iptables" && return 0
-
 
7982
    try_dirg "/usr/src/iptables" && return 0
-
 
7983
    try_dir2 `locate $VER/extensions 2>/dev/null | head -1` && return 0
-
 
7984
    echo "! Can not find iptables source directory, you may try setting it with --ipt-src="
-
 
7985
    echo "! This is not fatal error, yet. Will be just using default include dir."
-
 
7986
    NOIPTSRC=1
-
 
7987
  fi
-
 
7988
}
-
 
7989
 
-
 
7990
show_help() {
-
 
7991
  echo "Possible options:"
-
 
7992
  echo "  --ipt-ver=..  iptables version (ex.: 1.4.2)"
-
 
7993
  echo "  --ipt-bin=..  iptables binary to use (ex.: /usr/sbin/iptables)"
-
 
7994
  echo "  --ipt-src=..  directory for iptable source (ex.: ../iptables-1.4.2)"
-
 
7995
  echo "  --ipt-lib=..  iptable modules path (ex.: /usr/libexec/xtables)"
-
 
7996
  echo "  --ipt-inc=..  directory for iptable headers (ex.: /usr/include)"
-
 
7997
  echo "  --kver=..     kernel version (ex.: 2.6.30-std-def-alt15)"
-
 
7998
  echo "  --kdir=..     directory for kernel source (ex.: /usr/src/kernel)"
-
 
7999
  echo "  --enable-natevents     enables natevents support"
-
 
8000
  echo "  --enable-snmp-rules    enables SNMP-index conversion rules"
-
 
8001
  echo "  --enable-macaddress    enables MAC address for v9/IPFIX"
-
 
8002
  echo "  --enable-vlan          enables VLAN Ids for v9/IPFIX"
-
 
8003
  echo "  --enable-direction     enables flowDirection(61) Element"
-
 
8004
  echo "  --enable-sampler       enables Flow Sampling"
-
 
8005
  echo "  --enable-sampler=hash  enables Hash sampler"
-
 
8006
  echo "  --enable-aggregation   enables aggregation rules"
-
 
8007
  echo "  --enable-promisc       enables promisc hack mode"
-
 
8008
  echo "  --promisc-mpls         decapsulate MPLS in promisc mode"
-
 
8009
  echo "  --promisc-mpls=N       -- and record N labels (default 3)"
-
 
8010
  echo "  --enable-physdev       enables physdev reporting"
-
 
8011
  echo "  --enable-physdev-override      to override interfaces"
-
 
8012
  echo "  --disable-snmp-agent   disables net-snmp agent"
-
 
8013
  echo "  --disable-dkms         disables DKMS support completely"
-
 
8014
  echo "  --disable-dkms-install  no DKMS install but still create dkms.conf"
-
 
8015
  exit 0
-
 
8016
}
-
 
8017
 
-
 
8018
CARGS="$@"
-
 
8019
for ac_option
-
 
8020
do
-
 
8021
  case "$ac_option" in
-
 
8022
    -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-
 
8023
    *) ac_optarg= ;;
-
 
8024
  esac
-
 
8025
 
-
 
8026
  case "$ac_option" in
-
 
8027
    --ipt-bin=*) IPTBIN="$ac_optarg" ;;
-
 
8028
    --ipt-lib=*) IPTLIB="$ac_optarg" ;;
-
 
8029
    --ipt-src=*) IPTSRC="$ac_optarg" ;;
-
 
8030
    --ipt-ver=*) IPTVER="$ac_optarg" ;;
-
 
8031
    --ipt-inc=*) IPTINC="-I$ac_optarg" ;;
-
 
8032
    --kver=*)  KVERSION="$ac_optarg" ;;
-
 
8033
    --kdir=*)      KDIR="$ac_optarg" ;;
-
 
8034
    --enable-nat*)   KOPTS="$KOPTS -DENABLE_NAT" ;;
-
 
8035
    --enable-mac*)   KOPTS="$KOPTS -DENABLE_MAC" ;;
-
 
8036
    --enable-vlan*)  KOPTS="$KOPTS -DENABLE_VLAN" ;;
-
 
8037
    --enable-direc*) KOPTS="$KOPTS -DENABLE_DIRECTION" ;;
-
 
8038
    --enable-sampl*hash) KOPTS="$KOPTS -DENABLE_SAMPLER -DSAMPLING_HASH" ;;
-
 
8039
    --enable-sampl*) KOPTS="$KOPTS -DENABLE_SAMPLER" ;;
-
 
8040
    --enable-aggr*)  KOPTS="$KOPTS -DENABLE_AGGR" ;;
-
 
8041
    --enable-promi*)   ENABLE_PROMISC=1 ;;
-
 
8042
    --promisc-mpls*)   ENABLE_PROMISC=1; PROMISC_MPLS=1; MPLS_DEPTH=${ac_optarg:-3} ;;
-
 
8043
    --enable-snmp-r*)  KOPTS="$KOPTS -DSNMP_RULES" ;;
-
 
8044
    --enable-physdev)       KOPTS="$KOPTS -DENABLE_PHYSDEV" ;;
-
 
8045
    --enable-physdev-over*) KOPTS="$KOPTS -DENABLE_PHYSDEV_OVER" ;;
-
 
8046
    --disable-snmp-a*)   SKIPSNMP=1 ;;
-
 
8047
    --disable-net-snmp*) SKIPSNMP=1 ;;
-
 
8048
    --disable-dkms*)     SKIPDKMS=1 ;;
-
 
8049
    --from-dkms-conf*) ;;
-
 
8050
    --make) echo called from make; CARGS=`echo $CARGS | sed s/--make//g` ;;
-
 
8051
    -Werror) KOPTS="$KOPTS -Werror" ;;
-
 
8052
    --help|-h) show_help ;;
-
 
8053
    -*) echo Invalid option: $ac_option; exit 1 ;;
-
 
8054
#    *) ni="$ni $ac_option" ;;
-
 
8055
  esac
-
 
8056
done
-
 
8057
 
-
 
8058
if [ "$ENABLE_PROMISC" = 1 ]; then KOPTS="$KOPTS -DENABLE_PROMISC"; fi
-
 
8059
if [ "$PROMISC_MPLS" = 1 ]; then
-
 
8060
  KOPTS="$KOPTS -DPROMISC_MPLS"
-
 
8061
  case "$MPLS_DEPTH" in (*[!0-9]*|"") MPLS_DEPTH=1 ;; esac
-
 
8062
  if [ "$MPLS_DEPTH" -lt 1 ]; then
-
 
8063
    echo "! Requested MPLS stack depth is too small, limiting to 1."
-
 
8064
  elif [ "$MPLS_DEPTH" -gt 10 ]; then
-
 
8065
    echo "! Requested MPLS stack depth is too big, limiting to 10."
-
 
8066
    MPLS_DEPTH=10;
-
 
8067
  fi
-
 
8068
  if [ "$MPLS_DEPTH" -ge 1 ]; then KOPTS="$KOPTS -DMPLS_DEPTH=$MPLS_DEPTH"; fi
-
 
8069
fi
-
 
8070
 
-
 
8071
kernel_find_version() {
-
 
8072
  KHOW=requested
-
 
8073
  test "$KVERSION" && return 0
-
 
8074
 
-
 
8075
  if grep -q '#.*Debian' /proc/version; then
-
 
8076
    KHOW=proc
-
 
8077
    KVERSION=`sed -n 's/.*#.*Debian \([0-9\.]\+\)-.*/\1/p' /proc/version`
-
 
8078
    KLIBMOD=`uname -r`
-
 
8079
  else
-
 
8080
    KHOW=uname
-
 
8081
    KVERSION=`uname -r`
-
 
8082
  fi
-
 
8083
  test "$KDIR" || return 0
-
 
8084
 
-
 
8085
  test -s $KDIR/Makefile || return 1
-
 
8086
  test -s $KDIR/include/config/kernel.release || return 1
-
 
8087
  KVERSION=`cat $KDIR/include/config/kernel.release`
-
 
8088
  KHOW=sources
-
 
8089
}
-
 
8090
 
-
 
8091
kernel_check_src() {
-
 
8092
  if [ -s "$1/Makefile" ]; then
-
 
8093
    KDIR="$1"
-
 
8094
    return 0
-
 
8095
  fi
-
 
8096
  return 1
-
 
8097
}
-
 
8098
 
-
 
8099
kernel_check_src2() {
-
 
8100
  if kernel_check_src $1/source; then
-
 
8101
    KSRC=$KDIR
-
 
8102
  fi
-
 
8103
  kernel_check_src $1/build
-
 
8104
}
-
 
8105
 
-
 
8106
kernel_find_source() {
-
 
8107
  if [ "$KDKMS" ]; then
-
 
8108
    # dkms args is highest priority
-
 
8109
    KDIR=$KDKMS
-
 
8110
    KSHOW=dkms
-
 
8111
    return 0
-
 
8112
  fi
-
 
8113
  KSHOW=requested
-
 
8114
  test "$KDIR" && return 0
-
 
8115
  KSHOW=found
-
 
8116
  kernel_check_src2 /lib/modules/$KLIBMOD  && return 0
-
 
8117
  kernel_check_src2 /lib/modules/$KVERSION && return 0
-
 
8118
  kernel_check_src  /usr/src/kernels/$KVERSION && return 0
-
 
8119
  kernel_check_src  /usr/src/linux-$KVERSION && return 0
-
 
8120
  echo "! Linux source not found. Don't panic. You may specify kernel source"
-
 
8121
  echo "! directory with --kdir=..., or try to install kernel-devel package,"
-
 
8122
  echo "! or just raw sources for linux-$KVERSION from kernel.org."
-
 
8123
  if grep -q -i centos /proc/version 2>/dev/null; then
-
 
8124
    echo "! "
-
 
8125
    arch=.`uname -m`
-
 
8126
    echo "! Under Centos simply run this:"
-
 
8127
    echo "!   root# yum install kernel-devel iptables-devel$arch pkgconfig"
-
 
8128
  fi
-
 
8129
  if grep -q -i debian /proc/version 2>/dev/null; then
-
 
8130
    echo "! "
-
 
8131
    echo "! Under Debian simply run this:"
-
 
8132
    echo "!   root# apt-get install module-assistant iptables-dev pkg-config"
-
 
8133
    echo "!   root# m-a prepare"
-
 
8134
  fi
-
 
8135
  exit 1
-
 
8136
}
-
 
8137
 
-
 
8138
kernel_check_consistency() {
-
 
8139
  if [ -s $KDIR/include/config/kernel.release ]; then
-
 
8140
    SRCVER=`cat $KDIR/include/config/kernel.release`
-
 
8141
    if [ "$KVERSION" != "$SRCVER" ]; then
-
 
8142
      echo "! Warning: $KHOW kernel version ($KVERSION) and $KSHOW version of kernel source ($SRCVER) doesn't match!"
-
 
8143
      echo "!   You may try to specify only kernel source tree with --kdir=$KDIR"
-
 
8144
      echo "!   and configure will pick up version properly."
-
 
8145
      echo "! Assuming you want to build for $SRCVER"
-
 
8146
      KVERSION=$SRCVER
-
 
8147
    fi
-
 
8148
  fi
-
 
8149
  test -e "$KDIR/.config" || error ".config in kernel source not found, run  make menuconfig  in $KDIR"
-
 
8150
  test -d "$KDIR/include/config" || error "kernel is not prepared, run  make prepare modules_prepare  in $KDIR"
-
 
8151
}
-
 
8152
 
-
 
8153
kconfig() {
-
 
8154
  KCONFIG=$KDIR/.config
-
 
8155
  if ! grep -q "^$1=" $KCONFIG 2>/dev/null; then
-
 
8156
    if [ "$KCONFIGREPORTED" != true ]; then
-
 
8157
      KCONFIGREPORTED=true
-
 
8158
      echo Kernel config file checked: $KCONFIG
-
 
8159
      echo
-
 
8160
    fi
-
 
8161
    echo "! Attention: $1 is undefined in your kernel configuration"
-
 
8162
    echo "!   Without this option enabled $2 will not work."
-
 
8163
    echo
-
 
8164
  fi
-
 
8165
}
-
 
8166
 
-
 
8167
kernel_check_config() {
-
 
8168
  kconfig CONFIG_SYSCTL			"sysctl interface"
-
 
8169
  kconfig CONFIG_PROC_FS		"proc interface"
-
 
8170
  kconfig CONFIG_NF_NAT_NEEDED		"natevents"
-
 
8171
  kconfig CONFIG_NF_CONNTRACK_EVENTS	"natevents"
-
 
8172
  kconfig CONFIG_IPV6			"IPv6"
-
 
8173
  kconfig CONFIG_IP6_NF_IPTABLES	"ip6tables target"
-
 
8174
}
-
 
8175
 
-
 
8176
kernel_check_include() {
-
 
8177
  echo -n "Checking for presence of $1... "
-
 
8178
  if [ "$KSRC" -a -e $KSRC/$1 ]; then
-
 
8179
    echo Yes
-
 
8180
    KOPTS="$KOPTS $2"
-
 
8181
  elif [ -e $KDIR/$1 ]; then
-
 
8182
    echo Yes
-
 
8183
    KOPTS="$KOPTS $2"
-
 
8184
  else
-
 
8185
    echo No
-
 
8186
  fi
-
 
8187
}
-
 
8188
 
-
 
8189
kernel_check_features() {
-
 
8190
  kernel_check_include include/linux/llist.h -DHAVE_LLIST
-
 
8191
  kernel_check_include include/linux/grsecurity.h -DHAVE_GRSECURITY_H
-
 
8192
}
-
 
8193
 
-
 
8194
snmp_check() {
-
 
8195
  SNMPTARGET=
-
 
8196
  SNMPINSTALL=
-
 
8197
  test "$SKIPSNMP" && return
-
 
8198
 
-
 
8199
  echo -n "Searching for net-snmp-config... "
-
 
8200
  if which net-snmp-config >/dev/null 2>&1; then
-
 
8201
    echo Yes `which net-snmp-config`
-
 
8202
  else
-
 
8203
    echo No.
-
 
8204
    SNMPCONFIG=no
-
 
8205
  fi
-
 
8206
 
-
 
8207
  echo -n "Searching for net-snmp agent... "
-
 
8208
  if [ -s /etc/redhat-release ]; then
-
 
8209
    if ! rpm --quiet -q net-snmp; then
-
 
8210
      echo No.
-
 
8211
      SNMPADD="do:  yum install net-snmp"
-
 
8212
      if [ "$SNMPCONFIG" ]; then
-
 
8213
	SNMPADD="$SNMPADD net-snmp-devel"
-
 
8214
      fi
-
 
8215
    else
-
 
8216
      echo Yes.
-
 
8217
    fi
-
 
8218
    if [ "$SNMPCONFIG" ]; then
-
 
8219
      SNMPCONFIG="run:  yum install net-snmp-devel"
-
 
8220
    fi
-
 
8221
  elif [ -s /etc/debian_version ]; then
-
 
8222
    if ! dpkg -s snmpd >/dev/null 2>&1; then
-
 
8223
      echo No.
-
 
8224
      SNMPADD="do:  apt-get install snmpd"
-
 
8225
      if [ "$SNMPCONFIG" ]; then
-
 
8226
	SNMPADD="$SNMPADD libsnmp-dev"
-
 
8227
      fi
-
 
8228
    else
-
 
8229
      echo Yes.
-
 
8230
    fi
-
 
8231
    if [ "$SNMPCONFIG" ]; then
-
 
8232
      SNMPCONFIG="run:  apt-get install libsnmp-dev"
-
 
8233
    fi
-
 
8234
  elif [ -s /etc/snmp/snmpd.conf ]; then
-
 
8235
    echo Yes.
-
 
8236
  else
-
 
8237
    echo No.
-
 
8238
    SNMPADD="install net-snmp (www.net-snmp.org)"
-
 
8239
    SNMPCONFIG="reinstall net-snmp with agent support."
-
 
8240
  fi
-
 
8241
 
-
 
8242
  if [ "$SNMPADD" ]; then
-
 
8243
    echo " Assuming you don't want net-snmp agent support".
-
 
8244
    echo " Otherwise $SNMPADD"
-
 
8245
    return
-
 
8246
  elif [ "$SNMPCONFIG" ]; then
-
 
8247
    echo "! You have net-snmp agent but not development package."
-
 
8248
    echo "! net-snmp agent will not be built, to fix:"
-
 
8249
    echo "!   $SNMPCONFIG"
-
 
8250
    return
-
 
8251
  fi
-
 
8252
 
-
 
8253
  SNMPTARGET=snmp_NETFLOW.so
-
 
8254
  SNMPINSTALL=sinstall
-
 
8255
}
-
 
8256
 
-
 
8257
dkms_check() {
-
 
8258
  DKMSINSTALL=
-
 
8259
  test "$SKIPDKMS" && return
-
 
8260
 
-
 
8261
  echo -n "Checking for DKMS... "
-
 
8262
  if ! which dkms >/dev/null 2>&1; then
-
 
8263
    echo "No. (It may be useful to install it.)"
-
 
8264
    echo "! "
-
 
8265
    echo "! DKMS is method of installing kernel modules, that will"
-
 
8266
    echo "! automatically recompile module after kernel upgrade."
-
 
8267
    if [ -s /etc/debian_version ]; then
-
 
8268
      echo "! "
-
 
8269
      echo "! To install it under Debian simply run this:"
-
 
8270
      echo "!   root# apt-get install dkms"
-
 
8271
      echo "! "
-
 
8272
    elif [ -s /etc/redhat-release ]; then
-
 
8273
      echo "! "
-
 
8274
      echo "! To install it under Centos enable EPEL or RPMforge repository,"
-
 
8275
      echo "! then run this:"
-
 
8276
      echo "!   root# yum install dkms"
-
 
8277
      echo "! "
-
 
8278
    fi
-
 
8279
    return
-
 
8280
  fi
-
 
8281
  echo Yes.
-
 
8282
  DKMSINSTALL=dinstall
-
 
8283
  test "$FROMDKMSCONF" && return
-
 
8284
  if dkms status | grep ^ipt-netflow, >/dev/null; then
-
 
8285
    echo "! You are already have module installed via DKMS"
-
 
8286
    echo "!   it will be uninstalled on 'make install' and"
-
 
8287
    echo "!   current version of module installed afterwards."
-
 
8288
    echo "! Use --disable-dkms option if don't want this."
-
 
8289
  fi
-
 
8290
}
-
 
8291
 
-
 
8292
kernel_find_version	#KVERSION
-
 
8293
test "$KLIBMOD" || KLIBMOD=$KVERSION
-
 
8294
echo "Kernel version: $KVERSION ($KHOW)"
-
 
8295
kernel_find_source	#KDIR
-
 
8296
echo "Kernel sources: $KDIR ($KSHOW)"
-
 
8297
kernel_check_consistency
-
 
8298
kernel_check_config
-
 
8299
kernel_check_features
-
 
8300
 
-
 
8301
CC=${CC:-gcc}
-
 
8302
test "$IPTBIN" || IPTBIN=`which iptables`
-
 
8303
 
-
 
8304
iptables_find_version	#IPTVER
-
 
8305
iptables_try_pkgconfig	#try to configure from pkg-config
-
 
8306
iptables_find_src	#IPTSRC
-
 
8307
iptables_src_version	#check that IPTSRC match to IPTVER
-
 
8308
iptables_inc		#IPTINC
-
 
8309
iptables_modules	#IPTLIB
-
 
8310
 
-
 
8311
snmp_check
-
 
8312
dkms_check
-
 
8313
 
-
 
8314
REPLACE="\
-
 
8315
s!@CARGS@!$CARGS!;\
-
 
8316
s!@KVERSION@!$KVERSION!;\
-
 
8317
s!@KDIR@!$KDIR!;\
-
 
8318
s!@KOPTS@!$KOPTS!;\
-
 
8319
s!@SNMPTARGET@!$SNMPTARGET!;\
-
 
8320
s!@SNMPINSTALL@!$SNMPINSTALL!;\
-
 
8321
s!@DKMSINSTALL@!$DKMSINSTALL!;\
-
 
8322
s!@IPTABLES_VERSION@!$IPTVER!;\
-
 
8323
s!@IPTABLES_CFLAGS@!$IPTCFLAGS $IPTINC!;\
-
 
8324
s!@IPTABLES_MODULES@!$IPTLIB!"
-
 
8325
 
-
 
8326
echo -n "Creating Makefile.. "
-
 
8327
 sed "$REPLACE" Makefile.in > Makefile
-
 
8328
 echo done.
-
 
8329
echo
-
 
8330
echo "  If you need some options enabled run ./configure --help"
-
 
8331
echo "  Now run: make all install"
-
 
8332
echo
-
 
8333
 
-
 
8334
ipt-netflow-2.2/openwrt/0000755000000000000000000000000013213006644014020 5ustar  rootrootipt-netflow-2.2/openwrt/Readme.md0000644000000000000000000000360113213006644015537 0ustar  rootrootCross-compiling and packages for openwrt
-
 
8335
===
-
 
8336
 
-
 
8337
Place Makefile in `packages/network/ipt-netflow` directory in OpenWRT bouldroot.
-
 
8338
Run `make menuconfig` and select package in Network/Netflow menu. Configure args partially supported.
-
 
8339
 
-
 
8340
Run `make` to build full firmware or `make package/network/ipt-netflow/{clean,prepare,configure,compile,install}` to rebuild packages.
-
 
8341
 
-
 
8342
To make git version uncomment two lines in Makefile.
-
 
8343
 
-
 
8344
Tested to work on Chaos Calmer and Designated Driver with Atheros AR7xxx/AR9xxx target.
-
 
8345
 
-
 
8346
For ipt-netflow 2.2 patches are needed, drop it for next version or git master to build.
-
 
8347
 
-
 
8348
Making and installilng
-
 
8349
===
-
 
8350
 
-
 
8351
```shell
-
 
8352
mkdir debian-toolchain
-
 
8353
sudo debootstrap jessie debian-toolchain
-
 
8354
sudo chroot debian-toolchain
-
 
8355
 
-
 
8356
. /etc/profile
-
 
8357
apt update
-
 
8358
apt install git ssh-client build-essential mercurial subversion \
-
 
8359
   binutils flex bzip2 asciidoc ncurses-dev libssl-dev gawk zlib1g-dev fastjar
-
 
8360
 
-
 
8361
adduser user
-
 
8362
su user
-
 
8363
. /etc/profile
-
 
8364
cd ~
-
 
8365
 
-
 
8366
git clone https://github.com/openwrt/openwrt.git openwrt-trunk
-
 
8367
git clone https://github.com/aabc/ipt-netflow.git
-
 
8368
 
-
 
8369
cd openwrt-trunk
-
 
8370
./scripts/feeds update -a
-
 
8371
ln -s ~/ipt-netflow/openwrt/ package/network/ipt-netflow
-
 
8372
 
-
 
8373
 
-
 
8374
make menuconfig
-
 
8375
  #select target and device
-
 
8376
  #go to network/netflow and check both
-
 
8377
 
-
 
8378
make
-
 
8379
  #and go for dinner or a walk ;)
-
 
8380
  #after five hours
-
 
8381
 
-
 
8382
scp bin/ar71xx/packages/kernel/kmod-ipt-netflow_4.4.14+2.2-2_ar71xx.ipk  \
-
 
8383
   root@192.168.236.79:/tmp/
-
 
8384
scp bin/ar71xx/packages/base/iptables-mod-netflow_2.2-2_ar71xx.ipk \
-
 
8385
   root@192.168.236.79:/tmp/
-
 
8386
scp bin/ar71xx/packages/base/kernel_4.4.14-1-abf9cc6feb410252d667326556dae184_ar71xx.ipk   \
-
 
8387
   root@192.168.236.79:/tmp/
-
 
8388
 
-
 
8389
   #goto router
-
 
8390
ssh root@192.168.236.79
-
 
8391
 
-
 
8392
opkg install /tmp/*.ipk
-
 
8393
 
-
 
8394
insmod /lib/modules/4.4.14/ipt_NETFLOW.ko
-
 
8395
sysctl -w net.netflow.protocol=5
-
 
8396
sysctl -w net.netflow.destination=192.168.236.34:2055
-
 
8397
 
-
 
8398
iptables -I FORWARD -j NETFLOW
-
 
8399
iptables -I INPUT -j NETFLOW
-
 
8400
iptables -I OUTPUT -j NETFLOW
-
 
8401
 
-
 
8402
```
-
 
8403
ipt-netflow-2.2/openwrt/Makefile0000644000000000000000000001001113213006644015451 0ustar  rootrootinclude $(TOPDIR)/rules.mk
-
 
8404
include $(INCLUDE_DIR)/kernel.mk
-
 
8405
 
-
 
8406
PKG_NAME:=ipt-netflow
-
 
8407
PKG_RELEASE:=2
-
 
8408
 
-
 
8409
PKG_SOURCE_URL:=https://github.com/aabc/$(PKG_NAME).git
-
 
8410
PKG_VERSION:=2.2
-
 
8411
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
-
 
8412
 
-
 
8413
#TO BUILD development version uncomment 2 rows below and remove patches
-
 
8414
#PKG_VERSION:=$(shell (git ls-remote $(PKG_SOURCE_URL) | grep refs/heads/master | cut -f 1 | head -c 7))
-
 
8415
#PKG_SOURCE_VERSION:=HEAD
-
 
8416
 
-
 
8417
PKG_SOURCE_PROTO:=git
-
 
8418
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-
 
8419
 
-
 
8420
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-
 
8421
 
-
 
8422
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
-
 
8423
PKG_DEPENDS:=iptables
-
 
8424
 
-
 
8425
include $(INCLUDE_DIR)/package.mk
-
 
8426
 
-
 
8427
 
-
 
8428
define KernelPackage/ipt-netflow
-
 
8429
	SECTION:=net
-
 
8430
	CATEGORY:=Network
-
 
8431
	SUBMENU:=Netflow
-
 
8432
	TITLE:=Netflow iptables module for Linux kernel
-
 
8433
	URL:=http://ipt-netflow.sourceforge.net/
-
 
8434
	FILES:=$(PKG_BUILD_DIR)/ipt_NETFLOW.ko
-
 
8435
	DEPENDS:=+iptables +iptables-mod-netflow
-
 
8436
endef
-
 
8437
 
-
 
8438
 
-
 
8439
define Package/iptables-mod-netflow
-
 
8440
	SECTION:=net
-
 
8441
	CATEGORY:=Network
-
 
8442
	SUBMENU:=Netflow
-
 
8443
	TITLE:=Netflow iptables module for Linux kernel
-
 
8444
	URL:=http://ipt-netflow.sourceforge.net/
-
 
8445
	#DEPENDS:=+kmod-ipt-netflow
-
 
8446
	DEPENDS:=+iptables
-
 
8447
endef
-
 
8448
 
-
 
8449
CONFIGURE_ARGS:= \
-
 
8450
	--kdir="$(LINUX_DIR)" 
-
 
8451
 
-
 
8452
define Package/iptables-mod-netflow/config
-
 
8453
	menu "Configuration"
-
 
8454
		depends on PACKAGE_iptables-mod-netflow
-
 
8455
	config PACKAGE_iptables-mod-netflow_natevents
-
 
8456
		bool "enables natevents support"
-
 
8457
		default n
-
 
8458
	config PACKAGE_iptables-mod-netflow_snmp-rules
-
 
8459
		bool "enables SNMP-index conversion rules"
-
 
8460
		default n
-
 
8461
	config PACKAGE_iptables-mod-netflow_macaddress
-
 
8462
		bool "enables MAC address for v9/IPFIX"
-
 
8463
		default n
-
 
8464
	config PACKAGE_iptables-mod-netflow_vlan
-
 
8465
		bool "enables VLAN Ids for v9/IPFIX"
-
 
8466
		default n
-
 
8467
	config PACKAGE_iptables-mod-netflow_direction
-
 
8468
		bool "enables flowDirection(61) Element"
-
 
8469
		default n
-
 
8470
	config PACKAGE_iptables-mod-netflow_sampler
-
 
8471
		bool "enables Flow Sampling"
-
 
8472
		default n
-
 
8473
	config PACKAGE_iptables-mod-netflow_aggregation
-
 
8474
		bool "enables aggregation rules"
-
 
8475
		default n
-
 
8476
	config PACKAGE_iptables-mod-netflow_promisc
-
 
8477
		bool "enables promisc hack mode"
-
 
8478
		default n
-
 
8479
	config PACKAGE_iptables-mod-netflow_promisc-mpls
-
 
8480
		bool "decapsulate MPLS in promisc mode"
-
 
8481
		default n
-
 
8482
	config PACKAGE_iptables-mod-netflow_physdev
-
 
8483
		bool "enables physdev reporting"
-
 
8484
		default n
-
 
8485
	config PACKAGE_iptables-mod-netflow_physdev-override
-
 
8486
		bool "to override interfaces"
-
 
8487
		default n
-
 
8488
	config PACKAGE_iptables-mod-netflow_snmp-agent
-
 
8489
		bool "disables net-snmp agent"
-
 
8490
		default y
-
 
8491
	config PACKAGE_iptables-mod-netflow_dkms
-
 
8492
		bool "disables DKMS support completely"
-
 
8493
		default y
-
 
8494
	config PACKAGE_iptables-mod-netflow_dkms-install
-
 
8495
		bool "no DKMS install but still create dkms.conf"
-
 
8496
		default n
-
 
8497
	endmenu
-
 
8498
endef
-
 
8499
 
-
 
8500
CONFIGURE_ARGS += \
-
 
8501
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_natevents),--enable-natevents) \
-
 
8502
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_snmp-rules),--enable-snmp-rules) \
-
 
8503
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_macaddress),--enable-macaddress) \
-
 
8504
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_vlan),--enable-vlan) \
-
 
8505
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_direction),--enable-direction) \
-
 
8506
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_sampler),--enable-sampler) \
-
 
8507
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_aggregation),--enable-aggregation) \
-
 
8508
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_promisc),--enable-promisc) \
-
 
8509
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_promisc-mpls),--promisc-mpls) \
-
 
8510
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_physdev),--enable-physdev) \
-
 
8511
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_physdev-override),--enable-physdev-override) \
-
 
8512
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_snmp-agent),--disable-snmp-agent) \
-
 
8513
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_dkms),--disable-dkms) \
-
 
8514
	$(if $(CONFIG_PACKAGE_iptables-mod-netflow_dkms-install),--disable-dkms-install) 
-
 
8515
 
-
 
8516
#TODO: --enable-sampler=hash --promisc-mpls=N
-
 
8517
 
-
 
8518
 
-
 
8519
$(eval $(call KernelPackage,ipt-netflow))
-
 
8520
 
-
 
8521
$(eval $(call Package,kmod-ipt-netflow))
-
 
8522
 
-
 
8523
define Package/iptables-mod-netflow/install
-
 
8524
	$(MAKE) -C $(PKG_BUILD_DIR) DESTDIR=$(1) linstall
-
 
8525
	#TODO: snmp install, dkms install
-
 
8526
endef
-
 
8527
 
-
 
8528
$(eval $(call BuildPackage,iptables-mod-netflow))
-
 
8529
ipt-netflow-2.2/openwrt/patches/0000755000000000000000000000000013213006644015447 5ustar  rootrootipt-netflow-2.2/openwrt/patches/310-Makefile_crosscompile.patch0000644000000000000000000000111713213006644023270 0ustar  rootrootIndex: ipt-netflow-2.2/Makefile.in
-
 
8530
===================================================================
-
 
8531
--- ipt-netflow-2.2.orig/Makefile.in
-
 
8532
+++ ipt-netflow-2.2/Makefile.in
-
 
8533
@@ -64,10 +64,10 @@ sinstall: | snmp_NETFLOW.so IPT-NETFLOW-
-
 
8534
 	fi
-
 
8535
 
-
 
8536
 %_sh.o: libipt_NETFLOW.c
-
 
8537
-	gcc -O2 -Wall -Wunused $(IPTABLES_CFLAGS) -fPIC -o $@ -c libipt_NETFLOW.c
-
 
8538
+	$(CC) $(CFLAGS) -O2 -Wall -Wunused $(IPTABLES_CFLAGS) -fPIC -o $@ -c libipt_NETFLOW.c
-
 
8539
 
-
 
8540
 %.so: %_sh.o
-
 
8541
-	gcc -shared -o $@ $<
-
 
8542
+	$(CC) -shared -o $@ $<
-
 
8543
 
-
 
8544
 version.h: ipt_NETFLOW.c ipt_NETFLOW.h compat.h Makefile
-
 
8545
 	@./version.sh --define > version.h
-
 
8546
ipt-netflow-2.2/irqtop0000755000000000000000000003676013213006644013602 0ustar  rootroot#!/usr/bin/ruby
-
 
8547
# Obeserve irq and softirq in top fashion
-
 
8548
# (c) 2014 <abc@telekom.ru>
-
 
8549
# License: GPL.
-
 
8550
 
-
 
8551
require 'getoptlong'
-
 
8552
require 'curses'
-
 
8553
require 'stringio'
-
 
8554
 
-
 
8555
@imode = :both
-
 
8556
@omode = :table
-
 
8557
@color = true
-
 
8558
@showrps = false
-
 
8559
 
-
 
8560
GetoptLong.new(
-
 
8561
    ["--help",     "-h", GetoptLong::NO_ARGUMENT],
-
 
8562
    ["--batch",    "-b", GetoptLong::NO_ARGUMENT],
-
 
8563
    ["--delay",    "-d", GetoptLong::REQUIRED_ARGUMENT],
-
 
8564
    ["--top",      "-t", GetoptLong::NO_ARGUMENT],
-
 
8565
    ["--table",    "-x", GetoptLong::NO_ARGUMENT],
-
 
8566
    ["--soft",     "-s", GetoptLong::NO_ARGUMENT],
-
 
8567
    ["--softirq",        GetoptLong::NO_ARGUMENT],
-
 
8568
    ["--softirqs",       GetoptLong::NO_ARGUMENT],
-
 
8569
    ["--irq",      "-i", GetoptLong::NO_ARGUMENT],
-
 
8570
    ["--irqs",           GetoptLong::NO_ARGUMENT],
-
 
8571
    ["--reverse",  "-r", GetoptLong::NO_ARGUMENT],
-
 
8572
    ["--nocolor",  "-C", GetoptLong::NO_ARGUMENT],
-
 
8573
    ["--eth",      "-e", "--pps", GetoptLong::NO_ARGUMENT],
-
 
8574
    ["--rps",      "-R", "--xps", GetoptLong::NO_ARGUMENT]
-
 
8575
).each do |opt, arg|
-
 
8576
  case opt
-
 
8577
  when '--help'
-
 
8578
    puts " Shows interrupt rates (per second) per cpu."
-
 
8579
    puts " Also shows irq affinity ('.' for disabled cpus),"
-
 
8580
    puts " and rps/xps affinity ('+' rx, '-' tx, '*' tx/rx)."
-
 
8581
    puts " Can show packet rate per eth queue."
-
 
8582
    puts
-
 
8583
    puts " Usage: #{$0} [-h] [-d #{@delay}] [-b] [-t|-x] [-i|-s] [-r]"
-
 
8584
    puts "    -d  --delay=n  refresh interval"
-
 
8585
    puts "    -s  --softirq  select softirqs only"
-
 
8586
    puts "    -i  --irq      select hardware irqs only"
-
 
8587
    puts "    -e  --eth      show extra eth stats (from ethtool)"
-
 
8588
    puts "    -R  --rps      enable display of rps/xps"
-
 
8589
    puts "    -x  --table    output in table mode (default)"
-
 
8590
    puts "    -t  --top      output in flat top mode"
-
 
8591
    puts "    -b  --batch    output non-interactively"
-
 
8592
    puts "    -r  --reverse  reverse sort order"
-
 
8593
    puts "    -C  --nocolor  disable colors"
-
 
8594
    puts
-
 
8595
    puts " Rates marked as '.' is forbidden by smp_affinity mask."
-
 
8596
    exit 0
-
 
8597
  when '--reverse'
-
 
8598
    @reverse = !@reverse
-
 
8599
  when '--batch'
-
 
8600
    @batch = true
-
 
8601
    @reverse = !@reverse if @omode == :top
-
 
8602
  when '--delay'
-
 
8603
    @delay = arg.to_i
-
 
8604
  when '--top'
-
 
8605
    @omode = :top
-
 
8606
  when '--table'
-
 
8607
    @omode = :table
-
 
8608
  when /--irq/
-
 
8609
    @imode = :irq
-
 
8610
  when /--soft/
-
 
8611
    @imode = :soft
-
 
8612
  when /--pps/
-
 
8613
    @pps = true
-
 
8614
  when /--nocolor/
-
 
8615
    @color = false
-
 
8616
  when /--rps/
-
 
8617
    @showrps = !@showrps
-
 
8618
  end
-
 
8619
end
-
 
8620
if !@delay && ARGV[0].to_f > 0
-
 
8621
  @delay = ARGV.shift.to_f
-
 
8622
else
-
 
8623
  @delay = 5
-
 
8624
end
-
 
8625
@count = ARGV.shift.to_f if ARGV[0].to_i > 0
-
 
8626
 
-
 
8627
def read_table(tag, file)
-
 
8628
  @cpus = []
-
 
8629
  lines = IO.readlines(file)
-
 
8630
  @cpus = lines[0].scan(/CPU\d+/)
-
 
8631
  @icpus = @cpus if tag == 'i'
-
 
8632
  lines[2..-1].each do |li|
-
 
8633
    irq, stat, desc = li.match(/^\s*(\S+):((?:\s+\d+)+)(.*)$/).captures
-
 
8634
    stat = stat.scan(/\d+/)
-
 
8635
    @irqs << [tag, irq, desc]
-
 
8636
    stat.each_with_index do |val, i|
-
 
8637
      # interruptsN, 's|i', irq'N', 'cpuX', 'descr...'
-
 
8638
      @stats << [val.to_i, tag, irq, @cpus[i], desc.strip]
-
 
8639
    end
-
 
8640
  end
-
 
8641
end
-
 
8642
 
-
 
8643
def read_procstat
-
 
8644
  @cstat = {}
-
 
8645
  lines = IO.readlines("/proc/stat").grep(/^cpu\d+ /)
-
 
8646
  lines.each do |li|
-
 
8647
    c, *d = li.split(" ")
-
 
8648
    d = d.map {|e| e.to_i}
-
 
8649
    @cstat[c] = d
-
 
8650
  end
-
 
8651
end
-
 
8652
 
-
 
8653
def read_affinity
-
 
8654
  @aff = {}
-
 
8655
  Dir.glob("/proc/irq/*/smp_affinity").each do |af|
-
 
8656
    irq = af[%r{\d+}].to_i
-
 
8657
    a = IO.read(af).strip.to_i(16)
-
 
8658
    @aff[irq] = a
-
 
8659
  end
-
 
8660
end
-
 
8661
 
-
 
8662
# list ethernet devices
-
 
8663
def net_devices_pci
-
 
8664
  Dir['/sys/class/net/*'].reject do |f|
-
 
8665
    f += "/device" unless File.symlink?(f)
-
 
8666
    if File.symlink?(f)
-
 
8667
      !(File.readlink(f) =~ %r{devices/pci})
-
 
8668
    else
-
 
8669
      false
-
 
8670
    end
-
 
8671
  end.map {|f| File.basename(f)}
-
 
8672
end
-
 
8673
 
-
 
8674
@devlist = net_devices_pci
-
 
8675
@devre = Regexp.union(@devlist)
-
 
8676
def get_rps(desc)
-
 
8677
  @rps = @xps = 0
-
 
8678
  return unless @showrps
-
 
8679
  return if @devlist.empty?
-
 
8680
  dev = desc[/\b(#{@devre})\b/, 1]
-
 
8681
  return unless dev
-
 
8682
  return unless desc =~ /-(tx|rx)+-\d+/i
-
 
8683
  qnr = desc[/-(\d+)\s*$/, 1]
-
 
8684
  return unless qnr
-
 
8685
  begin
-
 
8686
    @rps = IO.read("/sys/class/net/#{dev}/queues/rx-#{qnr}/rps_cpus").hex if desc =~ /rx/i
-
 
8687
    @xps = IO.read("/sys/class/net/#{dev}/queues/tx-#{qnr}/xps_cpus").hex if desc =~ /tx/i
-
 
8688
  rescue
-
 
8689
  end
-
 
8690
end
-
 
8691
 
-
 
8692
def calc_rps(cpu)
-
 
8693
  m = 0
-
 
8694
  m |= 1 if @rps & (1 << cpu) != 0
-
 
8695
  m |= 2 if @xps & (1 << cpu) != 0
-
 
8696
  " +-*".slice(m, 1)
-
 
8697
end
-
 
8698
 
-
 
8699
# ethtool -S eth0
-
 
8700
def ethtool_grab_stat(dev = nil)
-
 
8701
  unless dev
-
 
8702
    @esto = @est if @est
-
 
8703
    @est = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }
-
 
8704
    @devlist = net_devices_pci
-
 
8705
    @devre = Regexp.union(@devlist)
-
 
8706
    # own time counter because this stat could be paused
-
 
8707
    @ehts = @ets if @ets
-
 
8708
    @ets = @ts
-
 
8709
    @edt = @ets - @ehts if @ehts
-
 
8710
    @devlist.each {|e| ethtool_grab_stat(e)}
-
 
8711
    return
-
 
8712
  end
-
 
8713
  h = Hash.new {|k,v| k[v] = Array.new}
-
 
8714
  t = `ethtool -S #{dev} 2>/dev/null`
-
 
8715
  return if t == ''
-
 
8716
  t.split("\n").map { |e|
-
 
8717
    e.split(':')
-
 
8718
  }.reject { |e|
-
 
8719
    !e[1]
-
 
8720
  }.each { |k,v|
-
 
8721
    k.strip!
-
 
8722
    v = v.strip.to_i
-
 
8723
    if k =~ /^.x_queue_(\d+)_/
-
 
8724
      t = k.split('_', 4)
-
 
8725
      qdir = t[0]
-
 
8726
      qnr  = t[2]
-
 
8727
      qk   = t[3]
-
 
8728
      @est[dev][qdir][qnr][qk] = v
-
 
8729
    else
-
 
8730
      @est[dev][k] = v
-
 
8731
    end
-
 
8732
  }
-
 
8733
end
-
 
8734
 
-
 
8735
def e_queue_stat(dev, qdir, qnr, k)
-
 
8736
  n = @est[dev][qdir][qnr][k]
-
 
8737
  o = @esto[dev][qdir][qnr][k]
-
 
8738
  d = (n - o) / @edt
-
 
8739
  if d > 0
-
 
8740
    "%s:%d" % [qdir, d]
-
 
8741
  else
-
 
8742
    nil
-
 
8743
  end
-
 
8744
end
-
 
8745
 
-
 
8746
def e_dev_stat(dev, k, ks)
-
 
8747
  n = @est[dev][k]
-
 
8748
  o = @esto[dev][k]
-
 
8749
  r = (n - o) / @edt
-
 
8750
  ks = k unless ks
-
 
8751
  "%s:%d" % [ks, r]
-
 
8752
end
-
 
8753
 
-
 
8754
def e_queue_stat_err(dev, qdir, qnr)
-
 
8755
  r = []
-
 
8756
  ek = @est[dev][qdir][qnr].keys.reject{|e| e =~ /^(bytes|packets)$/}
-
 
8757
  ek.each do |k|
-
 
8758
    n = @est[dev][qdir][qnr][k]
-
 
8759
    o = @esto[dev][qdir][qnr][k]
-
 
8760
    d = n - o
-
 
8761
    r << "%s_%s:%d" % [qdir, k, d] if d.to_i > 0
-
 
8762
  end
-
 
8763
  r
-
 
8764
end
-
 
8765
 
-
 
8766
# this is not rate
-
 
8767
def e_dev_stat_sum(dev, rk, ks)
-
 
8768
  ek = @est[dev].keys.reject{|ek| !(ek =~ rk)}
-
 
8769
  n = ek.inject(0) {|sum,k| sum += @est[dev][k].to_i}
-
 
8770
  o = ek.inject(0) {|sum,k| sum += @esto[dev][k].to_i rescue 0}
-
 
8771
  r = (n - o)
-
 
8772
  if r > 0
-
 
8773
    "%s:%d" % [ks, r]
-
 
8774
  else
-
 
8775
    nil
-
 
8776
  end
-
 
8777
end
-
 
8778
 
-
 
8779
def print_ethstat(desc)
-
 
8780
  return if @devlist.empty?
-
 
8781
  dev = desc[/\b(#{@devre})\b/, 1]
-
 
8782
  return unless dev
-
 
8783
  unless @esto && @est
-
 
8784
    print ' []'
-
 
8785
    return
-
 
8786
  end
-
 
8787
  t = []
-
 
8788
  if desc =~ /-(tx|rx)+-\d+/i
-
 
8789
    qnr = desc[/-(\d+)\s*$/, 1]
-
 
8790
    if qnr
-
 
8791
      if desc =~ /rx/i
-
 
8792
	t << e_queue_stat(dev, "rx", qnr, "packets")
-
 
8793
	t += e_queue_stat_err(dev, "rx", qnr)
-
 
8794
      end
-
 
8795
      if desc =~ /tx/i
-
 
8796
	t << e_queue_stat(dev, "tx", qnr, "packets")
-
 
8797
	t += e_queue_stat_err(dev, "tx", qnr)
-
 
8798
      end
-
 
8799
    end
-
 
8800
  else
-
 
8801
    t << e_dev_stat(dev, "rx_packets", 'rx')
-
 
8802
    t << e_dev_stat(dev, "tx_packets", 'tx')
-
 
8803
    t << e_dev_stat_sum(dev, /_err/, 'err')
-
 
8804
    t << e_dev_stat_sum(dev, /_drop/, 'drop')
-
 
8805
  end
-
 
8806
  t.delete(nil)
-
 
8807
  print ' [' + t.join(' ') + ']'
-
 
8808
end
-
 
8809
 
-
 
8810
def grab_stat
-
 
8811
  # @h[istorical]
-
 
8812
  @hstats = @stats
-
 
8813
  @hcstat = @cstat
-
 
8814
  @hts = @ts
-
 
8815
 
-
 
8816
  @stats = []
-
 
8817
  @irqs = []
-
 
8818
  @ts = Time.now
-
 
8819
  @dt = @ts - @hts if @hts
-
 
8820
 
-
 
8821
  read_table 'i', "/proc/interrupts"
-
 
8822
  read_table 's', "/proc/softirqs"
-
 
8823
  read_affinity
-
 
8824
  read_procstat
-
 
8825
  ethtool_grab_stat if @pps
-
 
8826
end
-
 
8827
 
-
 
8828
def calc_speed
-
 
8829
  s = []
-
 
8830
  # calc speed
-
 
8831
  h = Hash.new(0)
-
 
8832
  @hstats.each do |v, t, i, c, d|
-
 
8833
    h[[t, i, c]] = v
-
 
8834
  end
-
 
8835
  # output
-
 
8836
  @h = {}
-
 
8837
  @t = Hash.new(0) # rate per cpu
-
 
8838
  @w = Hash.new(0) # irqs per irqN
-
 
8839
  @s = @stats.map do |v, t, i, c, d|
-
 
8840
    rate = (v - h[[t, i, c]]) / @dt
-
 
8841
    @t[c] += rate if t == 'i'
-
 
8842
    @w[[t, i]] += (v - h[[t, i, c]])
-
 
8843
    @h[[t, i, c]] = rate
-
 
8844
    [rate, v, t, i, c, d]
-
 
8845
  end
-
 
8846
end
-
 
8847
 
-
 
8848
def calc_cpu
-
 
8849
  @cBusy  = Hash.new(0)
-
 
8850
  @cHIrq  = Hash.new(0)
-
 
8851
  @cSIrq  = Hash.new(0)
-
 
8852
  # user, nice, system, [3] idle, [4] iowait, irq, softirq, etc.
-
 
8853
  @cstat.each do |c, d|
-
 
8854
    d = d.zip(@hcstat[c]).map {|a, b| a - b}
-
 
8855
    c = c.upcase
-
 
8856
    sum = d.reduce(:+)
-
 
8857
    @cBusy[c] = 100 - (d[3] + d[4]).to_f / sum * 100
-
 
8858
    @cHIrq[c] = (d[5]).to_f / sum * 100
-
 
8859
    @cSIrq[c] = (d[6]).to_f / sum * 100
-
 
8860
  end
-
 
8861
end
-
 
8862
 
-
 
8863
def show_top
-
 
8864
  @s.sort!.reverse!
-
 
8865
  @s.reverse! if @reverse
-
 
8866
  rej = nil
-
 
8867
  rej = 's' if @imode == :irq
-
 
8868
  rej = 'i' if @imode == :soft
-
 
8869
  @s.each do |s, v, t, i, c, d|
-
 
8870
    next if t == rej
-
 
8871
    if s > 0
-
 
8872
      print "%9.1f  %s  %s  <%s>  %s" % [s, c.downcase, t, i, d]
-
 
8873
      print_ethstat(d) if @pps
-
 
8874
      puts
-
 
8875
    end
-
 
8876
  end
-
 
8877
end
-
 
8878
 
-
 
8879
@ifilter = {}
-
 
8880
def show_interrupts
-
 
8881
  maxlen = 7
-
 
8882
  @irqs.reverse! if @reverse
-
 
8883
  print "%s %*s  " % [" ", maxlen, " "]
-
 
8884
  @icpus.each { |c| print " %6s" % c }
-
 
8885
  puts
-
 
8886
 
-
 
8887
  # load
-
 
8888
  print "%*s: " % [maxlen + 2, "cpuUtil"]
-
 
8889
  @icpus.each { |c| print " %6.1f" % @cBusy[c] }
-
 
8890
  puts "   total CPU utilization %"
-
 
8891
  #
-
 
8892
  print "%*s: " % [maxlen + 2, "%irq"]
-
 
8893
  @icpus.each { |c| print " %6.1f" % @cHIrq[c] }
-
 
8894
  puts "   hardware IRQ CPU util%"
-
 
8895
  print "%*s: " % [maxlen + 2, "%sirq"]
-
 
8896
  @icpus.each { |c| print " %6.1f" % @cSIrq[c] }
-
 
8897
  puts "   software IRQ CPU util%"
-
 
8898
 
-
 
8899
  # total
-
 
8900
  print "%*s: " % [maxlen + 2, "irqTotal"]
-
 
8901
  @icpus.each { |c| print " %6d" % @t[c] }
-
 
8902
  puts "   total hardware IRQs"
-
 
8903
 
-
 
8904
  rej = nil
-
 
8905
  rej = 's' if @imode == :irq
-
 
8906
  rej = 'i' if @imode == :soft
-
 
8907
  @irqs.each do |t, i, desc|
-
 
8908
    next if t == rej
-
 
8909
 
-
 
8910
    # include incrementally and all eth
-
 
8911
    unless @ifilter[[t, i]] || @showall
-
 
8912
      next unless @w[[t, i]] > 0 || desc =~ /eth/
-
 
8913
      @ifilter[[t, i]] = true
-
 
8914
    end
-
 
8915
 
-
 
8916
    print "%s %*s:  " % [t.to_s, maxlen, i.slice(0, maxlen)]
-
 
8917
    rps = get_rps(desc)
-
 
8918
    @icpus.each do |c|
-
 
8919
      cpu = c[/\d+/].to_i
-
 
8920
      aff = @aff[i.to_i]
-
 
8921
      off = ((aff & 1 << cpu) ==0)? true : false if aff
-
 
8922
      fla = calc_rps(cpu)
-
 
8923
      begin
-
 
8924
	v = @h[[t, i, c]]
-
 
8925
	if v > 0 || !off
-
 
8926
	  print "%6d%c" % [v, fla]
-
 
8927
	elsif aff
-
 
8928
	  print "%6s%c" % [".", fla]
-
 
8929
	end
-
 
8930
      rescue
-
 
8931
      end
-
 
8932
    end
-
 
8933
    print desc
-
 
8934
    print_ethstat(desc) if @pps
-
 
8935
    puts
-
 
8936
  end
-
 
8937
end
-
 
8938
 
-
 
8939
def select_output
-
 
8940
  if @omode == :top
-
 
8941
    show_top
-
 
8942
  else
-
 
8943
    show_interrupts
-
 
8944
  end
-
 
8945
end
-
 
8946
 
-
 
8947
def curses_choplines(text)
-
 
8948
  cols = Curses.cols - 1
-
 
8949
  rows = Curses.lines - 2
-
 
8950
  lines = text.split("\n").map {|e| e.slice(0, cols)}.slice(0, rows)
-
 
8951
  text = lines.join("\n")
-
 
8952
  text << "\n" * (rows - lines.size) if lines.size < rows
-
 
8953
  text
-
 
8954
end
-
 
8955
 
-
 
8956
def show_help
-
 
8957
  puts "irqtop help:"
-
 
8958
  puts
-
 
8959
  puts "  In table view, cells marked with '.' mean this hw irq is"
-
 
8960
  puts "     disabled via /proc/irq/<irq>/smp_affinity"
-
 
8961
  puts "  Interactive keys:"
-
 
8962
  puts "    i     Toggle (hardware) irqs view"
-
 
8963
  puts "    s     Toggle software irqs (softirqs) view"
-
 
8964
  puts "    e     Show eth stat per queue"
-
 
8965
  puts "    R     Show rps/xps affinity"
-
 
8966
  puts "    t     Flat top display mode"
-
 
8967
  puts "    x     Table display mode"
-
 
8968
  puts "    r     Reverse rows order"
-
 
8969
  puts "    c     Toggle colors (for eth)"
-
 
8970
  puts "    a     Show lines with zero rate (all)"
-
 
8971
  puts "    A     Clear lines with zero rates"
-
 
8972
  puts "    .     Pause screen updating"
-
 
8973
  puts "    h,?   This help screen"
-
 
8974
  puts "    q     Quit."
-
 
8975
  puts "  Any other key will update display."
-
 
8976
  puts
-
 
8977
  puts "Press any key to continue."
-
 
8978
end
-
 
8979
 
-
 
8980
hostname = `hostname`.strip
-
 
8981
#
-
 
8982
grab_stat
-
 
8983
sleep 0.5
-
 
8984
 
-
 
8985
COLOR_GREEN  = "\033[0;32m"
-
 
8986
COLOR_YELLOW = "\033[0;33m"
-
 
8987
COLOR_CYAN   = "\033[0;36m"
-
 
8988
COLOR_RED    = "\033[0;31m"
-
 
8989
COLOR_OFF    = "\033[m"
-
 
8990
def tty_printline(t)
-
 
8991
  latr = nil # line color
-
 
8992
  if t =~ /-rx-/
-
 
8993
    latr = COLOR_GREEN
-
 
8994
  elsif t =~ /-tx-/
-
 
8995
    latr = COLOR_YELLOW
-
 
8996
  elsif t =~ /\beth/
-
 
8997
    latr = COLOR_CYAN
-
 
8998
  end
-
 
8999
  print latr if latr
-
 
9000
 
-
 
9001
  if t =~ /cpuUtil:|irq:|sirq:/
-
 
9002
    # colorize percentage values
-
 
9003
    t.scan(/\s+\S+/) do |e|
-
 
9004
      eatr = nil
-
 
9005
      if e =~ /^\s*[\d.]+$/
-
 
9006
        if e.to_i >= 90
-
 
9007
          eatr = COLOR_RED
-
 
9008
        elsif e.to_i <= 10
-
 
9009
          eatr = COLOR_GREEN
-
 
9010
        else
-
 
9011
          eatr = COLOR_YELLOW
-
 
9012
        end
-
 
9013
      end
-
 
9014
      print eatr if eatr
-
 
9015
      print e
-
 
9016
      print (latr)? latr : COLOR_OFF if eatr
-
 
9017
    end
-
 
9018
  elsif latr && t =~ / \[[^\]]+\]$/
-
 
9019
    # colorize eth stats
-
 
9020
    print $`
-
 
9021
    print COLOR_OFF if latr
-
 
9022
    $&.scan(/(.*?)(\w+)(:)(\d+)/) do |e|
-
 
9023
      eatr = nil
-
 
9024
      case e[1]
-
 
9025
      when 'rx'
-
 
9026
	eatr = COLOR_GREEN
-
 
9027
      when 'tx'
-
 
9028
	eatr = COLOR_YELLOW
-
 
9029
      else
-
 
9030
	eatr = COLOR_RED
-
 
9031
      end
-
 
9032
      eatr = nil if e[3].to_i == 0
-
 
9033
 
-
 
9034
      print e[0]
-
 
9035
      print eatr if eatr
-
 
9036
      print e[1..-1].join
-
 
9037
      print (latr)? latr : COLOR_OFF if eatr
-
 
9038
    end
-
 
9039
    print $'
-
 
9040
  else
-
 
9041
    print t
-
 
9042
  end
-
 
9043
 
-
 
9044
  print COLOR_OFF if latr
-
 
9045
  puts
-
 
9046
end
-
 
9047
def tty_output
-
 
9048
  if @color
-
 
9049
    $stdout = StringIO.new
-
 
9050
    yield
-
 
9051
    $stdout.rewind
-
 
9052
    txt = $stdout.read
-
 
9053
    $stdout = STDOUT
-
 
9054
 
-
 
9055
    txt.split("\n", -1).each do |li|
-
 
9056
      tty_printline(li)
-
 
9057
    end
-
 
9058
  else
-
 
9059
    yield
-
 
9060
  end
-
 
9061
end
-
 
9062
 
-
 
9063
if @batch
-
 
9064
  @color = @color && $stdout.tty?
-
 
9065
  loop do
-
 
9066
    grab_stat
-
 
9067
    calc_speed
-
 
9068
    calc_cpu
-
 
9069
    puts "#{hostname} - irqtop - #{Time.now}"
-
 
9070
    tty_output {
-
 
9071
      select_output
-
 
9072
    }
-
 
9073
    $stdout.flush
-
 
9074
    break if @count && (@count -= 1) == 0
-
 
9075
    sleep @delay
-
 
9076
  end
-
 
9077
  exit 0
-
 
9078
end
-
 
9079
 
-
 
9080
Curses.init_screen
-
 
9081
Curses.start_color
-
 
9082
Curses.cbreak
-
 
9083
Curses.noecho
-
 
9084
Curses.nonl
-
 
9085
Curses.init_pair(1, Curses::COLOR_GREEN,  Curses::COLOR_BLACK);
-
 
9086
Curses.init_pair(2, Curses::COLOR_YELLOW, Curses::COLOR_BLACK);
-
 
9087
Curses.init_pair(3, Curses::COLOR_CYAN,   Curses::COLOR_BLACK);
-
 
9088
Curses.init_pair(4, Curses::COLOR_RED,    Curses::COLOR_BLACK);
-
 
9089
$stdscr = Curses.stdscr
-
 
9090
$stdscr.keypad(true)
-
 
9091
 
-
 
9092
def curses_printline(t)
-
 
9093
  latr = nil # line color
-
 
9094
  if t =~ /-rx-/
-
 
9095
    latr = Curses.color_pair(1)
-
 
9096
  elsif t =~ /-tx-/
-
 
9097
    latr = Curses.color_pair(2)
-
 
9098
  elsif t =~ /\beth/
-
 
9099
    latr = Curses.color_pair(3)
-
 
9100
  end
-
 
9101
  $stdscr.attron(latr)  if latr
-
 
9102
 
-
 
9103
  if t =~ /cpuUtil:|irq:|sirq:/
-
 
9104
    # colorize percentage values
-
 
9105
    t.scan(/\s+\S+/) do |e|
-
 
9106
      eatr = nil
-
 
9107
      if e =~ /^\s*[\d.]+$/
-
 
9108
	if e.to_i >= 90
-
 
9109
	  eatr = Curses.color_pair(4)
-
 
9110
	elsif e.to_i <= 10
-
 
9111
	  eatr = Curses.color_pair(1)
-
 
9112
	else
-
 
9113
	  eatr = Curses.color_pair(2)
-
 
9114
	end
-
 
9115
      end
-
 
9116
      $stdscr.attron(eatr)  if eatr
-
 
9117
      $stdscr.addstr("#{e}")
-
 
9118
      $stdscr.attroff(eatr) if eatr
-
 
9119
    end
-
 
9120
  elsif latr && t =~ / \[[^\]]+\]$/
-
 
9121
    # colorize eth stats
-
 
9122
    $stdscr.addstr($`)
-
 
9123
    $stdscr.attroff(latr) if latr
-
 
9124
    $&.scan(/(.*?)(\w+)(:)(\d+)/) do |e|
-
 
9125
      eatr = nil
-
 
9126
      case e[1]
-
 
9127
      when 'rx'
-
 
9128
	eatr = Curses.color_pair(1)
-
 
9129
      when 'tx'
-
 
9130
	eatr = Curses.color_pair(2)
-
 
9131
      else
-
 
9132
	eatr = Curses.color_pair(4)
-
 
9133
      end
-
 
9134
      eatr = nil if e[3].to_i == 0
-
 
9135
 
-
 
9136
      $stdscr.addstr(e[0])
-
 
9137
      $stdscr.attron(eatr)  if eatr
-
 
9138
      $stdscr.addstr(e[1..-1].join)
-
 
9139
      $stdscr.attroff(eatr) if eatr
-
 
9140
    end
-
 
9141
    $stdscr.addstr($' + "\n")
-
 
9142
  else
-
 
9143
    $stdscr.addstr("#{t}\n")
-
 
9144
  end
-
 
9145
 
-
 
9146
  $stdscr.attroff(latr) if latr
-
 
9147
end
-
 
9148
 
-
 
9149
def curses_output
-
 
9150
  $stdout = StringIO.new
-
 
9151
  yield
-
 
9152
  $stdout.rewind
-
 
9153
  text = $stdout.read
-
 
9154
  $stdout = STDOUT
-
 
9155
  txt = curses_choplines(text)
-
 
9156
  if @color
-
 
9157
    txt.split("\n", -1).each_with_index do |li, i|
-
 
9158
      $stdscr.setpos(i, 0)
-
 
9159
      curses_printline(li)
-
 
9160
    end
-
 
9161
  else
-
 
9162
    $stdscr.setpos(0, 0)
-
 
9163
    $stdscr.addstr(txt)
-
 
9164
  end
-
 
9165
  $stdscr.setpos(1, 0)
-
 
9166
  Curses.refresh
-
 
9167
end
-
 
9168
 
-
 
9169
def curses_enter(text, echo = true)
-
 
9170
  $stdscr.setpos(1, 0)
-
 
9171
  $stdscr.addstr(text + "\n")
-
 
9172
  $stdscr.setpos(1, 0)
-
 
9173
  Curses.attron(Curses::A_BOLD)
-
 
9174
  $stdscr.addstr(text)
-
 
9175
  Curses.attroff(Curses::A_BOLD)
-
 
9176
  Curses.refresh
-
 
9177
  Curses.echo if echo
-
 
9178
  Curses.timeout = -1
-
 
9179
  line = Curses.getstr
-
 
9180
  Curses.noecho
-
 
9181
  line
-
 
9182
end
-
 
9183
 
-
 
9184
loop do
-
 
9185
  grab_stat
-
 
9186
  calc_speed
-
 
9187
  calc_cpu
-
 
9188
 
-
 
9189
  curses_output {
-
 
9190
   puts "#{hostname} - irqtop - #{Time.now}"
-
 
9191
   select_output
-
 
9192
  }
-
 
9193
 
-
 
9194
  Curses.timeout = @delay * 1000
-
 
9195
  ch = Curses.getch.chr rescue nil
-
 
9196
  case ch
-
 
9197
  when "\f"
-
 
9198
    Curses.clear
-
 
9199
  when "q", "Z", "z"
-
 
9200
    break
-
 
9201
  when 'i'
-
 
9202
    @imode = (@imode == :both)? :soft : :both
-
 
9203
  when 's'
-
 
9204
    @imode = (@imode == :both)? :irq : :both
-
 
9205
  when 't'
-
 
9206
    @omode = (@omode == :top)? :table : :top
-
 
9207
  when 'x'
-
 
9208
    @omode = (@omode == :table)? :top : :table
-
 
9209
  when 'e', 'p'
-
 
9210
    @pps = !@pps
-
 
9211
  when 'r'
-
 
9212
    @reverse = !@reverse
-
 
9213
  when 'c'
-
 
9214
    @color = !@color
-
 
9215
  when 'A'
-
 
9216
    @ifilter = {}
-
 
9217
  when 'a'
-
 
9218
    @ifilter = {}
-
 
9219
    @showall = !@showall
-
 
9220
  when 'R'
-
 
9221
    @showrps = !@showrps
-
 
9222
  when '.'
-
 
9223
    curses_enter("Pause, press enter to to continue: ", false)
-
 
9224
  when 'd'
-
 
9225
    d = curses_enter("Enter display interval: ")
-
 
9226
    @delay = d.to_f if d.to_f > 0
-
 
9227
  when 'h', '?'
-
 
9228
    curses_output { show_help }
-
 
9229
    Curses.timeout = -1
-
 
9230
    ch = Curses.getch.chr rescue nil
-
 
9231
    break if ch == 'q'
-
 
9232
  end
-
 
9233
end
-
 
9234
 
-
 
9235
ipt-netflow-2.2/snmp_NETFLOW.c0000644000000000000000000004172613213006644014653 0ustar  rootroot/*
-
 
9236
 * dlmod plugin for net-snmp for monitoring
-
 
9237
 * ipt_NETFLOW module via IPT-NETFLOW-MIB.
-
 
9238
 *
-
 
9239
 * (c) 2014 <abc@telekom.ru>
-
 
9240
 *
-
 
9241
 * This program is free software; you can redistribute it and/or modify
-
 
9242
 * it under the terms of the GNU General Public License version 2 as
-
 
9243
 * published by the Free Software Foundation.
-
 
9244
 */
-
 
9245
 
-
 
9246
#include <sys/types.h>
-
 
9247
#include <sys/stat.h>
-
 
9248
#include <fcntl.h>
-
 
9249
#include <errno.h>
-
 
9250
 
-
 
9251
#include <net-snmp/net-snmp-config.h>
-
 
9252
#include <net-snmp/net-snmp-includes.h>
-
 
9253
#include <net-snmp/agent/net-snmp-agent-includes.h>
-
 
9254
 
-
 
9255
#define iptNetflowMIB_oid 1, 3, 6, 1, 4, 1, 37476, 9000, 10, 1 /* .1.3.6.1.4.1.37476.9000.10.1 */
-
 
9256
 
-
 
9257
/* iptNetflowObjects */
-
 
9258
static oid iptNetflowModule_oid[]    = { iptNetflowMIB_oid, 1, 1 };
-
 
9259
static oid iptNetflowSysctl_oid[]    = { iptNetflowMIB_oid, 1, 2 };
-
 
9260
/* iptNetflowStatistics */
-
 
9261
static oid iptNetflowTotals_oid[]    = { iptNetflowMIB_oid, 2, 1 };
-
 
9262
static oid iptNetflowCpuTable_oid[]  = { iptNetflowMIB_oid, 2, 2 };
-
 
9263
static oid iptNetflowSockTable_oid[] = { iptNetflowMIB_oid, 2, 3 };
-
 
9264
 
-
 
9265
struct snmp_vars {
-
 
9266
	int obj;
-
 
9267
	int type;
-
 
9268
	char *name;
-
 
9269
 
-
 
9270
	time_t ts; /* when value last read */
-
 
9271
	long long val64;
-
 
9272
};
-
 
9273
 
-
 
9274
struct snmp_vars modinfos[] = {
-
 
9275
	{1, ASN_OCTET_STR, "name"},
-
 
9276
	{2, ASN_OCTET_STR, "version"},
-
 
9277
	{3, ASN_OCTET_STR, "srcversion"},
-
 
9278
	{4, ASN_OCTET_STR, "loadTime"}, /* DateAndTime */
-
 
9279
	{5, ASN_INTEGER,   "refcnt"},
-
 
9280
	{ 0 }
-
 
9281
};
-
 
9282
#define MODINFO_NAME "ipt_NETFLOW"
-
 
9283
#define MODINFO_NAME_ID 1
-
 
9284
#define MODINFO_DATE_ID 4
-
 
9285
 
-
 
9286
struct snmp_vars sysctls[] = {
-
 
9287
	{1,  ASN_INTEGER,   "protocol"},
-
 
9288
	{2,  ASN_INTEGER,   "hashsize"},
-
 
9289
	{3,  ASN_INTEGER,   "maxflows"},
-
 
9290
	{4,  ASN_INTEGER,   "active_timeout"},
-
 
9291
	{5,  ASN_INTEGER,   "inactive_timeout"},
-
 
9292
	{6,  ASN_INTEGER,   "sndbuf"},
-
 
9293
	{7,  ASN_OCTET_STR, "destination"},
-
 
9294
	{8,  ASN_OCTET_STR, "aggregation"},
-
 
9295
	{9,  ASN_OCTET_STR, "sampler"},
-
 
9296
	{10, ASN_INTEGER,   "natevents"},
-
 
9297
	{11, ASN_INTEGER,   "promisc"},
-
 
9298
	{12, ASN_OCTET_STR, "snmp-rules"},
-
 
9299
	{13, ASN_INTEGER,   "scan-min"},
-
 
9300
	{ 0 }
-
 
9301
};
-
 
9302
 
-
 
9303
struct snmp_vars totals[] = {
-
 
9304
	{1,  ASN_COUNTER64, "inBitRate"},
-
 
9305
	{2,  ASN_GAUGE,     "inPacketRate"},
-
 
9306
	{3,  ASN_COUNTER64, "inFlows"},
-
 
9307
	{4,  ASN_COUNTER64, "inPackets"},
-
 
9308
	{5,  ASN_COUNTER64, "inBytes"},
-
 
9309
	{6,  ASN_GAUGE,     "hashMetric"},
-
 
9310
	{7,  ASN_GAUGE,     "hashMemory"},
-
 
9311
	{8,  ASN_GAUGE,     "hashFlows"},
-
 
9312
	{9,  ASN_GAUGE,     "hashPackets"},
-
 
9313
	{10, ASN_COUNTER64, "hashBytes"},
-
 
9314
	{11, ASN_COUNTER64, "dropPackets"},
-
 
9315
	{12, ASN_COUNTER64, "dropBytes"},
-
 
9316
	{13, ASN_GAUGE,     "outByteRate"},
-
 
9317
	{14, ASN_COUNTER64, "outFlows"},
-
 
9318
	{15, ASN_COUNTER64, "outPackets"},
-
 
9319
	{16, ASN_COUNTER64, "outBytes"},
-
 
9320
	{17, ASN_COUNTER64, "lostFlows"},
-
 
9321
	{18, ASN_COUNTER64, "lostPackets"},
-
 
9322
	{19, ASN_COUNTER64, "lostBytes"},
-
 
9323
	{20, ASN_COUNTER,   "errTotal"},
-
 
9324
	{21, ASN_COUNTER,   "sndbufPeak"},
-
 
9325
	{ 0 }
-
 
9326
};
-
 
9327
#define TOTALS_METRIC_ID 6
-
 
9328
 
-
 
9329
static netsnmp_table_data_set *cpu_data_set;
-
 
9330
static netsnmp_cache *stat_cache = NULL;
-
 
9331
 
-
 
9332
struct snmp_vars cputable[] = {
-
 
9333
	{1,  ASN_INTEGER,   "cpuIndex"},
-
 
9334
	{2,  ASN_GAUGE,     "cpuInPacketRate"},
-
 
9335
	{3,  ASN_COUNTER64, "cpuInFlows"},
-
 
9336
	{4,  ASN_COUNTER64, "cpuInPackets"},
-
 
9337
	{5,  ASN_COUNTER64, "cpuInBytes"},
-
 
9338
	{6,  ASN_GAUGE,     "cpuHashMetric"},
-
 
9339
	{7,  ASN_COUNTER64, "cpuDropPackets"},
-
 
9340
	{8,  ASN_COUNTER64, "cpuDropBytes"},
-
 
9341
	{9,  ASN_COUNTER,   "cpuErrTrunc"},
-
 
9342
	{10, ASN_COUNTER,   "cpuErrFrag"},
-
 
9343
	{11, ASN_COUNTER,   "cpuErrAlloc"},
-
 
9344
	{12, ASN_COUNTER,   "cpuErrMaxflows"},
-
 
9345
	{ 0 }
-
 
9346
};
-
 
9347
 
-
 
9348
static netsnmp_table_data_set *sock_data_set;
-
 
9349
struct snmp_vars socktable[] = {
-
 
9350
	{1,  ASN_INTEGER,   "sockIndex"},
-
 
9351
	{2,  ASN_OCTET_STR, "sockDestination"},
-
 
9352
	{3,  ASN_INTEGER,   "sockActive"},
-
 
9353
	{4,  ASN_COUNTER,   "sockErrConnect"},
-
 
9354
	{5,  ASN_COUNTER,   "sockErrFull"},
-
 
9355
	{6,  ASN_COUNTER,   "sockErrCberr"},
-
 
9356
	{7,  ASN_COUNTER,   "sockErrOther"},
-
 
9357
	{8,  ASN_GAUGE,     "sockSndbuf"},
-
 
9358
	{9,  ASN_GAUGE,     "sockSndbufFill"},
-
 
9359
	{10, ASN_GAUGE,     "sockSndbufPeak"},
-
 
9360
	{ 0 }
-
 
9361
};
-
 
9362
 
-
 
9363
static time_t totals_ts; /* when statistics last read from kernel */
-
 
9364
 
-
 
9365
static int var_max(struct snmp_vars *head)
-
 
9366
{
-
 
9367
	struct snmp_vars *sys;
-
 
9368
	int max = 0;
-
 
9369
 
-
 
9370
	for (sys = head; sys->obj; sys++)
-
 
9371
		if (max < sys->obj)
-
 
9372
			max = sys->obj;
-
 
9373
	return max;
-
 
9374
}
-
 
9375
 
-
 
9376
static struct snmp_vars *find_varinfo(struct snmp_vars *head, const int obj)
-
 
9377
{
-
 
9378
	struct snmp_vars *sys;
-
 
9379
 
-
 
9380
	for (sys = head; sys->obj; sys++) {
-
 
9381
		if (sys->obj == obj)
-
 
9382
			return sys;
-
 
9383
	}
-
 
9384
	return NULL;
-
 
9385
}
-
 
9386
 
-
 
9387
static struct snmp_vars *find_varinfo_str(struct snmp_vars *head, const char *name)
-
 
9388
{
-
 
9389
	struct snmp_vars *sys;
-
 
9390
 
-
 
9391
	for (sys = head; sys->obj; sys++) {
-
 
9392
		if (!strcmp(sys->name, name))
-
 
9393
			return sys;
-
 
9394
	}
-
 
9395
	return NULL;
-
 
9396
}
-
 
9397
 
-
 
9398
static void modinfo_fname(char *name, char *fname, size_t flen)
-
 
9399
{
-
 
9400
	snprintf(fname, flen, "/sys/module/" MODINFO_NAME "/%s", name);
-
 
9401
}
-
 
9402
 
-
 
9403
static void sysctl_fname(char *name, char *fname, size_t flen)
-
 
9404
{
-
 
9405
	snprintf(fname, flen, "/proc/sys/net/netflow/%s", name);
-
 
9406
}
-
 
9407
 
-
 
9408
static int sysctl_access_ok(char *name)
-
 
9409
{
-
 
9410
	char fname[64];
-
 
9411
 
-
 
9412
	sysctl_fname(name, fname, sizeof(fname));
-
 
9413
	if (access(fname, W_OK) < 0)
-
 
9414
		return 0;
-
 
9415
	return 1;
-
 
9416
}
-
 
9417
 
-
 
9418
static char *file_read_string(char *name, char *buf, size_t size)
-
 
9419
{
-
 
9420
	int fd = open(name, O_RDONLY);
-
 
9421
	if (fd < 0)
-
 
9422
		return NULL;
-
 
9423
	int n = read(fd, buf, size - 1);
-
 
9424
	if (n < 0) {
-
 
9425
		close(fd);
-
 
9426
		return NULL;
-
 
9427
	}
-
 
9428
	buf[n] = '\0';
-
 
9429
	close(fd);
-
 
9430
	return buf;
-
 
9431
}
-
 
9432
 
-
 
9433
static char *modinfo_read_string(char *name, char *buf, size_t size)
-
 
9434
{
-
 
9435
	char fname[64];
-
 
9436
 
-
 
9437
	modinfo_fname(name, fname, sizeof(fname));
-
 
9438
	return file_read_string(fname, buf, size);
-
 
9439
}
-
 
9440
 
-
 
9441
static char *sysctl_read_string(char *name, char *buf, size_t size)
-
 
9442
{
-
 
9443
	char fname[64];
-
 
9444
 
-
 
9445
	sysctl_fname(name, fname, sizeof(fname));
-
 
9446
	return file_read_string(fname, buf, size);
-
 
9447
}
-
 
9448
 
-
 
9449
static int sysctl_write_string(char *name, char *buf, size_t size)
-
 
9450
{
-
 
9451
	char fname[64];
-
 
9452
	int fd;
-
 
9453
	int n;
-
 
9454
 
-
 
9455
	sysctl_fname(name, fname, sizeof(fname));
-
 
9456
	fd = open(fname, O_RDWR, 0644);
-
 
9457
	if (fd < 0)
-
 
9458
		return fd;
-
 
9459
	n = write(fd, buf, size);
-
 
9460
	close(fd);
-
 
9461
	return n;
-
 
9462
}
-
 
9463
 
-
 
9464
static int sysctl_read(netsnmp_request_info *request, int obj)
-
 
9465
{
-
 
9466
	struct snmp_vars *sys = find_varinfo(sysctls, obj);
-
 
9467
	char buf[225];
-
 
9468
	char *p;
-
 
9469
	long value;
-
 
9470
 
-
 
9471
	if (!sys)
-
 
9472
		goto nosuchobject;
-
 
9473
 
-
 
9474
	p = sysctl_read_string(sys->name, buf, sizeof(buf));
-
 
9475
	if (!p)
-
 
9476
		goto nosuchobject;
-
 
9477
 
-
 
9478
	switch (sys->type) {
-
 
9479
	case ASN_INTEGER:
-
 
9480
		value = atoi(p);
-
 
9481
		snmp_set_var_typed_value(request->requestvb,
-
 
9482
		    sys->type,
-
 
9483
		    (u_char *)&value, sizeof(value));
-
 
9484
		return SNMP_ERR_NOERROR;
-
 
9485
	case ASN_OCTET_STR:
-
 
9486
		snmp_set_var_typed_value(request->requestvb,
-
 
9487
		    sys->type,
-
 
9488
		    (u_char *)p, strcspn(p, "\n"));
-
 
9489
		return SNMP_ERR_NOERROR;
-
 
9490
	}
-
 
9491
nosuchobject:
-
 
9492
	netsnmp_request_set_error(request, SNMP_NOSUCHOBJECT);
-
 
9493
	return SNMP_ERR_NOERROR;
-
 
9494
}
-
 
9495
 
-
 
9496
static int sysctl_write(netsnmp_request_info *request, int obj)
-
 
9497
{
-
 
9498
	struct snmp_vars *sys = find_varinfo(sysctls, obj);
-
 
9499
	char buf[225];
-
 
9500
	int len;
-
 
9501
 
-
 
9502
	if (!sys) {
-
 
9503
		netsnmp_request_set_error(request, SNMP_NOSUCHOBJECT);
-
 
9504
		return SNMP_ERR_NOERROR;
-
 
9505
	}
-
 
9506
	switch (sys->type) {
-
 
9507
	case ASN_INTEGER:
-
 
9508
		snprintf(buf, sizeof(buf), "%ld\n", *(request->requestvb->val.integer));
-
 
9509
		break;
-
 
9510
	case ASN_UNSIGNED:
-
 
9511
		snprintf(buf, sizeof(buf), "%lu\n", *(request->requestvb->val.integer));
-
 
9512
		break;
-
 
9513
	case ASN_OCTET_STR:
-
 
9514
		snprintf(buf, sizeof(buf), "%s\n", request->requestvb->val.string);
-
 
9515
		break;
-
 
9516
	default:
-
 
9517
		netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE);
-
 
9518
		return SNMP_ERR_NOERROR;
-
 
9519
	}
-
 
9520
	len = strlen(buf);
-
 
9521
	if (sysctl_write_string(sys->name, buf, len) < len)
-
 
9522
		netsnmp_request_set_error(request, SNMP_ERR_BADVALUE);
-
 
9523
	return SNMP_ERR_NOERROR;
-
 
9524
}
-
 
9525
 
-
 
9526
static int iptNetflowModule_handler(
-
 
9527
    netsnmp_mib_handler          *handler,
-
 
9528
    netsnmp_handler_registration *reginfo,
-
 
9529
    netsnmp_agent_request_info   *reqinfo,
-
 
9530
    netsnmp_request_info         *request)
-
 
9531
{
-
 
9532
	struct snmp_vars *sys;
-
 
9533
	oid obj;
-
 
9534
	char buf[225];
-
 
9535
	char *p = NULL;
-
 
9536
	long value;
-
 
9537
 
-
 
9538
	obj = request->requestvb->name[request->requestvb->name_length - 2];
-
 
9539
	sys = find_varinfo(modinfos, obj);
-
 
9540
	if (!sys) {
-
 
9541
		netsnmp_request_set_error(request, SNMP_ERR_NOSUCHNAME);
-
 
9542
		return SNMP_ERR_NOERROR;
-
 
9543
	}
-
 
9544
	if (reqinfo->mode != MODE_GET) {
-
 
9545
		netsnmp_request_set_error(request, SNMP_ERR_READONLY);
-
 
9546
		return SNMP_ERR_NOERROR;
-
 
9547
	}
-
 
9548
	switch (obj) {
-
 
9549
	case MODINFO_NAME_ID:
-
 
9550
		p = MODINFO_NAME;
-
 
9551
		break;
-
 
9552
	case MODINFO_DATE_ID: {
-
 
9553
		size_t len;
-
 
9554
		struct stat st;
-
 
9555
 
-
 
9556
		modinfo_fname(".", buf, sizeof(buf));
-
 
9557
		if (stat(buf, &st) < 0)
-
 
9558
			break;
-
 
9559
		p = (char *)date_n_time(&st.st_mtime, &len);
-
 
9560
		snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, p, len);
-
 
9561
		return SNMP_ERR_NOERROR;
-
 
9562
	}
-
 
9563
	default:
-
 
9564
		p = modinfo_read_string(sys->name, buf, sizeof(buf));
-
 
9565
	}
-
 
9566
	if (!p) {
-
 
9567
		netsnmp_request_set_error(request, SNMP_ERR_NOSUCHNAME);
-
 
9568
		return SNMP_ERR_NOERROR;
-
 
9569
	}
-
 
9570
 
-
 
9571
	switch (sys->type) {
-
 
9572
	case ASN_INTEGER:
-
 
9573
		value = atoi(p);
-
 
9574
		snmp_set_var_typed_value(request->requestvb,
-
 
9575
		    sys->type,
-
 
9576
		    (u_char *)&value, sizeof(value));
-
 
9577
		break;
-
 
9578
	case ASN_OCTET_STR:
-
 
9579
		snmp_set_var_typed_value(request->requestvb,
-
 
9580
		    sys->type,
-
 
9581
		    (u_char *)p, strcspn(p, "\n"));
-
 
9582
		break;
-
 
9583
	default:
-
 
9584
		netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE);
-
 
9585
 
-
 
9586
	}
-
 
9587
	return SNMP_ERR_NOERROR;
-
 
9588
}
-
 
9589
 
-
 
9590
static int iptNetflowSysctl_handler(
-
 
9591
    netsnmp_mib_handler          *handler,
-
 
9592
    netsnmp_handler_registration *reginfo,
-
 
9593
    netsnmp_agent_request_info   *reqinfo,
-
 
9594
    netsnmp_request_info         *request)
-
 
9595
{
-
 
9596
	struct snmp_vars *sys;
-
 
9597
	oid obj;
-
 
9598
 
-
 
9599
	obj = request->requestvb->name[request->requestvb->name_length - 2];
-
 
9600
	switch (reqinfo->mode) {
-
 
9601
	case MODE_GET:
-
 
9602
		return sysctl_read(request, obj);
-
 
9603
	case MODE_SET_RESERVE1:
-
 
9604
		sys = find_varinfo(sysctls, obj);
-
 
9605
		if (!sys || !sysctl_access_ok(sys->name))
-
 
9606
			netsnmp_request_set_error(request, SNMP_ERR_NOSUCHNAME);
-
 
9607
		if (sys && request->requestvb->type != sys->type)
-
 
9608
			netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE);
-
 
9609
		break;
-
 
9610
	case MODE_SET_RESERVE2:
-
 
9611
	case MODE_SET_FREE:
-
 
9612
	case MODE_SET_UNDO:
-
 
9613
	case MODE_SET_COMMIT:
-
 
9614
		return SNMP_ERR_NOERROR;
-
 
9615
	case MODE_SET_ACTION:
-
 
9616
		return sysctl_write(request, obj);
-
 
9617
	default:
-
 
9618
		return SNMP_ERR_GENERR;
-
 
9619
 
-
 
9620
	}
-
 
9621
	return SNMP_ERR_NOERROR;
-
 
9622
}
-
 
9623
 
-
 
9624
#define TOTAL_INTERVAL 1
-
 
9625
 
-
 
9626
static void clear_data_set(netsnmp_table_data_set *data_set)
-
 
9627
{
-
 
9628
	netsnmp_table_row *row, *nextrow;
-
 
9629
 
-
 
9630
	for (row = netsnmp_table_data_set_get_first_row(data_set); row; row = nextrow) {
-
 
9631
		nextrow = netsnmp_table_data_set_get_next_row(data_set, row);
-
 
9632
		netsnmp_table_dataset_remove_and_delete_row(data_set, row);
-
 
9633
	}
-
 
9634
}
-
 
9635
 
-
 
9636
static void parse_table_row(
-
 
9637
    int			    cpu,
-
 
9638
    char		    *p,
-
 
9639
    struct snmp_vars	    *sys,
-
 
9640
    netsnmp_table_data_set  *data_set)
-
 
9641
{
-
 
9642
	netsnmp_table_row *row;
-
 
9643
 
-
 
9644
	row = netsnmp_create_table_data_row();
-
 
9645
	netsnmp_table_row_add_index(row, ASN_INTEGER, (u_char *)&cpu, sizeof(cpu));
-
 
9646
 
-
 
9647
	if (sys == cputable) {
-
 
9648
		/* add cpuIndex as column too to break SMIv2 */
-
 
9649
		netsnmp_set_row_column(row, 1, sys->type, (char *)&cpu, sizeof(cpu));
-
 
9650
	}
-
 
9651
	for (++sys; p && sys->obj; sys++) {
-
 
9652
		char		 *val;
-
 
9653
		long long	 val64;
-
 
9654
		unsigned int	 uval32;
-
 
9655
		int		 val32;
-
 
9656
		struct counter64 c64;
-
 
9657
 
-
 
9658
		p += strspn(p, " \t");
-
 
9659
		val = p;
-
 
9660
		if ((p = strpbrk(p, " \t")))
-
 
9661
			*p++ = '\0';
-
 
9662
		if (index(val, '.')) {
-
 
9663
			double d = strtod(val, NULL);
-
 
9664
 
-
 
9665
			val64 = (long long)(d * 100);
-
 
9666
		} else
-
 
9667
			val64 = strtoll(val, NULL, 10);
-
 
9668
 
-
 
9669
		switch (sys->type) {
-
 
9670
		case ASN_OCTET_STR:
-
 
9671
			netsnmp_set_row_column(row, sys->obj,
-
 
9672
			    sys->type, (char *)val, strlen(val));
-
 
9673
			break;
-
 
9674
		case ASN_INTEGER:
-
 
9675
		case ASN_GAUGE:
-
 
9676
			val32 = (int)val64;
-
 
9677
			netsnmp_set_row_column(row, sys->obj,
-
 
9678
			    sys->type, (char *)&val32, sizeof(val32));
-
 
9679
			break;
-
 
9680
		case ASN_COUNTER:
-
 
9681
			uval32 = (unsigned int)val64;
-
 
9682
			netsnmp_set_row_column(row, sys->obj,
-
 
9683
			    sys->type, (char *)&uval32, sizeof(uval32));
-
 
9684
			break;
-
 
9685
		case ASN_COUNTER64:
-
 
9686
			c64.low = (uint32_t)val64;
-
 
9687
			c64.high = val64 >> 32;
-
 
9688
			netsnmp_set_row_column(row, sys->obj,
-
 
9689
			    sys->type, (char *)&c64, sizeof(c64));
-
 
9690
			break;
-
 
9691
		default:
-
 
9692
			netsnmp_table_dataset_delete_row(row);
-
 
9693
			continue;
-
 
9694
		}
-
 
9695
 
-
 
9696
	}
-
 
9697
	netsnmp_table_data_add_row(data_set->table, row);
-
 
9698
}
-
 
9699
 
-
 
9700
static void grab_ipt_netflow_snmp(time_t now)
-
 
9701
{
-
 
9702
	static char buf[4096];
-
 
9703
	int fd;
-
 
9704
	int n;
-
 
9705
	char *p = buf;
-
 
9706
 
-
 
9707
	if ((now - totals_ts) < (TOTAL_INTERVAL + 1))
-
 
9708
		return;
-
 
9709
 
-
 
9710
	if ((fd = open("/proc/net/stat/ipt_netflow_snmp", O_RDONLY)) < 0)
-
 
9711
		return;
-
 
9712
 
-
 
9713
	n = read(fd, buf, sizeof(buf) - 1);
-
 
9714
	close(fd);
-
 
9715
	if (n <= 0)
-
 
9716
		return;
-
 
9717
	buf[n] = '\0';
-
 
9718
 
-
 
9719
	DEBUGMSGTL(("netflow", "%s\n", buf));
-
 
9720
	clear_data_set(cpu_data_set);
-
 
9721
	clear_data_set(sock_data_set);
-
 
9722
	while (*p) {
-
 
9723
		struct snmp_vars *sys;
-
 
9724
		char *name = p;
-
 
9725
		char *val;
-
 
9726
 
-
 
9727
		if (!(p = strpbrk(p, " \t")))
-
 
9728
			break;
-
 
9729
		*p++ = '\0';
-
 
9730
		val = p + strspn(p, " \t");
-
 
9731
		p = index(p, '\n');
-
 
9732
		*p++ = '\0';
-
 
9733
 
-
 
9734
		if (!strncmp(name, "cpu", 3)) {
-
 
9735
			parse_table_row(atoi(name + 3), val, cputable, cpu_data_set);
-
 
9736
			continue;
-
 
9737
		} else if (!strncmp(name, "sock", 4)) {
-
 
9738
			parse_table_row(atoi(name + 4), val, socktable, sock_data_set);
-
 
9739
			continue;
-
 
9740
		}
-
 
9741
		if (!(sys = find_varinfo_str(totals, name)))
-
 
9742
		    continue;
-
 
9743
		if (index(val, '.')) {
-
 
9744
			double d = strtod(val, NULL);
-
 
9745
			sys->val64 = (long long)(d * 100);
-
 
9746
		} else
-
 
9747
			sys->val64 = strtoll(val, NULL, 10);
-
 
9748
		sys->ts = now;
-
 
9749
	}
-
 
9750
	totals_ts = now;
-
 
9751
}
-
 
9752
 
-
 
9753
static int iptNetflowTotals_handler(
-
 
9754
    netsnmp_mib_handler          *handler,
-
 
9755
    netsnmp_handler_registration *reginfo,
-
 
9756
    netsnmp_agent_request_info   *reqinfo,
-
 
9757
    netsnmp_request_info         *request)
-
 
9758
{
-
 
9759
	struct snmp_vars *sys;
-
 
9760
	time_t now = time(NULL);
-
 
9761
	oid obj;
-
 
9762
	unsigned int	 uval32;
-
 
9763
	int		 val32;
-
 
9764
	struct counter64 c64;
-
 
9765
 
-
 
9766
	grab_ipt_netflow_snmp(now);
-
 
9767
 
-
 
9768
	obj = request->requestvb->name[request->requestvb->name_length - 2];
-
 
9769
	sys = find_varinfo(totals, obj);
-
 
9770
	if (!sys || ((now - sys->ts) > (TOTAL_INTERVAL * 2 + 3))) {
-
 
9771
		netsnmp_request_set_error(request, SNMP_ERR_NOSUCHNAME);
-
 
9772
		return SNMP_ERR_NOERROR;
-
 
9773
	}
-
 
9774
	if (reqinfo->mode != MODE_GET) {
-
 
9775
		netsnmp_request_set_error(request, SNMP_ERR_READONLY);
-
 
9776
		return SNMP_ERR_NOERROR;
-
 
9777
	}
-
 
9778
	switch (sys->type) {
-
 
9779
	case ASN_GAUGE:
-
 
9780
		val32 = (int)sys->val64;
-
 
9781
		snmp_set_var_typed_value(request->requestvb,
-
 
9782
		    sys->type, (u_char *)&val32, sizeof(val32));
-
 
9783
		break;
-
 
9784
	case ASN_COUNTER:
-
 
9785
		uval32 = (unsigned int)sys->val64;
-
 
9786
		snmp_set_var_typed_value(request->requestvb,
-
 
9787
		    sys->type, (u_char *)&uval32, sizeof(uval32));
-
 
9788
		break;
-
 
9789
	case ASN_COUNTER64:
-
 
9790
		c64.low = (uint32_t)sys->val64;
-
 
9791
		c64.high = sys->val64 >> 32;
-
 
9792
		snmp_set_var_typed_value(request->requestvb,
-
 
9793
		    ASN_COUNTER64, (u_char *)&c64, sizeof(c64));
-
 
9794
		break;
-
 
9795
	default:
-
 
9796
		return SNMP_ERR_GENERR;
-
 
9797
	}
-
 
9798
	return SNMP_ERR_NOERROR;
-
 
9799
}
-
 
9800
 
-
 
9801
static int stat_cache_load(netsnmp_cache *cache, void *x)
-
 
9802
{
-
 
9803
	grab_ipt_netflow_snmp(time(NULL));
-
 
9804
	return 0;
-
 
9805
}
-
 
9806
 
-
 
9807
static void dummy_cache_free(netsnmp_cache *cache, void *x)
-
 
9808
{
-
 
9809
	/* free_cache callback is not always checked for NULL
-
 
9810
	 * pointer. */
-
 
9811
}
-
 
9812
 
-
 
9813
void init_netflow(void)
-
 
9814
{
-
 
9815
	netsnmp_handler_registration *reg;
-
 
9816
	struct snmp_vars *sys;
-
 
9817
 
-
 
9818
	/* snmpd -f -L -Dnetflow,dlmod */
-
 
9819
	DEBUGMSGTL(("netflow", "init_netflow\n"));
-
 
9820
 
-
 
9821
	netsnmp_register_scalar_group(
-
 
9822
	    netsnmp_create_handler_registration(
-
 
9823
		    "iptNetflowModule",
-
 
9824
		    iptNetflowModule_handler,
-
 
9825
		    iptNetflowModule_oid,
-
 
9826
		    OID_LENGTH(iptNetflowModule_oid),
-
 
9827
		    HANDLER_CAN_RONLY),
-
 
9828
	    1, var_max(modinfos));
-
 
9829
 
-
 
9830
	netsnmp_register_scalar_group(
-
 
9831
	    netsnmp_create_handler_registration(
-
 
9832
		    "iptNetflowSysctl",
-
 
9833
		    iptNetflowSysctl_handler,
-
 
9834
		    iptNetflowSysctl_oid,
-
 
9835
		    OID_LENGTH(iptNetflowSysctl_oid),
-
 
9836
		    HANDLER_CAN_RWRITE),
-
 
9837
	    1, var_max(sysctls));
-
 
9838
 
-
 
9839
	netsnmp_register_scalar_group(
-
 
9840
	    netsnmp_create_handler_registration(
-
 
9841
		    "iptNetflowTotals",
-
 
9842
		    iptNetflowTotals_handler,
-
 
9843
		    iptNetflowTotals_oid,
-
 
9844
		    OID_LENGTH(iptNetflowTotals_oid),
-
 
9845
		    HANDLER_CAN_RONLY),
-
 
9846
	    1, var_max(totals));
-
 
9847
 
-
 
9848
	/* Register first table. */
-
 
9849
	reg = netsnmp_create_handler_registration(
-
 
9850
	    "iptNetflowCpuTable", /* no handler */ NULL,
-
 
9851
	    iptNetflowCpuTable_oid, OID_LENGTH(iptNetflowCpuTable_oid),
-
 
9852
	    HANDLER_CAN_RONLY);
-
 
9853
 
-
 
9854
	/* set up columns */
-
 
9855
	cpu_data_set = netsnmp_create_table_data_set("iptNetflowCpuDataSet");
-
 
9856
	netsnmp_table_set_add_indexes(cpu_data_set, ASN_INTEGER, 0);
-
 
9857
	/* I include cpuIndex into columns, which is not SMIv2'ish */
-
 
9858
	for (sys = cputable; sys->obj; sys++)
-
 
9859
		netsnmp_table_set_add_default_row(cpu_data_set, sys->obj, sys->type, 0, NULL, 0);
-
 
9860
	netsnmp_register_table_data_set(reg, cpu_data_set, NULL);
-
 
9861
 
-
 
9862
	/* cache handler will load actual data, and it needs to be
-
 
9863
	 * injected in front of dataset handler to be called first */
-
 
9864
	stat_cache = netsnmp_cache_create(
-
 
9865
	    /* no timeout */ -1,
-
 
9866
	    stat_cache_load, dummy_cache_free,
-
 
9867
	    iptNetflowCpuTable_oid, OID_LENGTH(iptNetflowCpuTable_oid));
-
 
9868
	netsnmp_inject_handler(reg, netsnmp_cache_handler_get(stat_cache));
-
 
9869
 
-
 
9870
	/* Register second table. */
-
 
9871
	reg = netsnmp_create_handler_registration(
-
 
9872
	    "iptNetflowSockTable", /* no handler */ NULL,
-
 
9873
	    iptNetflowSockTable_oid, OID_LENGTH(iptNetflowSockTable_oid),
-
 
9874
	    HANDLER_CAN_RONLY);
-
 
9875
 
-
 
9876
	/* set up columns */
-
 
9877
	sock_data_set = netsnmp_create_table_data_set("iptNetflowSockDataSet");
-
 
9878
	/* I don't include sockIndex into columns, which is more SMIv2'ish */
-
 
9879
	netsnmp_table_set_add_indexes(sock_data_set, ASN_INTEGER, 0);
-
 
9880
	for (sys = &socktable[1]; sys->obj; sys++)
-
 
9881
		netsnmp_table_set_add_default_row(sock_data_set, sys->obj, sys->type, 0, NULL, 0);
-
 
9882
	netsnmp_register_table_data_set(reg, sock_data_set, NULL);
-
 
9883
 
-
 
9884
	/* as before, cache handler will load actual data, and it needs
-
 
9885
	 * to be injected in front of dataset handler to be called first */
-
 
9886
	stat_cache = netsnmp_cache_create(
-
 
9887
	    /* no timeout */ -1,
-
 
9888
	    stat_cache_load, dummy_cache_free,
-
 
9889
	    iptNetflowSockTable_oid, OID_LENGTH(iptNetflowSockTable_oid));
-
 
9890
	netsnmp_inject_handler(reg, netsnmp_cache_handler_get(stat_cache));
-
 
9891
}
-
 
9892
 
-
 
9893
void deinit_netflow(void)
-
 
9894
{
-
 
9895
	DEBUGMSGTL(("netflow", "deinit_netflow\n"));
-
 
9896
}
-
 
9897
 
-
 
9898
ipt-netflow-2.2/dkms.conf0000644000000000000000000000042713213006644014132 0ustar  rootrootPACKAGE_NAME=ipt-netflow
-
 
9899
pushd `dirname $BASH_SOURCE`
-
 
9900
PACKAGE_VERSION=`./version.sh`
-
 
9901
popd
-
 
9902
BUILT_MODULE_NAME[0]=ipt_NETFLOW
-
 
9903
DEST_MODULE_LOCATION[0]=/kernel/extra
-
 
9904
STRIP[0]=no
-
 
9905
MAKE[0]="make ipt_NETFLOW.ko"
-
 
9906
PRE_BUILD="./configure --from-dkms-conf=$kernel_source_dir"
-
 
9907
AUTOINSTALL=yes
-
 
9908
ipt-netflow-2.2/ipt_NETFLOW.h0000644000000000000000000003536313213006644014477 0ustar  rootroot/*
-
 
9909
 *   This file is part of NetFlow exporting module.
-
 
9910
 *
-
 
9911
 *   This program is free software: you can redistribute it and/or modify
-
 
9912
 *   it under the terms of the GNU General Public License as published by
-
 
9913
 *   the Free Software Foundation, either version 2 of the License, or
-
 
9914
 *   (at your option) any later version.
-
 
9915
 *
-
 
9916
 *   This program is distributed in the hope that it will be useful,
-
 
9917
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
9918
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
9919
 *   GNU General Public License for more details.
-
 
9920
 *
-
 
9921
 *   You should have received a copy of the GNU General Public License
-
 
9922
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 
9923
 *
-
 
9924
 */
-
 
9925
 
-
 
9926
#ifndef _IPT_NETFLOW_H
-
 
9927
#define _IPT_NETFLOW_H
-
 
9928
 
-
 
9929
/*
-
 
9930
 * Some tech info:
-
 
9931
 * http://www.cisco.com/en/US/products/ps6601/prod_white_papers_list.html
-
 
9932
 * http://www.cisco.com/en/US/products/sw/netmgtsw/ps1964/products_implementation_design_guide09186a00800d6a11.html
-
 
9933
 */
-
 
9934
 
-
 
9935
#define NETFLOW5_RECORDS_MAX 30
-
 
9936
 
-
 
9937
struct netflow5_record {
-
 
9938
	__be32		s_addr;
-
 
9939
	__be32		d_addr;
-
 
9940
	__be32		nexthop;
-
 
9941
	__be16		i_ifc;
-
 
9942
	__be16		o_ifc;
-
 
9943
	__be32		nr_packets;
-
 
9944
	__be32		nr_octets;
-
 
9945
	__be32		first_ms;
-
 
9946
	__be32		last_ms;
-
 
9947
	__be16		s_port;
-
 
9948
	__be16		d_port;
-
 
9949
	__u8		reserved;
-
 
9950
	__u8		tcp_flags;
-
 
9951
	__u8		protocol;
-
 
9952
	__u8		tos;
-
 
9953
	__be16		s_as;
-
 
9954
	__be16		d_as;
-
 
9955
	__u8		s_mask;
-
 
9956
	__u8		d_mask;
-
 
9957
	__u16		padding;
-
 
9958
} __attribute__ ((packed));
-
 
9959
 
-
 
9960
/* NetFlow v5 packet */
-
 
9961
struct netflow5_pdu {
-
 
9962
	__be16			version;
-
 
9963
	__be16			nr_records;
-
 
9964
	__be32			ts_uptime; /* ms */
-
 
9965
	__be32			ts_usecs;  /* s  */
-
 
9966
	__be32			ts_unsecs; /* ns */
-
 
9967
	__be32			seq;
-
 
9968
	__u8			eng_type;
-
 
9969
	__u8			eng_id;
-
 
9970
	__u16			sampling;
-
 
9971
	struct netflow5_record	flow[NETFLOW5_RECORDS_MAX];
-
 
9972
} __attribute__ ((packed));
-
 
9973
#define NETFLOW5_HEADER_SIZE (sizeof(struct netflow5_pdu) - NETFLOW5_RECORDS_MAX * sizeof(struct netflow5_record))
-
 
9974
 
-
 
9975
#define IF_NAME_SZ	IFNAMSIZ
-
 
9976
#define IF_DESC_SZ	32
-
 
9977
 
-
 
9978
/* NetFlow v9	http://www.ietf.org/rfc/rfc3954.txt */
-
 
9979
/* IPFIX	http://www.iana.org/assignments/ipfix/ipfix.xhtml */
-
 
9980
/* v9 elements are uppercased, IPFIX camel cased. */
-
 
9981
#define one(id, name, len) name = id,
-
 
9982
#define two(id, a, b, len)		\
-
 
9983
		one(id, a, len)	\
-
 
9984
		one(id, b, len)
-
 
9985
#define Elements \
-
 
9986
	two(1,   IN_BYTES, octetDeltaCount, 4) \
-
 
9987
	two(2,   IN_PKTS, packetDeltaCount, 4) \
-
 
9988
	two(4,   PROTOCOL, protocolIdentifier, 1) \
-
 
9989
	two(5,   TOS, ipClassOfService, 1) \
-
 
9990
	two(6,   TCP_FLAGS, tcpControlBits, 1) \
-
 
9991
	two(7,   L4_SRC_PORT, sourceTransportPort, 2) \
-
 
9992
	two(8,   IPV4_SRC_ADDR, sourceIPv4Address, 4) \
-
 
9993
	two(9,   SRC_MASK, sourceIPv4PrefixLength, 1) \
-
 
9994
	two(10,  INPUT_SNMP, ingressInterface, 2) \
-
 
9995
	two(11,  L4_DST_PORT, destinationTransportPort, 2) \
-
 
9996
	two(12,  IPV4_DST_ADDR, destinationIPv4Address, 4) \
-
 
9997
	two(13,  DST_MASK, destinationIPv4PrefixLength, 1) \
-
 
9998
	two(14,  OUTPUT_SNMP, egressInterface, 2) \
-
 
9999
	two(15,  IPV4_NEXT_HOP, ipNextHopIPv4Address, 4) \
-
 
10000
	two(21,  LAST_SWITCHED, flowEndSysUpTime, 4) \
-
 
10001
	two(22,  FIRST_SWITCHED, flowStartSysUpTime, 4) \
-
 
10002
	one(25,  minimumIpTotalLength, 2) \
-
 
10003
	one(26,  maximumIpTotalLength, 2) \
-
 
10004
	two(27,  IPV6_SRC_ADDR, sourceIPv6Address, 16) \
-
 
10005
	two(28,  IPV6_DST_ADDR, destinationIPv6Address, 16) \
-
 
10006
	two(31,  IPV6_FLOW_LABEL, flowLabelIPv6, 3) \
-
 
10007
	two(32,  ICMP_TYPE, icmpTypeCodeIPv4, 2) \
-
 
10008
	two(33,  MUL_IGMP_TYPE, igmpType, 1) \
-
 
10009
	two(40,  TOTAL_BYTES_EXP, exportedOctetTotalCount, 8) \
-
 
10010
	two(41,  TOTAL_PKTS_EXP, exportedMessageTotalCount, 8) \
-
 
10011
	two(42,  TOTAL_FLOWS_EXP, exportedFlowRecordTotalCount, 8) \
-
 
10012
	two(48,  FLOW_SAMPLER_ID, samplerId, 1) \
-
 
10013
	two(49,  FLOW_SAMPLER_MODE, samplerMode, 1) \
-
 
10014
	two(50,  FLOW_SAMPLER_RANDOM_INTERVAL, samplerRandomInterval, 2) \
-
 
10015
	one(52,  minimumTTL, 1) \
-
 
10016
	one(53,  maximumTTL, 1) \
-
 
10017
	two(56,  SRC_MAC, sourceMacAddress, 6) \
-
 
10018
	two(57,  DST_MAC, postDestinationMacAddress, 6) \
-
 
10019
	two(58,  SRC_VLAN, vlanId, 2) \
-
 
10020
	two(61,  DIRECTION, flowDirection, 1) \
-
 
10021
	two(62,  IPV6_NEXT_HOP, ipNextHopIPv6Address, 16) \
-
 
10022
	two(64,  IPV6_OPTION_HEADERS, ipv6ExtensionHeaders, 2) \
-
 
10023
	two(70,  MPLS_LABEL_1,  mplsTopLabelStackSection, 3) \
-
 
10024
	two(71,  MPLS_LABEL_2,  mplsLabelStackSection2,   3) \
-
 
10025
	two(72,  MPLS_LABEL_3,  mplsLabelStackSection3,   3) \
-
 
10026
	two(73,  MPLS_LABEL_4,  mplsLabelStackSection4,   3) \
-
 
10027
	two(74,  MPLS_LABEL_5,  mplsLabelStackSection5,   3) \
-
 
10028
	two(75,  MPLS_LABEL_6,  mplsLabelStackSection6,   3) \
-
 
10029
	two(76,  MPLS_LABEL_7,  mplsLabelStackSection7,   3) \
-
 
10030
	two(77,  MPLS_LABEL_8,  mplsLabelStackSection8,   3) \
-
 
10031
	two(78,  MPLS_LABEL_9,  mplsLabelStackSection9,   3) \
-
 
10032
	two(79,  MPLS_LABEL_10, mplsLabelStackSection10,  3) \
-
 
10033
	one(80,  destinationMacAddress, 6) \
-
 
10034
	two(82,  IF_NAME, interfaceName, IF_NAME_SZ) \
-
 
10035
	two(83,  IF_DESC, interfaceDescription, IF_DESC_SZ) \
-
 
10036
	one(136, flowEndReason, 1) \
-
 
10037
	one(138, observationPointId, 4) \
-
 
10038
	one(139, icmpTypeCodeIPv6, 2) \
-
 
10039
	one(141, LineCardId, 4) \
-
 
10040
	one(142, portId, 4) \
-
 
10041
	one(143, meteringProcessId, 4) \
-
 
10042
	one(144, exportingProcessId, 4) \
-
 
10043
	one(145, TemplateId, 2) \
-
 
10044
	one(149, observationDomainId, 4) \
-
 
10045
	one(152, flowStartMilliseconds, 8) \
-
 
10046
	one(153, flowEndMilliseconds, 8) \
-
 
10047
	one(154, flowStartMicroseconds, 8) \
-
 
10048
	one(155, flowEndMicroseconds, 8) \
-
 
10049
	one(160, systemInitTimeMilliseconds, 8) \
-
 
10050
	one(163, observedFlowTotalCount, 8) \
-
 
10051
	one(164, ignoredPacketTotalCount, 8) \
-
 
10052
	one(165, ignoredOctetTotalCount, 8) \
-
 
10053
	one(166, notSentFlowTotalCount, 8) \
-
 
10054
	one(167, notSentPacketTotalCount, 8) \
-
 
10055
	one(168, notSentOctetTotalCount, 8) \
-
 
10056
	one(200, mplsTopLabelTTL, 1) \
-
 
10057
	one(201, mplsLabelStackLength, 1) \
-
 
10058
	one(202, mplsLabelStackDepth, 1) \
-
 
10059
	one(208, ipv4Options, 4) \
-
 
10060
	one(209, tcpOptions, 4) \
-
 
10061
	one(225, postNATSourceIPv4Address, 4) \
-
 
10062
	one(226, postNATDestinationIPv4Address, 4) \
-
 
10063
	one(227, postNAPTSourceTransportPort, 2) \
-
 
10064
	one(228, postNAPTDestinationTransportPort, 2) \
-
 
10065
	one(230, natEvent, 1) \
-
 
10066
	one(243, dot1qVlanId, 2) \
-
 
10067
	one(244, dot1qPriority, 1) \
-
 
10068
	one(245, dot1qCustomerVlanId, 2) \
-
 
10069
	one(246, dot1qCustomerPriority, 1) \
-
 
10070
	one(252, ingressPhysicalInterface, 2) \
-
 
10071
	one(253, egressPhysicalInterface, 2) \
-
 
10072
	one(256, ethernetType, 2) \
-
 
10073
	one(295, IPSecSPI, 4) \
-
 
10074
	one(300, observationDomainName, 128) \
-
 
10075
	one(302, selectorId, 1) \
-
 
10076
	one(309, samplingSize, 1) \
-
 
10077
	one(310, samplingPopulation, 2) \
-
 
10078
	one(318, selectorIdTotalPktsObserved, 8) \
-
 
10079
	one(319, selectorIdTotalPktsSelected, 8) \
-
 
10080
	one(323, observationTimeMilliseconds, 8) \
-
 
10081
	one(324, observationTimeMicroseconds, 8) \
-
 
10082
	one(325, observationTimeNanoseconds, 8) \
-
 
10083
	one(390, flowSelectorAlgorithm, 1) \
-
 
10084
	one(394, selectorIDTotalFlowsObserved, 8) \
-
 
10085
	one(395, selectorIDTotalFlowsSelected, 8) \
-
 
10086
	one(396, samplingFlowInterval, 1) \
-
 
10087
	one(397, samplingFlowSpacing, 2)
-
 
10088
 
-
 
10089
enum {
-
 
10090
	Elements
-
 
10091
};
-
 
10092
#undef one
-
 
10093
#undef two
-
 
10094
 
-
 
10095
enum {
-
 
10096
	FLOWSET_TEMPLATE = 0,
-
 
10097
	FLOWSET_OPTIONS = 1,
-
 
10098
	IPFIX_TEMPLATE = 2,
-
 
10099
	IPFIX_OPTIONS = 3,
-
 
10100
	FLOWSET_DATA_FIRST = 256,
-
 
10101
};
-
 
10102
 
-
 
10103
enum {				/* v9 scopes */
-
 
10104
	V9_SCOPE_SYSTEM = 1,
-
 
10105
	V9_SCOPE_INTERFACE = 2,
-
 
10106
	V9_SCOPE_LINECARD = 3,
-
 
10107
	V9_SCOPE_CACHE = 4,
-
 
10108
	V9_SCOPE_TEMPLATE = 5,
-
 
10109
};
-
 
10110
 
-
 
10111
struct flowset_template {
-
 
10112
	__be16	flowset_id;
-
 
10113
	__be16	length;		/* (bytes) */
-
 
10114
	__be16	template_id;
-
 
10115
	__be16	field_count;	/* (items) */
-
 
10116
} __attribute__ ((packed));
-
 
10117
 
-
 
10118
struct flowset_data {
-
 
10119
	__be16	flowset_id;	/* corresponds to template_id */
-
 
10120
	__be16	length;		/* (bytes) */
-
 
10121
} __attribute__ ((packed));
-
 
10122
 
-
 
10123
/* http://tools.ietf.org/html/rfc3954#section-6.1 */
-
 
10124
struct flowset_opt_tpl_v9 {
-
 
10125
	__be16	flowset_id;
-
 
10126
	__be16	length;
-
 
10127
	__be16	template_id;
-
 
10128
	__be16	scope_len;	/* (bytes) */
-
 
10129
	__be16	opt_len;	/* (bytes) */
-
 
10130
} __attribute__ ((packed));
-
 
10131
 
-
 
10132
/* http://tools.ietf.org/html/rfc5101#section-3.4.2.2 */
-
 
10133
struct flowset_opt_tpl_ipfix {
-
 
10134
	__be16	flowset_id;
-
 
10135
	__be16	length;
-
 
10136
	__be16	template_id;
-
 
10137
	__be16	field_count;	/* total (items) */
-
 
10138
	__be16	scope_count;	/* (items) must not be zero */
-
 
10139
} __attribute__ ((packed));
-
 
10140
 
-
 
10141
/* NetFlow v9 packet. */
-
 
10142
struct netflow9_pdu {
-
 
10143
	__be16		version;
-
 
10144
	__be16		nr_records;	/* (items) */
-
 
10145
	__be32		sys_uptime_ms;
-
 
10146
	__be32		export_time_s;
-
 
10147
	__be32		seq;
-
 
10148
	__be32		source_id;	/* Exporter Observation Domain */
-
 
10149
	__u8		data[1400];
-
 
10150
} __attribute__ ((packed));
-
 
10151
 
-
 
10152
/* IPFIX packet. */
-
 
10153
struct ipfix_pdu {
-
 
10154
	__be16		version;
-
 
10155
	__be16		length;		/* (bytes) */
-
 
10156
	__be32		export_time_s;
-
 
10157
	__be32		seq;
-
 
10158
	__be32		odomain_id;	/* Observation Domain ID */
-
 
10159
	__u8		data[1400];
-
 
10160
} __attribute__ ((packed));
-
 
10161
 
-
 
10162
/* Maximum bytes flow can have, after it's reached flow will become
-
 
10163
 * not searchable and will be exported soon. */
-
 
10164
#define FLOW_FULL_WATERMARK 0xffefffff
-
 
10165
 
-
 
10166
#define EXTRACT_SPI(tuple)	((tuple.s_port << 16) | tuple.d_port)
-
 
10167
#define SAVE_SPI(tuple, spi)	{ tuple.s_port = spi >> 16; \
-
 
10168
				  tuple.d_port = spi; }
-
 
10169
#define MAX_VLAN_TAGS	2
-
 
10170
 
-
 
10171
/* hashed data which identify unique flow */
-
 
10172
/* 16+16 + 2+2 + 2+1+1+1 = 41 */
-
 
10173
struct ipt_netflow_tuple {
-
 
10174
	union nf_inet_addr src;
-
 
10175
	union nf_inet_addr dst;
-
 
10176
	__be16		s_port; // Network byte order
-
 
10177
	__be16		d_port; // -"-
-
 
10178
#ifdef MPLS_DEPTH
-
 
10179
	__be32		mpls[MPLS_DEPTH]; /* Network byte order */
-
 
10180
#endif
-
 
10181
	__u16		i_ifc;	// Host byte order
-
 
10182
#ifdef ENABLE_VLAN
-
 
10183
	__be16		tag[MAX_VLAN_TAGS]; // Network byte order (outer tag first)
-
 
10184
#endif
-
 
10185
	__u8		protocol;
-
 
10186
	__u8		tos;
-
 
10187
	__u8		l3proto;
-
 
10188
#ifdef ENABLE_MAC
-
 
10189
	__u8		h_dst[ETH_ALEN];
-
 
10190
	__u8		h_src[ETH_ALEN];
-
 
10191
#endif
-
 
10192
} __attribute__ ((packed));
-
 
10193
 
-
 
10194
/* hlist[2] + tuple[]: 8+8 + 41 = 57 (less than usual cache line, 64) */
-
 
10195
struct ipt_netflow {
-
 
10196
	struct hlist_node hlist; // hashtable search chain
-
 
10197
 
-
 
10198
	/* unique per flow data (hashed, NETFLOW_TUPLE_SIZE) */
-
 
10199
	struct ipt_netflow_tuple tuple;
-
 
10200
 
-
 
10201
	/* volatile data */
-
 
10202
	union nf_inet_addr nh;
-
 
10203
#if defined(ENABLE_MAC) || defined(ENABLE_VLAN)
-
 
10204
	__be16		ethernetType; /* Network byte order */
-
 
10205
#endif
-
 
10206
	__u16		o_ifc;
-
 
10207
#ifdef ENABLE_PHYSDEV
-
 
10208
	__u16		i_ifphys;
-
 
10209
	__u16		o_ifphys;
-
 
10210
#endif
-
 
10211
#ifdef SNMP_RULES
-
 
10212
	__u16		i_ifcr;	/* translated interface numbers*/
-
 
10213
	__u16		o_ifcr;
-
 
10214
#endif
-
 
10215
	__u8		s_mask;
-
 
10216
	__u8		d_mask;
-
 
10217
	__u8		tcp_flags; /* `OR' of all tcp flags */
-
 
10218
	__u8		flowEndReason;
-
 
10219
#ifdef ENABLE_DIRECTION
-
 
10220
	__u8		hooknumx; /* hooknum + 1 */
-
 
10221
#endif
-
 
10222
	/* flow statistics */
-
 
10223
	u_int32_t	nr_packets;
-
 
10224
	u_int32_t	nr_bytes;
-
 
10225
#ifdef ENABLE_SAMPLER
-
 
10226
	unsigned int	sampler_count; /* for deterministic sampler only */
-
 
10227
#endif
-
 
10228
	union {
-
 
10229
		struct {
-
 
10230
			unsigned long first;
-
 
10231
			unsigned long last;
-
 
10232
		} ts;
-
 
10233
		ktime_t	ts_obs;
-
 
10234
	} _ts_un;
-
 
10235
#define nf_ts_first _ts_un.ts.first
-
 
10236
#define nf_ts_last  _ts_un.ts.last
-
 
10237
#define nf_ts_obs   _ts_un.ts_obs
-
 
10238
	u_int32_t	flow_label; /* IPv6 */
-
 
10239
	u_int32_t	options; /* IPv4(16) & IPv6(32) Options */
-
 
10240
	u_int32_t	tcpoptions;
-
 
10241
#ifdef CONFIG_NF_NAT_NEEDED
-
 
10242
	__be32		s_as;
-
 
10243
	__be32		d_as;
-
 
10244
	struct nat_event *nat;
-
 
10245
#endif
-
 
10246
	union {
-
 
10247
		struct list_head list; /* all flows in ipt_netflow_list */
-
 
10248
#ifdef HAVE_LLIST
-
 
10249
		struct llist_node llnode; /* purged flows */
-
 
10250
#endif
-
 
10251
	} _flow_list;
-
 
10252
#define flows_list  _flow_list.list
-
 
10253
#define flows_llnode _flow_list.llnode
-
 
10254
};
-
 
10255
 
-
 
10256
#ifdef CONFIG_NF_NAT_NEEDED
-
 
10257
enum {
-
 
10258
	NAT_CREATE = 1, NAT_DESTROY = 2, NAT_POOLEXHAUSTED = 3
-
 
10259
};
-
 
10260
struct nat_event {
-
 
10261
	struct list_head list;
-
 
10262
	struct {
-
 
10263
		__be32	s_addr;
-
 
10264
		__be32	d_addr;
-
 
10265
		__be16	s_port;
-
 
10266
		__be16	d_port;
-
 
10267
	} pre, post;
-
 
10268
	ktime_t		ts_ktime;
-
 
10269
	unsigned long	ts_jiffies;
-
 
10270
	__u8	protocol;
-
 
10271
	__u8	nat_event;
-
 
10272
};
-
 
10273
#define IS_DUMMY_FLOW(nf) (nf->nat)
-
 
10274
#else
-
 
10275
#define IS_DUMMY_FLOW(nf) 0
-
 
10276
#endif
-
 
10277
 
-
 
10278
static inline int ipt_netflow_tuple_equal(const struct ipt_netflow_tuple *t1,
-
 
10279
				    const struct ipt_netflow_tuple *t2)
-
 
10280
{
-
 
10281
	return (!memcmp(t1, t2, sizeof(struct ipt_netflow_tuple)));
-
 
10282
}
-
 
10283
 
-
 
10284
struct ipt_netflow_sock {
-
 
10285
	struct list_head list;
-
 
10286
	struct socket *sock;
-
 
10287
	struct sockaddr_storage addr;	// destination
-
 
10288
	struct sockaddr_storage saddr;	// source
-
 
10289
	char   sdev[IFNAMSIZ];		// source device
-
 
10290
	atomic_t wmem_peak;		// sk_wmem_alloc peak value
-
 
10291
	unsigned int err_connect;	// connect errors
-
 
10292
	unsigned int err_full;		// socket filled error
-
 
10293
	unsigned int err_other;		// other socket errors
-
 
10294
	unsigned int err_cberr;		// async errors, icmp
-
 
10295
	unsigned int pkt_exp;		// pkts expoted to this dest
-
 
10296
	u64 bytes_exp;			// bytes -"-
-
 
10297
	u64 bytes_exp_old;		// for rate calculation
-
 
10298
	unsigned int bytes_rate;	// bytes per second
-
 
10299
	unsigned int pkt_sent;		// pkts sent to this dest
-
 
10300
	unsigned int pkt_fail;		// pkts failed to send to this dest
-
 
10301
};
-
 
10302
 
-
 
10303
struct netflow_aggr_n {
-
 
10304
	struct list_head list;
-
 
10305
	atomic_t usage;
-
 
10306
	__u32 mask;
-
 
10307
	__u32 addr;
-
 
10308
	__u32 aggr_mask;
-
 
10309
	__u8 prefix;
-
 
10310
};
-
 
10311
 
-
 
10312
struct netflow_aggr_p {
-
 
10313
	struct list_head list;
-
 
10314
	atomic_t usage;
-
 
10315
	__u16 port1;
-
 
10316
	__u16 port2;
-
 
10317
	__u16 aggr_port;
-
 
10318
};
-
 
10319
 
-
 
10320
#define NETFLOW_STAT_INC(count) (__get_cpu_var(ipt_netflow_stat).count++)
-
 
10321
#define NETFLOW_STAT_ADD(count, val) (__get_cpu_var(ipt_netflow_stat).count += (unsigned long long)val)
-
 
10322
#define NETFLOW_STAT_SET(count, val) (__get_cpu_var(ipt_netflow_stat).count = (unsigned long long)val)
-
 
10323
#define NETFLOW_STAT_TS(count)							 \
-
 
10324
	do {									 \
-
 
10325
		ktime_t kts = ktime_get_real();					 \
-
 
10326
		if (!(__get_cpu_var(ipt_netflow_stat)).count.first_tv64)	 \
-
 
10327
			__get_cpu_var(ipt_netflow_stat).count.first = kts;	 \
-
 
10328
		__get_cpu_var(ipt_netflow_stat).count.last = kts;		 \
-
 
10329
	} while (0);
-
 
10330
 
-
 
10331
#define NETFLOW_STAT_INC_ATOMIC(count)				\
-
 
10332
	do {							\
-
 
10333
		preempt_disable();				\
-
 
10334
		(__get_cpu_var(ipt_netflow_stat).count++);	\
-
 
10335
		preempt_enable();				\
-
 
10336
	} while (0);
-
 
10337
 
-
 
10338
#define NETFLOW_STAT_ADD_ATOMIC(count, val)			\
-
 
10339
	do {							\
-
 
10340
		preempt_disable();				\
-
 
10341
		(__get_cpu_var(ipt_netflow_stat).count += (unsigned long long)val); \
-
 
10342
		preempt_enable();				\
-
 
10343
	} while (0);
-
 
10344
#define NETFLOW_STAT_READ(count) ({					\
-
 
10345
		unsigned int _tmp = 0, _cpu;				\
-
 
10346
		for_each_present_cpu(_cpu)				\
-
 
10347
			 _tmp += per_cpu(ipt_netflow_stat, _cpu).count;	\
-
 
10348
		_tmp;							\
-
 
10349
	})
-
 
10350
 
-
 
10351
struct duration {
-
 
10352
	ktime_t first;
-
 
10353
	ktime_t last;
-
 
10354
};
-
 
10355
 
-
 
10356
/* statistics */
-
 
10357
struct ipt_netflow_stat {
-
 
10358
	u64 searched;			// hash stat
-
 
10359
	u64 found;			// hash stat
-
 
10360
	u64 notfound;			// hash stat (new flows)
-
 
10361
	u64  pkt_total;			// packets metered
-
 
10362
	u64 traf_total;			// traffic metered
-
 
10363
#ifdef ENABLE_PROMISC
-
 
10364
	u64 pkt_promisc;		// how much packets passed promisc code
-
 
10365
	u64 pkt_promisc_drop;		// how much packets discarded
-
 
10366
#endif
-
 
10367
	/* above is grouped for cache */
-
 
10368
	unsigned int truncated;		// packets stat (drop)
-
 
10369
	unsigned int frags;		// packets stat (drop)
-
 
10370
	unsigned int maxflows_err;	// maxflows reached (drop)
-
 
10371
	unsigned int alloc_err;		// failed to allocate memory (drop & lost)
-
 
10372
	struct duration drop;
-
 
10373
	unsigned int send_success;	// sendmsg() ok
-
 
10374
	unsigned int send_failed;	// sendmsg() failed
-
 
10375
	unsigned int sock_cberr;	// socket error callback called (got icmp refused)
-
 
10376
	unsigned int exported_rate;	// netflow traffic itself
-
 
10377
	u64 exported_pkt;		// netflow traffic itself
-
 
10378
	u64 exported_flow;		// netflow traffic itself
-
 
10379
	u64 exported_traf;		// netflow traffic itself
-
 
10380
	u64 exported_trafo;		// netflow traffic itself
-
 
10381
	u64  pkt_total_prev;		// packets metered previous interval
-
 
10382
	u32  pkt_total_rate;		// packet rate for this cpu
-
 
10383
	u64  pkt_drop;			// packets not metered
-
 
10384
	u64 traf_drop;			// traffic not metered
-
 
10385
	u64 flow_lost;			// flows not sent to collector
-
 
10386
	u64  pkt_lost;			// packets not sent to collector
-
 
10387
	u64 traf_lost;			// traffic not sent to collector
-
 
10388
	struct duration lost;
-
 
10389
	u64  pkt_out;			// packets out of the hash
-
 
10390
	u64 traf_out;			// traffic out of the hash
-
 
10391
#ifdef ENABLE_SAMPLER
-
 
10392
	u64 pkts_observed;		// sampler stat
-
 
10393
	u64 pkts_selected;		// sampler stat
-
 
10394
#endif
-
 
10395
	u64 old_searched;		// previous hash stat
-
 
10396
	u64 old_found;			// for calculation per cpu metric
-
 
10397
	u64 old_notfound;
-
 
10398
	int metric;			// one minute ewma of hash efficiency
-
 
10399
};
-
 
10400
 
-
 
10401
#endif
-
 
10402
/* vim: set sw=8: */
-
 
10403
ipt-netflow-2.2/version.sh0000755000000000000000000000164013213006644014347 0ustar  rootroot#!/bin/sh
-
 
10404
# This script determines actual module version.
-
 
10405
 
-
 
10406
PATH=$PATH:/usr/local/bin:/usr/bin:/bin
-
 
10407
 
-
 
10408
# Base version from the source.
-
 
10409
MVERSION=`sed -n 's/^#define.*IPT_NETFLOW_VERSION.*"\(.*\)".*/\1/p' ipt_NETFLOW.c`
-
 
10410
 
-
 
10411
# GITVERSION overrides base version.
-
 
10412
if [ -e version.h ] && grep -q GITVERSION version.h; then
-
 
10413
  MVERSION=`sed -n 's/#define GITVERSION "\(.*\)".*/\1/p' version.h`
-
 
10414
fi
-
 
10415
 
-
 
10416
# git describe overrides version from the source.
-
 
10417
if [ -d .git ] && which git >/dev/null 2>&1; then \
-
 
10418
  GVERSION=`git describe --dirty 2>/dev/null`
-
 
10419
  if [ "$GVERSION" ]; then
-
 
10420
    MVERSION=${GVERSION#v}
-
 
10421
  fi
-
 
10422
else
-
 
10423
  GVERSION=
-
 
10424
fi
-
 
10425
 
-
 
10426
if [ "$1" = --define ]; then
-
 
10427
  # called from Makefile to create version.h
-
 
10428
  # which should contain GITVERSION or be empty.
-
 
10429
  if [ "$GVERSION" ]; then
-
 
10430
    echo "#define GITVERSION \"$MVERSION\""
-
 
10431
  else
-
 
10432
    echo "/* placeholder, because kernel doesn't like empty files */"
-
 
10433
  fi
-
 
10434
else
-
 
10435
  # normal run
-
 
10436
  echo $MVERSION
-
 
10437
fi
-
 
10438
ipt-netflow-2.2/README0000644000000000000000000010145113213006644013204 0ustar  rootrootipt_NETFLOW linux 2.6.x-4.x kernel module by <abc@telekom.ru> -- 2008-2016.
-
 
10439
 
-
 
10440
   High performance NetFlow v5, v9, IPFIX flow data export module for Linux
-
 
10441
   kernel. Created to be useful for highly loaded linux router. It should be
-
 
10442
   used as iptables target.
-
 
10443
 
-
 
10444
 
-
 
10445
=========================
-
 
10446
= Detailed Feature List =
-
 
10447
=========================
-
 
10448
 
-
 
10449
   * High performance and scalability. For highest performance module could be
-
 
10450
     run without conntrack being enabled in kernel. Reported to be able to
-
 
10451
     handle 10Gbit traffic with more than 1500000 pps with negligible server
-
 
10452
     load (on S5500BC).
-
 
10453
 
-
 
10454
   * NetFlow v5, v9, and IPFIX are fully supported.
-
 
10455
 
-
 
10456
     Support of v9/IPFIX is adding flexibility to exporting of flow data
-
 
10457
     plus greater visibility of traffic, letting export many additional fields
-
 
10458
     besides what was possible in v5 era. Such as
-
 
10459
     
-
 
10460
   * IPv6 option headers, IPv4 options, TCP options, ethernet type, dot1q
-
 
10461
     service and customer VLAN ids, MAC addresses, and
-
 
10462
 
-
 
10463
   * Full IPv6 support,
-
 
10464
 
-
 
10465
   * NAT translations events (from conntrack) using NetFlow Event Logging (NEL).
-
 
10466
     This is standardized way for v9/IPFIXr, but module export such events even
-
 
10467
     for v5 collectors via specially crafted pseudo-records.
-
 
10468
 
-
 
10469
   * Deterministic (systematic count-based), random and hash Flow Sampling.
-
 
10470
     With appropriate differences in support of v5, v9, and IPFIX.
-
 
10471
 
-
 
10472
   * SNMP agent (for net-snmp) for remote management and monitoring.
-
 
10473
 
-
 
10474
   * Options Templates (v9/IPFIX) let export useful statistical,
-
 
10475
     configurational, and informational records to collector.
-
 
10476
     Such as metering, exporting, sampling stat and reliability stat, sampling 
-
 
10477
     configuration, network devices ifName, ifDescr list.
-
 
10478
 
-
 
10479
   * Tested to compile and work out of the box on Centos 5, 6, 7, Debian and
-
 
10480
   * Ubuntu. Many vanilla Linux kernels since 2.6.18 up to the latest (as of
-
 
10481
   * writing is 3.19) are supported and tested.
-
 
10482
 
-
 
10483
   * Module load time and run-time (via sysctl) configuration.
-
 
10484
 
-
 
10485
   * Flexibility in enabling features via ./configure script. This will let you
-
 
10486
     disable features you don't need, which increase compatibility with custom
-
 
10487
     kernels and performance.
-
 
10488
 
-
 
10489
   * SNMP-index translation rules, let convert meaningless and unstable
-
 
10490
     interface indexes (ifIndex) to more meaningful numbering scheme.
-
 
10491
 
-
 
10492
   * Easy support for catching mirrored traffic with promisc option. Which is
-
 
10493
     also supporting optional MPLS decapsulation and MPLS-aware NetFlow.
-
 
10494
 
-
 
10495
 
-
 
10496
============================
-
 
10497
= OBTAINING LATEST VERSION =
-
 
10498
============================
-
 
10499
 
-
 
10500
   $ git clone git://github.com/aabc/ipt-netflow.git ipt-netflow
-
 
10501
   $ cd ipt-netflow
-
 
10502
 
-
 
10503
 
-
 
10504
================
-
 
10505
= INSTALLATION =
-
 
10506
================
-
 
10507
 
-
 
10508
   Five easy steps.
-
 
10509
 
-
 
10510
** 1. Prepare Kernel source
-
 
10511
 
-
 
10512
   If you have package system install kernel-devel package, otherwise install
-
 
10513
   raw kernel source from http://kernel.org matching _exactly_ version of your
-
 
10514
   installed kernel.
-
 
10515
 
-
 
10516
   a) What to do for Centos:
-
 
10517
 
-
 
10518
      ~# yum install kernel-devel
-
 
10519
 
-
 
10520
   b) What to do for Debian and Ubuntu:
-
 
10521
 
-
 
10522
      ~# apt-get install module-assistant
-
 
10523
      ~# m-a prepare
-
 
10524
 
-
 
10525
   c) Otherwise, if you downloaded raw kernel sources don't forget to create
-
 
10526
    .config by copying it from your distribution's kernel. Its copy could reside
-
 
10527
    in /boot or sometimes in /proc, examples:
-
 
10528
 
-
 
10529
      kernel-src-dir/# cp /boot/config-`uname -r` .config
-
 
10530
    or
-
 
10531
      kernel-src-dir/# zcat /proc/config.gz > .config
-
 
10532
 
-
 
10533
    Assuming you unpacked kernel source into `kernel-src-dir/' directory.
-
 
10534
    Then run:
-
 
10535
 
-
 
10536
      kernel-src-dir/# make oldconfig
-
 
10537
 
-
 
10538
    After that you'll need to prepare kernel for modules build:
-
 
10539
 
-
 
10540
      kernel-src-dir/# make prepare modules_prepare
-
 
10541
 
-
 
10542
   Note: Don't try to `make prepare' in Centos kernel-devel package directory
-
 
10543
     (which is usually something like /usr/src/kernels/2.6.32-431.el6.x86_64)
-
 
10544
     as this is wrong and meaningless.
-
 
10545
 
-
 
10546
** 2. Prepare Iptables
-
 
10547
 
-
 
10548
   Before this step it also would be useful to install pkg-config if don't
-
 
10549
   already have.
-
 
10550
 
-
 
10551
   If you have package system just install iptables-devel (or iptables-dev)
-
 
10552
   package, otherwise install iptables source matching version of your
-
 
10553
   installation from ftp://ftp.netfilter.org/pub/iptables/
-
 
10554
 
-
 
10555
   a) What to do for Centos:
-
 
10556
 
-
 
10557
      # yum install iptables-devel
-
 
10558
 
-
 
10559
   b) What to do for Debian or Ubuntu:
-
 
10560
 
-
 
10561
      # apt-get install iptables-dev pkg-config
-
 
10562
 
-
 
10563
   c) Otherwise, for raw iptables source build it and make install.
-
 
10564
 
-
 
10565
** 3. Prepare net-snmp (optional)
-
 
10566
 
-
 
10567
  In case you want to manage or monitor module performance via SNMP you
-
 
10568
  may install net-snmp. If you want to skip this step run configure
-
 
10569
  with --disable-snmp-agent option.
-
 
10570
 
-
 
10571
  a) For Centos:
-
 
10572
 
-
 
10573
      # yum install net-snmp net-snmp-devel
-
 
10574
 
-
 
10575
  b) For Debian or Ubuntu:
-
 
10576
 
-
 
10577
      # apt-get install snmpd libsnmp-dev
-
 
10578
 
-
 
10579
  c) Otherwise install net-snmp from www.net-snmp.org
-
 
10580
 
-
 
10581
** 4. Now, to actually build the module run:
-
 
10582
 
-
 
10583
      ~/ipt-netflow# ./configure
-
 
10584
      ~/ipt-netflow# make all install
-
 
10585
      ~/ipt-netflow# depmod
-
 
10586
 
-
 
10587
   This will install kernel module and iptables specific library.
-
 
10588
 
-
 
10589
   Troubleshooting:
-
 
10590
 
-
 
10591
     a) Sometimes you will want to add CC=gcc-3 to make command.
-
 
10592
     Example: make CC=gcc-3.3
-
 
10593
 
-
 
10594
     b) Compile module with actual kernel source compiled.
-
 
10595
     I.e. first compile kernel and boot into it, and then compile module.
-
 
10596
     If you are using kernel-devel package check that its version matches
-
 
10597
     your kernel package.
-
 
10598
 
-
 
10599
     c) If you have sources in non-standard places or configure isn't able to
-
 
10600
     find something run ./configure --help to see how to specify paths manually.
-
 
10601
 
-
 
10602
     d) To run irqtop on Debian 8 you may need to install:
-
 
10603
 
-
 
10604
       # apt-get install ruby ruby-dev ncurses-dev
-
 
10605
       # gem install curses
-
 
10606
 
-
 
10607
     z) If all fails create ticket at
-
 
10608
          https://github.com/aabc/ipt-netflow/issues
-
 
10609
 
-
 
10610
** 5. After this point you should be able to load module and
-
 
10611
     use -j NETFLOW target in your iptables. See next section.
-
 
10612
 
-
 
10613
 
-
 
10614
=====================
-
 
10615
= Configure Options =
-
 
10616
=====================
-
 
10617
 
-
 
10618
   Configure script allows to enable or disable optional features:
-
 
10619
 
-
 
10620
     --enable-natevents
-
 
10621
         enables natevents (NEL) support, (this and option will require
-
 
10622
	 conntrack support to be enabled into kernel and conntack
-
 
10623
         module (nf_conntrack) loaded before ipt_NETFLOW. Usually this is
-
 
10624
         done automatically because of `depmod', but if you don't do `make
-
 
10625
         install' you'll need to load nf_conntrack manually.
-
 
10626
         Read below for explanation of natevents.
-
 
10627
 
-
 
10628
     --enable-sampler
-
 
10629
         enables flow sampler. Read below for explanation of its configuration
-
 
10630
	 option.
-
 
10631
 
-
 
10632
     --enable-sampler=hash
-
 
10633
         additionally enables 'hash' sampler.
-
 
10634
 
-
 
10635
     --disable-snmp-agent
-
 
10636
         disables building net-snmp agent module, which is enabled by default.
-
 
10637
 
-
 
10638
     --enable-snmp-rules
-
 
10639
         enables SNMP-index conversion rules. Read below for explanation
-
 
10640
         of snmp-rules.
-
 
10641
 
-
 
10642
     --enable-macaddress
-
 
10643
         enables exporting of src and dst MAC addresses for every flow
-
 
10644
         in v9/IPFIX. Difference in any of MAC address will be accounted
-
 
10645
         as differnt flow. I.e. MAC addresses will be part of flow key.
-
 
10646
 
-
 
10647
     --enable-vlan
-
 
10648
         enables exporting of dot1q VLAN Ids and Priorities for every flow
-
 
10649
         in v9/IPFIX. It supports outer and second dot1q tags if present.
-
 
10650
 
-
 
10651
         Any of two previous options will enable exporting of Ethernet Packet
-
 
10652
         Type, ethernetType(256).
-
 
10653
 
-
 
10654
     --enable-direction
-
 
10655
         enables exporting of flowDirection(61) Element for v9/IPFIX.
-
 
10656
 
-
 
10657
         Packets captured in PREROUTING and INPUT chains will be accounted as
-
 
10658
         ingress flows(0), in OUTPUT and POSTROUTING as egress flows(1), and
-
 
10659
         in FORWARD will have flowDirection set to undefined value 255.
-
 
10660
 
-
 
10661
     --enable-aggregation
-
 
10662
         enables aggregation rules. Read below for explanation of aggregation.
-
 
10663
 
-
 
10664
     --disable-dkms
-
 
10665
         disable creating dkms.conf and auto-install module into DKMS tree.
-
 
10666
 
-
 
10667
     --disable-dkms-install
-
 
10668
         only disable auto-install into DKMS, but still create dkms.conf, in
-
 
10669
         case you will want to install it manually.
-
 
10670
 
-
 
10671
     --enable-physdev
-
 
10672
	 Export ingressPhysicalInterface(252) and egressPhysicalInterface(253)
-
 
10673
	 (relevant for bridges) in V9 and IPFIX. If your collector does not
-
 
10674
	 support these Elements but you still need physdevs then use
-
 
10675
	 --enable-physdev-override, in that case physdevs will override normal
-
 
10676
	 interface numbers ingressInterface(10) and egressInterface(14).
-
 
10677
 
-
 
10678
     --enable-promisc
-
 
10679
	 Enables capturing of promiscuous packets into raw/PREROUTING chain.
-
 
10680
	 See README.promisc Solution 1 for usage details and example.
-
 
10681
 
-
 
10682
     --promisc-mpls
-
 
10683
	 Enables MPLS label stack decapsulation for promiscuous packets. (For
-
 
10684
	 IPv4 and IPv6 packets only). This also enables MPLS-aware NetFlow (v9
-
 
10685
	 and IPFIX), you may wish to specify with --promisc-mpls=n how much MPLS
-
 
10686
	 labels you want to be recorded and exported (default is 3, maximum is
-
 
10687
	 10, set to 0 to not report anything).
-
 
10688
 
-
 
10689
 
-
 
10690
===========
-
 
10691
= RUNNING =
-
 
10692
===========
-
 
10693
 
-
 
10694
1. You can load module directly by insmod like this:
-
 
10695
 
-
 
10696
     # insmod ipt_NETFLOW.ko destination=127.0.0.1:2055 debug=1
-
 
10697
 
-
 
10698
   Or if properly installed (make install; depmod) by this:
-
 
10699
 
-
 
10700
     # modprobe ipt_NETFLOW destination=127.0.0.1:2055
-
 
10701
 
-
 
10702
   See, you may add options in insmod/modprobe command line, or add
-
 
10703
   them in /etc/modprobe.conf or /etc/modprobe.d/ipt_NETFLOW.conf
-
 
10704
   like thus:
-
 
10705
 
-
 
10706
     options ipt_NETFLOW destination=127.0.0.1:2055 protocol=9 natevents=1
-
 
10707
 
-
 
10708
2. Statistics is in /proc/net/stat/ipt_netflow
-
 
10709
   Machine readable statistics is in /proc/net/stat/ipt_netflow_snmp
-
 
10710
   To view boring slab statistics: grep ipt_netflow /proc/slabinfo
-
 
10711
   Dump of all flows is in /proc/net/stat/ipt_netflow_flows
-
 
10712
 
-
 
10713
3. You can view parameters and control them via sysctl, example:
-
 
10714
 
-
 
10715
     # sysctl net.netflow
-
 
10716
     # sysctl net.netflow.hashsize=32768
-
 
10717
 
-
 
10718
   Note: For after-reboot configuration I recommend to store module parameters
-
 
10719
   in modprobe configs instead of storing them in /etc/sysctl.conf, as it's
-
 
10720
   less clear when init process will apply sysctl.conf, before of after
-
 
10721
   module's load.
-
 
10722
 
-
 
10723
4. Example of directing all IPv4 traffic into the module:
-
 
10724
 
-
 
10725
     # iptables -I FORWARD -j NETFLOW
-
 
10726
     # iptables -I INPUT -j NETFLOW
-
 
10727
     # iptables -I OUTPUT -j NETFLOW
-
 
10728
 
-
 
10729
   Note: It is preferable (because easier to understand) to _insert_
-
 
10730
   NETFLOW target at the top of the chain, otherwise not all traffic may
-
 
10731
   reach NETFLOW if your iptables configuration is complicated and some
-
 
10732
   other rule inadvertently consume the traffic (dropping or acepting before
-
 
10733
   NETFLOW is reached). It's always good to test your configuration.
-
 
10734
   Use  iptables -L -nvx  to check pkts/bytes counters on the rules.
-
 
10735
 
-
 
10736
5. If you want to account IPv6 traffic you should use protocol 9 or 10.
-
 
10737
   Example of directing all IPv6 traffic into the module:
-
 
10738
 
-
 
10739
     # sysctl net.netflow.protocol=10
-
 
10740
     # ip6tables -I FORWARD -j NETFLOW
-
 
10741
     # ip6tables -I INPUT -j NETFLOW
-
 
10742
     # ip6tables -I OUTPUT -j NETFLOW
-
 
10743
 
-
 
10744
   Note: First enable right version of protocol and after that add ip6tables
-
 
10745
     rules, otherwise you will get errors in dmesg.
-
 
10746
 
-
 
10747
6. If you want to account NAT events (NEL):
-
 
10748
 
-
 
10749
     # sysctl net.netflow.natevents=1
-
 
10750
 
-
 
10751
   Note that natevents feature is completely independent from traffic accounting
-
 
10752
   (it's using so called conntrack events), thus you don't need to set or change
-
 
10753
   any iptables rules to use that. You may need to enable kernel config option
-
 
10754
   CONFIG_NF_CONNTRACK_EVENTS though (if it isn't already enabled).
-
 
10755
   For details on how they are exported for different protocol versions see
-
 
10756
   below.
-
 
10757
 
-
 
10758
7. For SNMP support you will need to add this command into snmpd.conf to
-
 
10759
   enable IPT-NETFLOW-MIB in SNMP agent:
-
 
10760
 
-
 
10761
      dlmod netflow /usr/lib/snmp/dlmod/snmp_NETFLOW.so
-
 
10762
 
-
 
10763
   Restart snmpd for changes to take effect. Don't forget to properly configure
-
 
10764
   access control. Example simplest configuration may looks like (note that this
-
 
10765
   is whole /etc/snmp/snmpd.conf):
-
 
10766
 
-
 
10767
      rocommunity public 127.0.0.1
-
 
10768
      dlmod netflow /usr/lib/snmp/dlmod/snmp_NETFLOW.so
-
 
10769
 
-
 
10770
   Note, that this config will also allow _full_ read-only access to the whole
-
 
10771
   linux MIB. To install IPT-NETFLOW-MIB locally, copy file IPT-NETFLOW-MIB.my
-
 
10772
   into ~/.snmp/mibs/
-
 
10773
 
-
 
10774
   * Detailed example of SNMP configuration is there:
-
 
10775
   * https://github.com/aabc/ipt-netflow/wiki/Configuring-SNMP-access
-
 
10776
 
-
 
10777
   To check that MIB is installed well you may issue:
-
 
10778
 
-
 
10779
     $ snmptranslate -m IPT-NETFLOW-MIB -IR -Tp iptNetflowMIB
-
 
10780
 
-
 
10781
   This should output IPT-NETFLOW-MIB in tree form.
-
 
10782
 
-
 
10783
   To check that snmp agent is working well issue:
-
 
10784
 
-
 
10785
     $ snmpwalk -v 1 -c public 127.0.0.1 -m IPT-NETFLOW-MIB iptNetflowMIB
-
 
10786
 
-
 
10787
   Should output full MIB. If MIB is not installed try:
-
 
10788
 
-
 
10789
     $ snmpget -v 1 -c public 127.0.0.1 .1.3.6.1.4.1.37476.9000.10.1.1.1.1.0
-
 
10790
 
-
 
10791
   Which should output STRING: "ipt_NETFLOW".
-
 
10792
 
-
 
10793
   MIB provides access to very similar statistics that you have in
-
 
10794
   /proc/net/stat/ipt_netflow, you can read description of objects in
-
 
10795
   text file IPT-NETFLOW-MIB.my
-
 
10796
 
-
 
10797
   If you want to access to SNMP stat in machine readable form for your
-
 
10798
   scripts there is file /proc/net/stat/ipt_netflow_snmp
-
 
10799
 
-
 
10800
   Note: Using of SNMP v2c or v3 is mandatory for most tables, because
-
 
10801
   this MIB uses 64-bit counters (Counter64) which is not supported in old
-
 
10802
   SNMP v1. You should understand that 32-bit counter will wrap on 10Gbit
-
 
10803
   traffic in just 3.4 seconds! So, always pass option `-v2c' or `-v3'
-
 
10804
   to net-snmp utils. Or, for example, configure option `defVersion 2c'
-
 
10805
   in ~/.snmp/snmp.conf  You can also have `defCommunity public' ov v3
-
 
10806
   auth parameters (defSecurityName, defSecurityLevel, defPassphrase)
-
 
10807
   set there (man snmp.conf).
-
 
10808
 
-
 
10809
   Examples for dumping typical IPT-NETFLOW-MIB objects:
-
 
10810
 
-
 
10811
   - Module info (similar to modinfo, SNMPv1 is ok for following two objects):
-
 
10812
 
-
 
10813
     $ snmpwalk -v 1 -c public 127.0.0.1 -m IPT-NETFLOW-MIB iptNetflowModule
-
 
10814
 
-
 
10815
   - Read-write sysctl-like parameters (yes, they are writable via snmpset, you
-
 
10816
     may need to configure write access to snmpd, though):
-
 
10817
 
-
 
10818
     $ snmpwalk -v 1 -c public 127.0.0.1 -m IPT-NETFLOW-MIB iptNetflowSysctl
-
 
10819
 
-
 
10820
   - Global performance stat of the module (note -v2c, because rest of the
-
 
10821
     objects require SNMP v2c or SNMP v3):
-
 
10822
 
-
 
10823
     $ snmpwalk -v2c -c public 127.0.0.1 -m IPT-NETFLOW-MIB iptNetflowTotals
-
 
10824
 
-
 
10825
   - Per-CPU (metering) and per-socket (exporting) statistics in table format:
-
 
10826
 
-
 
10827
     $ snmptable -v2c -c public 127.0.0.1 -m IPT-NETFLOW-MIB iptNetflowCpuTable
-
 
10828
     $ snmptable -v2c -c public 127.0.0.1 -m IPT-NETFLOW-MIB iptNetflowSockTable
-
 
10829
 
-
 
10830
 
-
 
10831
===========
-
 
10832
= OPTIONS =
-
 
10833
===========
-
 
10834
 
-
 
10835
   Options can be passed as parameters to module or changed dynamically
-
 
10836
   via  sysctl net.netflow  or  IPT-NETFLOW-MIB::iptNetflowSysctl
-
 
10837
 
-
 
10838
   protocol=5
-
 
10839
     - what version of NetFlow protocol to use. Default is 5.
-
 
10840
       You can choose from 5, 9, or 10 (where 10 is IPFIX). If you plan
-
 
10841
       to account IPv6 traffic you should use protocol 9 or 10 (IPFIX),
-
 
10842
       because NetFlow v5 isn't compatible with IPv6.
-
 
10843
 
-
 
10844
   destination=127.0.0.1:2055
-
 
10845
     - where to export netflow, to this ip address. Port is optional, default
-
 
10846
       is 2055. You will see this connection in netstat like this:
-
 
10847
 
-
 
10848
       udp 0 0 127.0.0.1:32772 127.0.0.1:2055 ESTABLISHED 
-
 
10849
 
-
 
10850
   destination=[2001:db8::1]:2055
-
 
10851
     - export target using IPv6 address. Brackets are optional, but otherwise
-
 
10852
       you should delimit port with 'p' or '#' character.
-
 
10853
 
-
 
10854
   destination=127.0.0.1:2055,192.0.0.1:2055
-
 
10855
     - mirror flows to two (can be more) addresses, separate addresses
-
 
10856
       with comma.
-
 
10857
 
-
 
10858
   destination=127.0.0.1:2055@127.0.0.2
-
 
10859
     - bind socket to address (127.0.0.2).
-
 
10860
 
-
 
10861
   destination=127.0.0.1:2055%eth0
-
 
10862
     - bind socket to interface (eth0). May be useful for multi-homed boxes.
-
 
10863
 
-
 
10864
   sampler=deterministic:123
-
 
10865
   sampler=random:123
-
 
10866
   sampler=hash:123
-
 
10867
     - enables Flow Sampling. To disable set to the empty value or to `0'.
-
 
10868
       Note, that this is flow sampling (as of RFC 7014), not packet
-
 
10869
       sampling (PSAMP).
-
 
10870
 
-
 
10871
       There is three sampling modes:
-
 
10872
 
-
 
10873
         deterministic:  select each N-th observed flow; in IPFIX this mode
-
 
10874
                         is called Systematic count-based Sampling;
-
 
10875
         random:         select randomly one out of N flows.
-
 
10876
         hash:           select hash-randomly one out of N flows.
-
 
10877
 
-
 
10878
       Number after colon is population size N, with valid values 2-16383.
-
 
10879
       (This 16383 limit is for compatibility with NetFlow v5.)
-
 
10880
         Using 'deterministic' and 'random' sampling will not reduce resource
-
 
10881
       usage caused by the module, because flows are sampled late in exporting
-
 
10882
       process. This will reduces amount of flows which go to the collector,
-
 
10883
       thus, reducing load on the collector.
-
 
10884
         On the other hand, using 'hash' sampling will reduce CPU and memory
-
 
10885
       load caused by the module, because flows are discarded early in the
-
 
10886
       processing chain. They are discarded almost like in random sampler,
-
 
10887
       except that pseudo-random value is depend on the Flow Key hash for each
-
 
10888
       packet.
-
 
10889
         All required NetFlow/IPFIX information to signal use of sampling is
-
 
10890
       also sent to the collector. 'Hash' sampling will be presented as 'random'
-
 
10891
       sampling to the collector, because of their similarity.
-
 
10892
       Note, that Flow Sampling is compatible with NetFlow v5, v9, and IPFIX.
-
 
10893
 
-
 
10894
   natevents=1
-
 
10895
     - Collect and send NAT translation events as NetFlow Event Logging (NEL)
-
 
10896
       for NetFlow v9/IPFIX, or as dummy flows compatible with NetFlow v5.
-
 
10897
       Default is 0 (don't send).
-
 
10898
 
-
 
10899
       For NetFlow v5 protocol meaning of fields in dummy flows are such:
-
 
10900
         Src IP, Src Port  is Pre-nat source address.
-
 
10901
         Dst IP, Dst Port  is Post-nat destination address.
-
 
10902
           - These two fields made equal to data flows catched in FORWARD chain.
-
 
10903
         Nexthop, Src AS  is Post-nat source address for SNAT. Or,
-
 
10904
         Nexthop, Dst AS  is Pre-nat destination address for DNAT.
-
 
10905
         TCP Flags is SYN+SCK for start event, RST+FIN for stop event.
-
 
10906
         Pkt/Traffic size is 0 (zero), so it won't interfere with accounting.
-
 
10907
 
-
 
10908
       Natevents are compilation disabled by default, to enable you will need to
-
 
10909
       add --enable-natevents option to ./configure script.
-
 
10910
 
-
 
10911
       For techical description of NAT Events see:
-
 
10912
         http://tools.ietf.org/html/draft-ietf-behave-ipfix-nat-logging-04
-
 
10913
 
-
 
10914
   inactive_timeout=15
-
 
10915
     - export flow after it's inactive for 15 seconds. Default value is 15.
-
 
10916
 
-
 
10917
   active_timeout=1800
-
 
10918
     - export flow after it's active for 1800 seconds (30 minutes). Default
-
 
10919
       value is 1800.
-
 
10920
 
-
 
10921
   refresh-rate=20
-
 
10922
     - for NetFlow v9 and IPFIX it's rate how frequently to re-send templates
-
 
10923
       (per packets). You probably don't need to change default (which is 20).
-
 
10924
 
-
 
10925
   timeout-rate=30
-
 
10926
     - for NetFlow v9 and IPFIX it's rate when to re-send old templates (in
-
 
10927
       minutes). No need to change it.
-
 
10928
 
-
 
10929
   debug=0
-
 
10930
     - debug level (none).
-
 
10931
 
-
 
10932
   sndbuf=number
-
 
10933
     - size of output socket buffer in bytes. I recommend you to put higher
-
 
10934
       value if you experience netflow packet drops (can be seen in statistics
-
 
10935
       as 'sock: fail' number.)
-
 
10936
       Default value is system default.
-
 
10937
 
-
 
10938
   hashsize=number
-
 
10939
     - Hash table bucket size. Used for performance tuning.
-
 
10940
       Abstractly speaking, it should be minimum two times bigger than flows
-
 
10941
       you usually have, but not need to.
-
 
10942
       Default is system memory dependent small enough value.
-
 
10943
 
-
 
10944
   maxflows=2000000
-
 
10945
     - Maximum number of flows to account. It's here to prevent DOS attacks.
-
 
10946
       After this limit is reached new flows will not be accounted. Default is
-
 
10947
       2000000, zero is unlimited.
-
 
10948
 
-
 
10949
   aggregation=string..
-
 
10950
     - Few aggregation rules (or some say they are rule.)
-
 
10951
 
-
 
10952
       Buffer for aggregation string 1024 bytes, and sysctl limit it
-
 
10953
         to ~700 bytes, so don't write there a lot.
-
 
10954
       Rules worked in definition order for each packet, so don't
-
 
10955
         write them a lot again.
-
 
10956
       Rules applied to both directions (dst and src).
-
 
10957
       Rules tried until first match, but for netmask and port
-
 
10958
          aggregations separately.
-
 
10959
       Delimit them with commas.
-
 
10960
 
-
 
10961
       Rules are of two kinds: for netmask aggregation
-
 
10962
          and port aggregation:
-
 
10963
 
-
 
10964
       a) Netmask aggregation example: 192.0.0.0/8=16
-
 
10965
       Which mean to strip addresses matching subnet 192.0.0.0/8 to /16.
-
 
10966
 
-
 
10967
       b) Port aggregation example: 80-89=80
-
 
10968
       Which mean to replace ports from 80 to 89 with 80.
-
 
10969
 
-
 
10970
       Full example:
-
 
10971
          aggregation=192.0.0.0/8=16,10.0.0.0/8=16,80-89=80,3128=80
-
 
10972
 
-
 
10973
       Aggregation rules are enabled by default, if you feel you don't need them
-
 
10974
       you may add --disable-aggregation to ./configure script.
-
 
10975
 
-
 
10976
   snmp-rules=string...
-
 
10977
     - Few SNMP-index conversion rules similar to fproble-ulog.
-
 
10978
 
-
 
10979
       Quoting man fprobe-ulog:
-
 
10980
 
-
 
10981
         "Comma separated list of interface name to SNMP-index conversion
-
 
10982
         rules.  Each rule consists of interface base name and SNMP-index
-
 
10983
         base separated by colon (e.g. ppp:200). Final SNMP-index is  sum
-
 
10984
         of corresponding SNMP-index base and interface number.
-
 
10985
         In the above example SNMP-index of interface ppp11 is 211.
-
 
10986
 
-
 
10987
         If interface  name  did not fit to any of conversion rules then
-
 
10988
         SNMP-index will be taken from kernel."
-
 
10989
 
-
 
10990
       This implementation isn't optimized for performance (no rule caching
-
 
10991
       or hashing), but should be fast if rules list are short.
-
 
10992
 
-
 
10993
       Rules are parsed in order from first to last until first match.
-
 
10994
 
-
 
10995
       snmp-rules are compilation disabled by default, to enable you will need
-
 
10996
       to add --enable-snmp option to ./configure script.
-
 
10997
 
-
 
10998
   scan-min=1
-
 
10999
     - Minimal interval between flow export scans. Sometimes could be useful
-
 
11000
       to reduce load on exporting CPU by increasing this interval. Value are
-
 
11001
       in kernel jiffies units (which is x/HZ seconds).
-
 
11002
 
-
 
11003
   promisc=1
-
 
11004
     - Enables promisc hack. See README.promisc Solution 1 for details.
-
 
11005
 
-
 
11006
   exportcpu=number
-
 
11007
     - Lock exporter to single CPU. This may be useful to fine control CPU
-
 
11008
       load. Common use case: with smp_affinity and RSS you spread packet
-
 
11009
       processing to all CPUs except one, and lock it to the exporter. While
-
 
11010
       exporter CPU load generally is not high, for someone it may be not
-
 
11011
       desirable to combine it with packet processing on very highly loaded
-
 
11012
       routers.
-
 
11013
 
-
 
11014
       This option could be changed at runtime with:
-
 
11015
 
-
 
11016
         # echo number > /sys/module/ipt_NETFLOW/parameters/exportcpu
-
 
11017
 
-
 
11018
   engine_id=number
-
 
11019
     - Observation Domain ID (on IPFIX, Source Id on NetFlow v9, or Engine Id
-
 
11020
       on NetFlow v5) value to be exported. This may help your collector to
-
 
11021
       distinguish between multiple exporters. On Netflow v9 and IPFIX this
-
 
11022
       value is 32-bit on NetFlow v5 only 8 low bits are significant.
-
 
11023
       Default value is 0.
-
 
11024
 
-
 
11025
       This option could be changed at runtime with:
-
 
11026
 
-
 
11027
         # echo number > /sys/module/ipt_NETFLOW/parameters/engine_id
-
 
11028
 
-
 
11029
 
-
 
11030
====================
-
 
11031
= HOW TO READ STAT =
-
 
11032
====================
-
 
11033
 
-
 
11034
  Statistics is your friend to fine tune and understand netflow module
-
 
11035
  performance.
-
 
11036
 
-
 
11037
  To see stat in human readable form:
-
 
11038
    # cat /proc/net/stat/ipt_netflow
-
 
11039
 
-
 
11040
  How to interpret the data:
-
 
11041
 
-
 
11042
> ipt_NETFLOW version v1.8-122-gfae9d59-dirty, srcversion 6141961152BE0DFA6A21EF4; aggr mac vlan
-
 
11043
 
-
 
11044
  This line helps to identify actual source that your module is build on.
-
 
11045
  Please always supply it in all bug reports.
-
 
11046
 
-
 
11047
  v1.8-122: 1.8 is release, 122 is commit number after release;
-
 
11048
  -gfae9d59: fae9d59 is short git commit id;
-
 
11049
  -dirty: if present, meaning that git detected that sources are changed since
-
 
11050
      last git commit, you may wish to do `git diff' to view changes;
-
 
11051
  srcversion 6141961152BE0DFA6A21EF4: binary version of module, you can
-
 
11052
      compare this with data from `modinfo ./ipt_NETFLOW.ko' to identify
-
 
11053
      actual binary loaded;
-
 
11054
  aggr mac vlan: tags to identify compile time options that are enabled.
-
 
11055
 
-
 
11056
> Protocol version 10 (ipfix), refresh-rate 20, timeout-rate 30, (templates 2, active 2). Timeouts: active 5, inactive 15. Maxflows 2000000
-
 
11057
 
-
 
11058
  Protocol version currently in use. Refresh-rate and timeout-rate
-
 
11059
      for v9 and IPFIX. Total templates generated and currently active.
-
 
11060
  Timeout: active X: how much seconds to wait before exporting active flow.
-
 
11061
    - same as sysctl net.netflow.active_timeout variable.
-
 
11062
  inactive X: how much seconds to wait before exporting inactive flow.
-
 
11063
    - same as sysctl net.netflow.inactive_timeout variable.
-
 
11064
  Maxflows 2000000: maxflows limit.
-
 
11065
    - all flows above maxflows limit must be dropped.
-
 
11066
    - you can control maxflows limit by sysctl net.netflow.maxflows variable.
-
 
11067
 
-
 
11068
> Promisc hack is disabled (observed 0 packets, discarded 0).
-
 
11069
 
-
 
11070
  observed n: To see that promisc hack is really working.
-
 
11071
 
-
 
11072
> Natevents disabled, count start 0, stop 0.
-
 
11073
 
-
 
11074
    - Natevents mode disabled or enabled, and how much start or stop events
-
 
11075
      are reported.
-
 
11076
 
-
 
11077
> Flows: active 5187 (peak 83905 reached 0d0h1m ago), mem 283K, worker delay 100/1000 (37 ms, 0 us, 4:0 0 [3]).
-
 
11078
 
-
 
11079
  active X: currently active flows in memory cache.
-
 
11080
    - for optimum CPU performance it is recommended to set hash table size to
-
 
11081
      at least twice of average of this value, or higher.
-
 
11082
  peak X reached Y ago: peak value of active flows.
-
 
11083
  mem XK: how much kilobytes of memory currently taken by active flows.
-
 
11084
    - one active flow taking 56 bytes of memory.
-
 
11085
    - there is system limit on cache size too.
-
 
11086
  worker delay X/HZ: how frequently exporter scan flows table per second.
-
 
11087
  Rest is boring debug info.
-
 
11088
 
-
 
11089
> Hash: size 8192 (mem 32K), metric 1.00, [1.00, 1.00, 1.00]. InHash: 1420 pkt, 364 K, InPDU 28, 6716.
-
 
11090
 
-
 
11091
  Hash: size X: current hash size/limit.
-
 
11092
    - you can control this by sysctl net.netflow.hashsize variable.
-
 
11093
    - increasing this value can significantly reduce CPU load.
-
 
11094
    - default value is not optimal for performance.
-
 
11095
    - optimal value is twice of average of active flows.
-
 
11096
  mem XK: how much memory occupied by hash table.
-
 
11097
    - hash table is fixed size by nature, taking 4 bytes per entry.
-
 
11098
  metric X, [X, X, X]: how optimal is your hash table being used.
-
 
11099
    - lesser value mean more optimal hash table use, min is 1.0.
-
 
11100
    - last three numbers in squares is moving average (EWMA) of hash table
-
 
11101
      access divided by match rate (searches / matches) for 4sec, and 1, 5, and
-
 
11102
      15 minutes. Sort of hash table load average. First value is instantaneous.
-
 
11103
      You can try to increase hashsize if averages more than 1 (increase
-
 
11104
      certainly if >= 2).
-
 
11105
  InHash: X pkt, X K: how much traffic accounted for flows in the hash table.
-
 
11106
  InPDU X, X: how much traffic in flows preparing to be exported.
-
 
11107
 
-
 
11108
> Rate: 202448 bits/sec, 83 packets/sec; 1 min: 668463 bps, 930 pps; 5 min: 329039 bps, 483 pps
-
 
11109
 
-
 
11110
  - Module throughput values for 1 second, 1 minute, and 5 minutes.
-
 
11111
 
-
 
11112
> cpu#  pps; <search found new [metric], trunc frag alloc maxflows>, traffic: <pkt, bytes>, drop: <pkt, bytes>
-
 
11113
> cpu0  123; 980540  10473 180600 [1.03],    0    0    0    0, traffic: 188765, 14 MB, drop: 27863, 1142 K
-
 
11114
 
-
 
11115
  cpu#: this is Total and per CPU statistics for:
-
 
11116
  pps: packets per second on this CPU. It's useful to debug load imbalance.
-
 
11117
  <search found new, trunc frag alloc maxflows>: internal stat for:
-
 
11118
  search found new: hash table searched, found, and not found counters.
-
 
11119
  [metric]: one minute (ewma) average hash metric per cpu.
-
 
11120
  trunc: how much truncated packets are ignored
-
 
11121
    - for example if packets don't have valid IP header.
-
 
11122
    - it's also accounted in drop packets counter, but not in drop bytes.
-
 
11123
  frag: how much fragmented packets have seen.
-
 
11124
    - kernel defragments INPUT/OUTPUT chains for us if nf_defrag_ipv[46]
-
 
11125
      module is loaded.
-
 
11126
    - these packets are not ignored but not reassembled either, so:
-
 
11127
    - if there is no enough data in fragment (ex. tcp ports) it is considered
-
 
11128
      to be zero.
-
 
11129
  alloc: how much cache memory allocations are failed.
-
 
11130
    - packets ignored and accounted in traffic drop stat.
-
 
11131
    - probably increase system memory if this ever happen.
-
 
11132
  maxflows: how much packets ignored on maxflows (maximum active flows reached).
-
 
11133
    - packets ignored and accounted in traffic drop stat.
-
 
11134
    - you can control maxflows limit by sysctl net.netflow.maxflows variable.
-
 
11135
 
-
 
11136
  traffic: <pkt, bytes>: how much traffic is accounted.
-
 
11137
  pkt, bytes: sum of packets/megabytes accounted by module.
-
 
11138
    - flows that failed to be exported (on socket error) is accounted here too.
-
 
11139
 
-
 
11140
  drop: <pkt, bytes>: how much of traffic is not accounted.
-
 
11141
  pkt, bytes: sum of packets/kilobytes that are dropped by metering process.
-
 
11142
    - reasons these drops are accounted here:
-
 
11143
      truncated/fragmented packets,
-
 
11144
      packet is for new flow but failed to allocate memory for it,
-
 
11145
      packet is for new flow but maxflows is already reached.
-
 
11146
    Traffic lost due to socket errors is not accounted here. Look below
-
 
11147
      about export and socket errors.
-
 
11148
 
-
 
11149
> Export: Rate 0 bytes/s; Total 2 pkts, 0 MB, 18 flows; Errors 0 pkts; Traffic lost 0 pkts, 0 Kbytes, 0 flows.
-
 
11150
 
-
 
11151
  Rate X bytes/s: traffic rate generated by exporter itself.
-
 
11152
  Total X pkts, X MB: total amount of traffic generated by exporter.
-
 
11153
  X flows: how much data flows are exported.
-
 
11154
  Errors X pkts: how much packets not sent due to socket errors.
-
 
11155
  Traffic lost 0 pkts, 0 Kbytes, 0 flows: how much metered traffic is lost
-
 
11156
    due to socket errors.
-
 
11157
  Note that `cberr' errors are not accounted here due to their asynchronous
-
 
11158
    nature. Read below about `cberr' errors.
-
 
11159
 
-
 
11160
> sock0: 10.0.0.2:2055 unconnected (1 attempts).
-
 
11161
 
-
 
11162
  If socket is unconnected (for example if module loaded before interfaces is
-
 
11163
  up) it shows now much connection attempts was failed. It will try to connect
-
 
11164
  until success.
-
 
11165
 
-
 
11166
> sock0: 10.0.0.2:2055, sndbuf 106496, filled 0, peak 106848; err: sndbuf reached 928, connect 0, cberr 0, other 0
-
 
11167
 
-
 
11168
  sockX: per destination stats for:
-
 
11169
  X.X.X.X:Y: destination ip address and port.
-
 
11170
    - controlled by sysctl net.netflow.destination variable.
-
 
11171
  sndbuf X: how much data socket can hold in buffers.
-
 
11172
    - controlled by sysctl net.netflow.sndbuf variable.
-
 
11173
    - if you have packet drops due to sndbuf reached (error -11) increase this
-
 
11174
      value.
-
 
11175
  filled X: how much data in socket buffers right now.
-
 
11176
  peak X: peak value of how much data in socket buffers was.
-
 
11177
    - you will be interested to keep it below sndbuf value.
-
 
11178
  err: how much packets are dropped due to errors.
-
 
11179
    - all flows from them will be accounted in drop stat.
-
 
11180
  sndbuf reached X: how much packets dropped due to sndbuf being too small
-
 
11181
      (error -11).
-
 
11182
  connect X: how much connection attempts was failed.
-
 
11183
  cberr X: how much connection refused ICMP errors we got from export target.
-
 
11184
    - probably you are not launched collector software on destination,
-
 
11185
    - or specified wrong destination address.
-
 
11186
    - flows lost in this fashion is not possible to account in drop stat.
-
 
11187
    - these are ICMP errors, and would look like this in tcpdump:
-
 
11188
      05:04:09.281247 IP alice.19440 > bob.2055: UDP, length 120
-
 
11189
      05:04:09.281405 IP bob > alice: ICMP bob udp port 2055 unreachable, length 156
-
 
11190
  other X: dropped due to other possible errors.
-
 
11191
 
-
 
11192
> aggr0: ...
-
 
11193
  aggrX: aggregation rulesets.
-
 
11194
    - controlled by sysctl net.netflow.aggregation variable.
-
 
11195
 
-
 
11196
 
-
 
11197
==========================
-
 
11198
= NetFlow considerations =
-
 
11199
==========================
-
 
11200
 
-
 
11201
  List of all IPFIX Elements http://www.iana.org/assignments/ipfix/ipfix.xhtml
-
 
11202
 
-
 
11203
  Flow Keys are Elements that distinguish flows. Quoting RFC: "If a Flow
-
 
11204
  Record for a specific Flow Key value already exists, the Flow Record is
-
 
11205
  updated; otherwise, a new Flow Record is created."
-
 
11206
 
-
 
11207
  In this implementation following Elements are treated as Flow Keys:
-
 
11208
 
-
 
11209
     IPv4 source address:        sourceIPv4Address(8),
-
 
11210
     IPv6 source address:        sourceIPv6Address(27),
-
 
11211
     IPv4 destination address:   destinationIPv4Address(12),
-
 
11212
     IPv6 destination address:   destinationIPv6Address(28),
-
 
11213
     TCP/UDP source port:        sourceTransportPort(7),
-
 
11214
     TCP/UDP destination port:   destinationTransportPort(11),
-
 
11215
     input interface:            ingressInterface(10),
-
 
11216
     IP protocol:                protocolIdentifier(4),
-
 
11217
     IP TOS:                     ipClassOfService(5),
-
 
11218
     and address family (IP or IPv6).
-
 
11219
 
-
 
11220
  Additional Flow Keys if VLAN exporting is enabled:
-
 
11221
 
-
 
11222
     First (outer) dot1q VLAN tag: dot1qVlanId(243) and
-
 
11223
                                 dot1qPriority(244) for IPFIX,
-
 
11224
                                 or vlanId(243) for NetFlow v9.
-
 
11225
     Second (customer) dot1q VLAN tag: dot1qCustomerVlanId(245)
-
 
11226
                                 and dot1qCustomerPriority(246).
-
 
11227
 
-
 
11228
  Additional Flow Keys if MAC address exporting is enabled:
-
 
11229
 
-
 
11230
     Destination MAC address:    destinationMacAddress(80),
-
 
11231
     Source MAC address:         sourceMacAddress(56).
-
 
11232
 
-
 
11233
  Additional Flow Keys if MPLS-aware NetFlow is enabled:
-
 
11234
 
-
 
11235
     Captured MPLS stack is fully treated as flow key (including TTL values),
-
 
11236
     which is Elements from mplsTopLabelStackSection(70) to
-
 
11237
     mplsLabelStackSection10(79), and, if present, mplsTopLabelTTL(200).
-
 
11238
 
-
 
11239
 
-
 
11240
  Other Elements are not Flow Keys. Note that outer interface, which is
-
 
11241
  egressInterface(14), is not regarded as Flow Key. Quoting RFC 7012: "For
-
 
11242
  Information Elements ... for which the value may change from packet to packet
-
 
11243
  within a single Flow, the exported value of an Information Element is by
-
 
11244
  default determined by the first packet observed for the corresponding Flow".
-
 
11245
 
-
 
11246
  Note that NetFlow and IPFIX modes of operation may have slightly different
-
 
11247
  Elements being used and different statistics sent via Options Templates.
-
 
11248
 
-
 
11249
 
-
 
11250
=========
-
 
11251
= VOILA =
-
 
11252
=========
-
 
11253
ipt-netflow-2.2/README.promisc0000644000000000000000000000675513213006644014672 0ustar  rootrootHello,
-
 
11254
 
-
 
11255
If you wish to account with ipt-netflow module traffic mirrored on switch you may follow
-
 
11256
 one of these examples:
-
 
11257
 
-
 
11258
 
-
 
11259
   Solution 1: Promisc-hack module option. [2014]
-
 
11260
   Solution 2: General kernel patch. [2008]
-
 
11261
   Solution 3: Alternative w/o kernel patch, using bridges. [2010]
-
 
11262
 
-
 
11263
 
-
 
11264
    **************
-
 
11265
    * Solution 1 *
-
 
11266
    **************
-
 
11267
 
-
 
11268
   No kernel patching is need anymore! (As in easy.)
-
 
11269
 
-
 
11270
   Compile module with `./configure --enable-promisc' option. This will enable
-
 
11271
  `promisc=' module parameter and sysctl parameter `net.netflow.promisc'.
-
 
11272
  Set any of these to `1' to enable promisc hack, you will see dmesg message
-
 
11273
  that it's enabled, set to `0' to disable (default).
-
 
11274
 
-
 
11275
   This option turned on will pass promisc traffic into `PREROUTING' chain
-
 
11276
  of `raw' table (same as with promisc patches). Briefly it's like this:
-
 
11277
 
-
 
11278
   # cd ipt-netflow/
-
 
11279
   # ./configure --enable-promisc
-
 
11280
   # make all install
-
 
11281
   # iptables -A PREROUTING -t raw -i eth2 -j NETFLOW
-
 
11282
   # sysctl net.netflow.promisc=1
-
 
11283
   # ifconfig eth2 promisc
-
 
11284
   # grep Promisc /proc/net/stat/ipt_netflow
-
 
11285
 
-
 
11286
   Now you should be able to see promisc observed packets count increasing.
-
 
11287
 
-
 
11288
   Note, that enabling module's parameter promisc=1 will not enable promiscuous
-
 
11289
  mode on network cards, these are completely different things. This option will
-
 
11290
  let iptables to see promisc traffic. That traffic will not be routed anywhere
-
 
11291
  and discarded just after passing PREROUTING chain.
-
 
11292
 
-
 
11293
   Do not enable this option if you have kernel already patched with promisc
-
 
11294
  patch, as this may cause double accounting. Just keep it disabled or remove
-
 
11295
  the patch. Promisc patching is completely custom and non-standard, so if you
-
 
11296
  did not apply it - you are most probably safe to use promisc option. But, if
-
 
11297
  in doubt - measure if module seeing traffic in raw/PREROUTING, if it isn't - you
-
 
11298
  don't have the patch applied and certainly safe to use the option.
-
 
11299
 
-
 
11300
 
-
 
11301
 
-
 
11302
    **************
-
 
11303
    * Solution 2 *
-
 
11304
    **************
-
 
11305
 
-
 
11306
1. Patch your kernel with `raw_promisc.patch' to enable raw table to see promisc traffic.
-
 
11307
 
-
 
11308
 # cd /usr/src/linux
-
 
11309
 # patch -p1 < ~/ipt_netflow/raw_promisc.patch
-
 
11310
 
-
 
11311
 Then recompile and reinstall patched kernel.
-
 
11312
 
-
 
11313
2. For example you mirroring traffic on your Cisco switch to 47th vlan:
-
 
11314
 
-
 
11315
 # interface FastEthernet0/32
-
 
11316
 # description this port with vlan 47
-
 
11317
 # switchport trunk encapsulation dot1q
-
 
11318
 # switchport mode trunk
-
 
11319
 # !
-
 
11320
 # interface FastEthernet0/33
-
 
11321
 # port monitor FastEthernet0/32
-
 
11322
 # !
-
 
11323
 
-
 
11324
3. Enable promisc mode on interface to actually see the packets:
-
 
11325
 
-
 
11326
 # /sbin/ifconfig eth1 promisc
-
 
11327
 
-
 
11328
4. Configure vlan on your linux box:
-
 
11329
 
-
 
11330
 # /sbin/vconfig add eth1 47
-
 
11331
 # /sbin/ifconfig eth1.47 up
-
 
11332
 
-
 
11333
5. Compile module:
-
 
11334
 
-
 
11335
 # make clean all install
-
 
11336
 
-
 
11337
6. Load ipt_netflow module:
-
 
11338
 
-
 
11339
 # /sbin/modprobe ipt_NETFLOW hashsize=160000 destination=127.0.0.1:9800
-
 
11340
 
-
 
11341
7. Direct all packets from 47th vlan to ipt_netflow module:
-
 
11342
 
-
 
11343
 # /sbin/iptables -A PREROUTING -t raw -i eth1.47 -j NETFLOW
-
 
11344
 
-
 
11345
Voila.
-
 
11346
 
-
 
11347
ps. For Debian Squeeze instructions look at raw_promisc_debian_squeeze6.patch
-
 
11348
 
-
 
11349
 
-
 
11350
 
-
 
11351
    **************
-
 
11352
    * Solution 3 *
-
 
11353
    **************
-
 
11354
 
-
 
11355
By Anonymous.
-
 
11356
 
-
 
11357
> raw promisc hack is not needed
-
 
11358
> there is a more elegant way to capture port mirrored traffic:
-
 
11359
>
-
 
11360
> 1. create a bridge of eth0 and dummy0
-
 
11361
> 2. put eth0 to promisc
-
 
11362
> 3. add a "-i br0 -j NETFLOW" rule to FORWARD (possibly also -j DROP after that)
-
 
11363
>
-
 
11364
> ...for some reason it works when ipt_netflow is attached to a bridge, but
-
 
11365
> requires the promisc hack when attached to a real promisc interface.
-
 
11366
 
-
 
11367
Sometimes you may need to run:
-
 
11368
 
-
 
11369
 # brctl setageing br0 0
-
 
11370
 
-
 
11371
for this scheme to work.
-
 
11372
 
-
 
11373
ipt-netflow-2.2/murmur3.h0000644000000000000000000000171213213006644014106 0ustar  rootroot/* MurmurHash3, based on https://code.google.com/p/smhasher of Austin Appleby. */
-
 
11374
 
-
 
11375
static __always_inline uint32_t rotl32(const uint32_t x, const int8_t r)
-
 
11376
{
-
 
11377
	return (x << r) | (x >> (32 - r));
-
 
11378
}
-
 
11379
 
-
 
11380
static __always_inline uint32_t fmix32(register uint32_t h)
-
 
11381
{
-
 
11382
	h ^= h >> 16;
-
 
11383
	h *= 0x85ebca6b;
-
 
11384
	h ^= h >> 13;
-
 
11385
	h *= 0xc2b2ae35;
-
 
11386
	h ^= h >> 16;
-
 
11387
	return h;
-
 
11388
}
-
 
11389
 
-
 
11390
static inline uint32_t murmur3(const void *key, const uint32_t len, const uint32_t seed)
-
 
11391
{
-
 
11392
	const uint32_t c1 = 0xcc9e2d51;
-
 
11393
	const uint32_t c2 = 0x1b873593;
-
 
11394
	const uint32_t *blocks;
-
 
11395
	const uint8_t *tail;
-
 
11396
	register uint32_t h1 = seed;
-
 
11397
	uint32_t k1 = 0;
-
 
11398
	uint32_t i;
-
 
11399
 
-
 
11400
	blocks = (const uint32_t *)key;
-
 
11401
	for (i = len / 4; i; --i) {
-
 
11402
		h1 ^= rotl32(*blocks++ * c1, 15) * c2;
-
 
11403
		h1 = rotl32(h1, 13) * 5 + 0xe6546b64;
-
 
11404
	}
-
 
11405
	tail = (const uint8_t*)blocks;
-
 
11406
	switch (len & 3) {
-
 
11407
		case 3: k1 ^= tail[2] << 16;
-
 
11408
		case 2: k1 ^= tail[1] << 8;
-
 
11409
		case 1: k1 ^= tail[0];
-
 
11410
			h1 ^= rotl32(k1 * c1, 15) * c2;
-
 
11411
	}
-
 
11412
	return fmix32(h1^ len);
-
 
11413
}
-
 
11414
 
-
 
11415
ipt-netflow-2.2/CREDITS0000644000000000000000000000572013213006644013346 0ustar  rootrootLicense is GPL v2, is the same as of Linux kernel:
-
 
11416
 
-
 
11417
   This program is free software: you can redistribute it and/or modify
-
 
11418
   it under the terms of the GNU General Public License as published by
-
 
11419
   the Free Software Foundation, either version 2 of the License, or
-
 
11420
   (at your option) any later version.
-
 
11421
 
-
 
11422
   This program is distributed in the hope that it will be useful,
-
 
11423
   but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
11424
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
11425
   GNU General Public License for more details.
-
 
11426
 
-
 
11427
   You should have received a copy of the GNU General Public License
-
 
11428
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 
11429
 
-
 
11430
 
-
 
11431
Sign-off rule is that of the Linux kernel:
-
 
11432
 
-
 
11433
  Developer's Certificate of Origin 1.1
-
 
11434
 
-
 
11435
  By making a contribution to this project, I certify that:
-
 
11436
 
-
 
11437
  (a) The contribution was created in whole or in part by me and I
-
 
11438
      have the right to submit it under the open source license
-
 
11439
      indicated in the file; or
-
 
11440
 
-
 
11441
  (b) The contribution is based upon previous work that, to the best
-
 
11442
      of my knowledge, is covered under an appropriate open source
-
 
11443
      license and I have the right under that license to submit that
-
 
11444
      work with modifications, whether created in whole or in part
-
 
11445
      by me, under the same open source license (unless I am
-
 
11446
      permitted to submit under a different license), as indicated
-
 
11447
      in the file; or
-
 
11448
 
-
 
11449
  (c) The contribution was provided directly to me by some other
-
 
11450
      person who certified (a), (b) or (c) and I have not modified
-
 
11451
      it.
-
 
11452
 
-
 
11453
  (d) I understand and agree that this project and the contribution
-
 
11454
      are public and that a record of the contribution (including all
-
 
11455
      personal information I submit with it, including my sign-off) is
-
 
11456
      maintained indefinitely and may be redistributed consistent with
-
 
11457
      this project or the open source license(s) involved.
-
 
11458
 
-
 
11459
 
-
 
11460
Principal author and project maintainer:
-
 
11461
 
-
 
11462
   ABC <abc@telekom.ru> [2008-2015]
-
 
11463
 
-
 
11464
 
-
 
11465
Compatibility layer is using code from Linux Kernel and should be
-
 
11466
attributed to respective Linux developers.
-
 
11467
 
-
 
11468
MurmurHash3 is based on smhasher (2012) of Austin Appleby.
-
 
11469
 
-
 
11470
 
-
 
11471
Patch authors and submitters:
-
 
11472
 
-
 
11473
   Ilya Evseev [2010]
-
 
11474
   spizer [2010]
-
 
11475
   Eric W. Biederman [2010]
-
 
11476
   Giedrius Liubavičius [2010]
-
 
11477
   Igor Alov [2010]
-
 
11478
   Alexey Osipov [2011]
-
 
11479
   Pavel Boldin [2012]
-
 
11480
   Alexander Demenshin [2013]
-
 
11481
   uropek [2013]
-
 
11482
   shaman [2013]
-
 
11483
   Jeremy Drake [2013]
-
 
11484
   Matthew Martin [2016] DKMS fixes
-
 
11485
   alex-eri [2016, 2017] OpenWRT compatibility
-
 
11486
 
-
 
11487
 
-
 
11488
Reference or prototype code authors:
-
 
11489
 
-
 
11490
   Valentin V. Yankin [2011] SNMP-index
-
 
11491
 
-
 
11492
 
-
 
11493
Project supporters:
-
 
11494
 
-
 
11495
   Summa Telecom [2014]
-
 
11496
   Starlink [2014]
-
 
11497
   Anonymous
-
 
11498
 
-
 
11499
 
-
 
11500
Extensive testing and other help:
-
 
11501
 
-
 
11502
   Alexander (shulik) [2013]
-
 
11503
   Igor Diakonov @ Summa Telecom [2014]
-
 
11504
   Yuriy Dolgoruk @ Summa Telecom [2014]
-
 
11505
   Andrew Savin @ Starlink [2014]
-
 
11506
   Alexander Zakharov @ WAW Technologies [2015]
-
 
11507
   Ivanov Eduard [2015]
-
 
11508
   Maciej Zdeb [2015]
-
 
11509
 
-
 
11510
 
-
 
11511
(Send your names, emails, or nicks to add to the list.)
-
 
11512
 
-
 
11513
 
-
 
11514
 
-
 
11515

Generated by GNU Enscript 1.6.6.
-
 
11516
 
-
 
11517
 
-
 
11518