免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 887 | 回复: 0
打印 上一主题 下一主题

using mac address in u32 filter [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-03 21:58 |只看该作者 |倒序浏览
lartc.org FAQ: using mac address in u32 filterLinux Advanced Routing & Traffic Control




lartc.org FAQ

:
using mac address in u32 filter
The
u32 can be used to match any bit in the ip header. Before the ip header, there
is a frame header. In that frame header you can find the src and dst mac
address. You can trick the u32 filter in using the frame header if you use
negative offsets.
Decimal Offset
Description
-14:
DST MAC, 6 bytes
-8:
SRC MAC, 6 bytes
-2:
Eth PROTO, 2 bytes, eg. ETH_P_IP
0:
Protocol header (IP Header)
From an email on the
LARTC list :
Egress (match Dst MAC):
... match u16 0xPPPP 0xFFFF at -2 match u32 0xM2M3M4M5 0xFFFFFFFF at -12 match u16 0xM0M1 0xFFFF at -14
Ingress (match Src MAC):
... match u16 0xPPPP 0xFFFF at -2 match u16 0xM4M5 0xFFFF at -4 match u32 0xM0M1M2M3 0xFFFFFFFF at -8
Where PPPP is the Eth Proto Code (from linux/include/linux/if_ether.h):
0800    ETH_P_IP
and M0..M5 are the 6 bytes of the MAC address
Example for matching ETH_P_IP for MAC 00:11:22:33:44:55
Egress:
... match u16 0x0800 0xFFFF at -2 match u32 0x22334455 0xFFFFFFFF at -12 match u16 0x0011 0xFFFF at -14
Ingress:
... match u16 0x0800 0xFFFF at -2 match u16 0x4455 0xFFFF at -4 match u32 0x00112233 0xFFFFFFFF at -8

[email=stef.coene@docum.org?subject=lartc.org%20FAQ]stef.coene@docum.org[/email]

               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/100089/showart_2045072.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP