Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:44:33+00:00 2026-06-15T17:44:33+00:00

I have some machines running on the same network. One node is the control

  • 0

I have some machines running on the same network. One node is the control node which distributes traffic coming to it to the other nodes. The thing is that I want to have a custom protocol header between MAC header and IP(or whatever) payload incoming to the control node.

Control node receives this any packet like this:

------------------------------------------------
| Layer 2 | IP(or whatever protocol) | Payload |
------------------------------------------------

This packet should be distributed like this to other nodes

----------------------------------------------------------------
| Layer 2 | Custom Header | IP(or whatever protocol) | Payload |
----------------------------------------------------------------

I want some directions to do such a thing, Is there any current solution which I can use and I have to hack kernel for it from the scratch. A similar approach is to use L2TP but that runs over IP layer so I dont want that.

I also want this communication to be appeared as a seperate interface in linux like tun0 apart from physical eth0 interface.

Any help or ideas would be highly appreciated.

I dont know in what stack-exchange website this question belongs to so directions to correct website are also appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:44:34+00:00Added an answer on June 15, 2026 at 5:44 pm

    Your case is very similar to VLAN, where VLAN header also sits between L2 header and IP header. You can take a look at VLAN code, especially net/8021q/vlan_dev.c.

    The key here is you need to construct your own L2 header, so you need to register your own header_ops like what VLAN does:

    static const struct header_ops vlan_header_ops = {
            .create  = vlan_dev_hard_header,
            .rebuild = vlan_dev_rebuild_header,
            .parse   = eth_header_parse,
    };
    

    and register it during initialization:

    dev->header_ops      = &vlan_header_ops;
    dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
    

    The ->create() function pointer here is used to create the custom header:

    static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
                    unsigned short type,
                    const void *daddr, const void *saddr,
                    unsigned int len)
    {
        struct vlan_hdr *vhdr;
        unsigned int vhdrlen = 0;
        u16 vlan_tci = 0;
        int rc;
    
        if (!(vlan_dev_priv(dev)->flags & VLAN_FLAG_REORDER_HDR)) {
            vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
    
            vlan_tci = vlan_dev_priv(dev)->vlan_id;
            vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
            vhdr->h_vlan_TCI = htons(vlan_tci);
    
            /*
             *  Set the protocol type. For a packet of type ETH_P_802_3/2 we
             *  put the length in here instead.
             */
            if (type != ETH_P_802_3 && type != ETH_P_802_2)
                vhdr->h_vlan_encapsulated_proto = htons(type);
            else
                vhdr->h_vlan_encapsulated_proto = htons(len);
    
            skb->protocol = htons(ETH_P_8021Q);
            type = ETH_P_8021Q;
            vhdrlen = VLAN_HLEN;
        }
    
        /* Before delegating work to the lower layer, enter our MAC-address */
        if (saddr == NULL)
            saddr = dev->dev_addr;
    
        /* Now make the underlying real hard header */
        dev = vlan_dev_priv(dev)->real_dev;
        rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen);
        if (rc > 0)
            rc += vhdrlen;
        return rc;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an installer which installs services and then starts them. On some machines
I have two ubuntu linux boxes: I'm in bash on one machine running some
I have some code that is running on several machines, and accesses an Oracle
I currently have 2 virtual machines running, one is a server and one is
I have some security related service running on my machine (start type = automatic)
So I have to run some python scripts on a cluster with machines for
I have a buildbot with some builders and two slave machines. Some of the
I have some files which need to be sftp from machine B ( linux
I have a linux vm which is our testing machine. as part of some
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.