dev_queue_xmit() 를 이용해서 멀티캐스트 패킷 전송 질문요

vision8520의 이미지

안녕하세요
dev_queue_xmit() 함수를 이용해서 2개의 NIC로 멀티캐스트 패킷을 전송하는 모듈을 만들고잇는데요

eth0으로 전송된 패킷을 ip_rcv에서 후킹해서 확인하고 다시 eth1로 dev_queue_xmit()함수로 전송하는 모듈이에요

근데 문제점이 수신하는 곳에서 확인을 해보니 ethernet header의 destination MAC이 변경되어 수신되더라구요

eth0으로 들어오는 destination MAC은 01:00:5e:01:01:03으로 ipv4 멀티캐스트 MAC인데

eht1로 전송되어 수신된 곳에서 Wireshark로 확인해보니 앞의 4자리가 랜덤으로 변경되서 수신되더라구요

그래서 다시 후킹해서 확인해보니 dev_hard_start_xmit()로 전달되는 skb 버퍼의 ethernet header destination MAC이 변경된걸 확인햇어요

수신되는 컴에서 패킷을 확인해보면 다른건 다 똑같이 날라오는데 유독 ethernet header destination MAC만 변경되어 날라오네요

아시는분 갈켜주세요 ㅠ 제발요 ㅠ

질문 1. 수신된 그대로 netfilter를 거치지 않고 바로 dev_queue_xmit로 전송을하는데 왜 MAC이 변경되는건가요?

질문 2. 변경되지 않게 전송하려면 어떻게 해야하나요?

static void inst_ip_rcv(struct sk_buff *skb, \
					struct net_device *dev, \
					struct packet_type *pt, \
					struct net_device *orig_dev)
{
	struct iphdr *iph;
	struct udphdr * udph;
	struct ethhdr *ethh=(struct ethhdr *)skb->mac_header;
	struct ethhdr *sethh;
	struct sk_buff *send_skb=skb_clone(skb,GFP_ATOMIC);
 
	struct net_device *eth1=dev_get_by_name(&init_net,"eth1");
	unsigned long saddr=0;
	unsigned long daddr=0;
	unsigned short sport=0;
	unsigned short dport=0;
	unsigned char *frame=NULL;
	unsigned char *ptr;
 
 
	iph=(struct iphdr *)skb_network_header(send_skb);
	udph=(struct udphdr *)(skb_network_header(send_skb)+20);
	saddr=ntohl(iph->saddr);
	daddr=ntohl(iph->daddr);
	sport=udph->source;
	dport=udph->dest;
 
 
	send_skb->dev=eth1;
 
	if(iph->protocol==IPPROTO_UDP && ntohs(dport)==5005)
	{
 
		frame=(unsigned char *)kmalloc(ntohs(iph->tot_len)+(ETH_HLEN), GFP_ATOMIC);
		ptr=(frame+(sizeof(struct ethhdr)));
 
		sethh=(struct ethhdr *)frame;
		memcpy(sethh,ethh,sizeof(struct ethhdr));	
		memcpy(ptr,skb->data, ntohs(iph->tot_len));
		send_skb->data=frame;
		send_skb->len=skb->len+sizeof(struct ethhdr);
 
 
		dev_queue_xmit(send_skb);
		kfree(frame);
	}
	else if(iph->protocol==IPPROTO_UDP && ntohs(dport)==5007)
	{		
		frame=(unsigned char *)kmalloc(ntohs(iph->tot_len)+(ETH_HLEN), GFP_ATOMIC);
		ptr=(frame+(sizeof(struct ethhdr)));
 
		sethh=(struct ethhdr *)frame;
		memcpy(sethh,ethh,sizeof(struct ethhdr));
		memcpy(ptr,skb->data, ntohs(iph->tot_len));
		send_skb->data=frame;
		send_skb->len=skb->len+sizeof(struct ethhdr);
 
		dev_queue_xmit(send_skb);
		kfree(frame);
 
	}
 
 
	jprobe_return();
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.